Discrete Distributions
UML Overview
AbstractDiscreteDistribution
Bases: object
Source code in qmcpy/discrete_distribution/abstract_discrete_distribution.py
__call__
- If just
n
is supplied, generate samples from the sequence at indices 0,...,n
-1. - If
n_min
andn_max
are supplied, generate samples from the sequence at indicesn_min
,...,n_max
-1. - If
n
andn_min
are supplied, then generate samples from the sequence at indicesn
,...,n_min
-1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
Union[None, int]
|
Number of points to generate. |
None
|
n_min
|
Union[None, int]
|
Starting index of sequence. |
None
|
n_max
|
Union[None, int]
|
Final index of sequence. |
None
|
return_binary
|
bool
|
Only used for |
False
|
warn
|
bool
|
If |
True
|
Returns:
Name | Type | Description |
---|---|---|
x |
ndarray
|
Samples from the sequence.
Note that if |
Source code in qmcpy/discrete_distribution/abstract_discrete_distribution.py
spawn
Spawn new instances of the current discrete distribution but with new seeds and dimensions. Used by multi-level QMC algorithms which require different seeds and dimensions on each level.
Note
Use replications
instead of using spawn
when possible, e.g., when spawning copies which all have the same dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s
|
int
|
Number of copies to spawn |
1
|
dimensions
|
ndarray
|
Length |
None
|
Returns:
Name | Type | Description |
---|---|---|
spawned_discrete_distribs |
list
|
Discrete distributions with new seeds and dimensions. |
Source code in qmcpy/discrete_distribution/abstract_discrete_distribution.py
DigitalNetB2
Bases: AbstractLDDiscreteDistribution
Low discrepancy digital net in base 2.
Note
- Digital net sample sizes should be powers of \(2\) e.g. \(1\), \(2\), \(4\), \(8\), \(16\), \(\dots\).
- The first point of an unrandomized digital nets is the origin.
Sobol
is an alias forDigitalNetB2
.-
To use higher order digital nets, either:
- Pass in
generating_matrices
without interlacing and supplyalpha
>1 to apply interlacing, or - Pass in
generating_matrices
with interlacing and setalpha=1
to avoid additional interlacing
i.e. do not pass in interlaced
generating_matrices
and setalpha>1
, this will apply additional interlacing. - Pass in
Examples:
>>> discrete_distrib = DigitalNetB2(2,seed=7)
>>> discrete_distrib(4)
array([[0.72162356, 0.914955 ],
[0.16345554, 0.42964856],
[0.98676255, 0.03436384],
[0.42956655, 0.55876342]])
>>> discrete_distrib(1) # first point in the sequence
array([[0.72162356, 0.914955 ]])
>>> discrete_distrib
DigitalNetB2 (AbstractLDDiscreteDistribution)
d 2^(1)
replications 1
randomize LMS DS
gen_mats_source joe_kuo.6.21201.txt
order RADICAL INVERSE
t 63
alpha 1
n_limit 2^(32)
entropy 7
Replications of independent randomizations
>>> x = DigitalNetB2(dimension=3,seed=7,replications=2)(4)
>>> x.shape
(2, 4, 3)
>>> x
array([[[0.24653277, 0.1821862 , 0.74732591],
[0.68152903, 0.66169442, 0.42891961],
[0.48139855, 0.79818233, 0.08201287],
[0.91541325, 0.29520621, 0.77495809]],
[[0.44876891, 0.85899604, 0.50549679],
[0.53635924, 0.04353443, 0.33564946],
[0.23214143, 0.29281506, 0.06841036],
[0.75295715, 0.60241448, 0.76962976]]])
Different orderings (avoid warnings that the first point is the origin)
>>> DigitalNetB2(dimension=2,randomize=False,order="GRAY")(n_min=2,n_max=4,warn=False)
array([[0.75, 0.25],
[0.25, 0.75]])
>>> DigitalNetB2(dimension=2,randomize=False,order="RADICAL INVERSE")(n_min=2,n_max=4,warn=False)
array([[0.25, 0.75],
[0.75, 0.25]])
Generating matrices from https://github.com/QMCSoftware/LDData/tree/main/dnet
>>> DigitalNetB2(dimension=3,randomize=False,generating_matrices="mps.nx_s5_alpha2_m32.txt")(8,warn=False)
array([[0. , 0. , 0. ],
[0.75841841, 0.45284834, 0.48844557],
[0.57679828, 0.13226272, 0.10061957],
[0.31858402, 0.32113875, 0.39369111],
[0.90278927, 0.45867532, 0.01803333],
[0.14542431, 0.02548793, 0.4749614 ],
[0.45587539, 0.33081476, 0.11474426],
[0.71318879, 0.15377192, 0.37629925]])
All randomizations
>>> DigitalNetB2(dimension=3,randomize='LMS DS',seed=5)(8)
array([[0.69346401, 0.20118185, 0.64779396],
[0.43998032, 0.90102467, 0.0936172 ],
[0.86663563, 0.60910036, 0.26043276],
[0.11327376, 0.30772653, 0.93959283],
[0.62102883, 0.79169756, 0.77051637],
[0.37451038, 0.1231324 , 0.46634012],
[0.94785596, 0.38577413, 0.13377215],
[0.20121617, 0.71843325, 0.56293458]])
>>> DigitalNetB2(dimension=3,randomize='LMS',seed=5)(8,warn=False)
array([[0. , 0. , 0. ],
[0.75446077, 0.83265937, 0.69584079],
[0.42329494, 0.65793842, 0.90427279],
[0.67763292, 0.48937304, 0.33344964],
[0.18550714, 0.97332905, 0.3772791 ],
[0.93104851, 0.17195496, 0.82311652],
[0.26221346, 0.31742386, 0.53093284],
[0.50787715, 0.5172669 , 0.2101083 ]])
>>> DigitalNetB2(dimension=3,randomize='DS',seed=5)(8)
array([[0.68383949, 0.04047995, 0.42903182],
[0.18383949, 0.54047995, 0.92903182],
[0.93383949, 0.79047995, 0.67903182],
[0.43383949, 0.29047995, 0.17903182],
[0.55883949, 0.66547995, 0.05403182],
[0.05883949, 0.16547995, 0.55403182],
[0.80883949, 0.41547995, 0.80403182],
[0.30883949, 0.91547995, 0.30403182]])
>>> DigitalNetB2(dimension=3,randomize='OWEN',seed=5)(8)
array([[0.33595486, 0.05834975, 0.30066401],
[0.89110875, 0.84905188, 0.81833285],
[0.06846074, 0.59997956, 0.67064205],
[0.6693703 , 0.25824002, 0.10469644],
[0.44586618, 0.99161977, 0.1873488 ],
[0.84245267, 0.16445553, 0.56544372],
[0.18546359, 0.44859876, 0.97389524],
[0.61215442, 0.64341386, 0.44529863]])
Higher order net without randomization
>>> DigitalNetB2(dimension=3,randomize='FALSE',seed=7,alpha=2)(4,warn=False)
array([[0. , 0. , 0. ],
[0.75 , 0.75 , 0.75 ],
[0.4375, 0.9375, 0.1875],
[0.6875, 0.1875, 0.9375]])
Higher order nets with randomizations and replications
>>> DigitalNetB2(dimension=3,randomize='LMS DS',seed=7,replications=2,alpha=2)(4,warn=False)
array([[[0.42955149, 0.89149058, 0.43867111],
[0.68701828, 0.07601148, 0.51312447],
[0.10088033, 0.16293661, 0.25144138],
[0.85846252, 0.87103178, 0.70041789]],
[[0.27151905, 0.42406763, 0.21917369],
[0.55035224, 0.67864387, 0.90033876],
[0.19356758, 0.57589964, 0.00347701],
[0.97235125, 0.32168581, 0.86920948]]])
>>> DigitalNetB2(dimension=3,randomize='LMS',seed=7,replications=2,alpha=2)(4,warn=False)
array([[[0. , 0. , 0. ],
[0.75817062, 0.96603053, 0.94947625],
[0.45367986, 0.80295638, 0.18778553],
[0.71171791, 0.2295424 , 0.76175441]],
[[0. , 0. , 0. ],
[0.78664636, 0.75470215, 0.86876474],
[0.45336727, 0.99953621, 0.22253579],
[0.73996397, 0.24544824, 0.9008679 ]]])
>>> DigitalNetB2(dimension=3,randomize='DS',seed=7,replications=2,alpha=2)(4)
array([[[0.04386058, 0.58727432, 0.3691824 ],
[0.79386058, 0.33727432, 0.6191824 ],
[0.48136058, 0.39977432, 0.4316824 ],
[0.73136058, 0.64977432, 0.6816824 ]],
[[0.65212985, 0.69669968, 0.10605352],
[0.40212985, 0.44669968, 0.85605352],
[0.83962985, 0.25919968, 0.16855352],
[0.08962985, 0.50919968, 0.91855352]]])
>>> DigitalNetB2(dimension=3,randomize='OWEN',seed=7,replications=2,alpha=2)(4)
array([[[0.46368517, 0.03964427, 0.62172094],
[0.7498683 , 0.76141348, 0.4243043 ],
[0.01729754, 0.97968459, 0.65963223],
[0.75365329, 0.1903774 , 0.34141493]],
[[0.52252547, 0.5679709 , 0.05949112],
[0.27248656, 0.36488289, 0.81844058],
[0.94219959, 0.39172304, 0.20285965],
[0.19716391, 0.64741585, 0.92494554]]])
References:
-
Marius Hofert and Christiane Lemieux.
qrng: (Randomized) Quasi-Random Number Generators (2019).
R package version 0.0-7.
https://CRAN.R-project.org/package=qrng. -
Faure, Henri, and Christiane Lemieux.
Implementation of Irreducible Sobol' Sequences in Prime Power Bases.
Mathematics and Computers in Simulation 161 (2019): 13-22. Crossref. Web. -
F.Y. Kuo, D. Nuyens.
Application of quasi-Monte Carlo methods to elliptic PDEs with random diffusion coefficients - a survey of analysis and implementation.
Foundations of Computational Mathematics, 16(6):1631-1696, 2016.
https://link.springer.com/article/10.1007/s10208-016-9329-5. -
D. Nuyens.
The Magic Point Shop of QMC point generators and generating vectors.
MATLAB and Python software, 2018.
https://people.cs.kuleuven.be/~dirk.nuyens/. -
R. Cools, F.Y. Kuo, D. Nuyens.
Constructing embedded lattice rules for multivariate integration.
SIAM J. Sci. Comput., 28(6), 2162-2188. -
I.M. Sobol', V.I. Turchaninov, Yu.L. Levitan, B.V. Shukhman.
Quasi-Random Sequence Generators.
Keldysh Institute of Applied Mathematics.
Russian Academy of Sciences, Moscow (1992). -
Sobol, Ilya & Asotsky, Danil & Kreinin, Alexander & Kucherenko, Sergei. (2011).
Construction and Comparison of High-Dimensional Sobol' Generators. Wilmott. 2011.
10.1002/wilm.10056. -
Paul Bratley and Bennett L. Fox.
Algorithm 659: Implementing Sobol's quasirandom sequence generator.
ACM Trans. Math. Softw. 14, 1 (March 1988), 88-100. 1988.
https://doi.org/10.1145/42288.214372.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dimension
|
Union[int, ndarray]
|
Dimension of the generator.
|
1
|
replications
|
int
|
Number of independent randomizations of a pointset. |
None
|
seed
|
Union[None,int,np.random.SeedSeq
|
Seed the random number generator for reproducibility. |
None
|
randomize
|
str
|
Options are
|
'LMS DS'
|
generating_matrices
|
Union[str, ndarray, int]
|
Specify the generating matrices.
|
'joe_kuo.6.21201.txt'
|
order
|
str
|
|
'RADICAL INVERSE'
|
t
|
int
|
Number of bits in integer represetation of points after randomization. The number of bits in the generating matrices is inferred based on the largest value. |
63
|
alpha
|
int
|
Interlacing factor for higher order nets. |
1
|
msb
|
bool
|
Flag for Most Significant Bit (MSB) vs Least Significant Bit (LSB) integer representations in generating matrices. If |
None
|
_verbose
|
bool
|
If |
False
|
Source code in qmcpy/discrete_distribution/digital_net_b2/digital_net_b2.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
|
Lattice
Bases: AbstractLDDiscreteDistribution
Low discrepancy lattice sequence.
Note
- Lattice sample sizes should be powers of \(2\) e.g. \(1\), \(2\), \(4\), \(8\), \(16\), \(\dots\).
- The first point of an unrandomized lattice is the origin.
Examples:
>>> discrete_distrib = Lattice(2,seed=7)
>>> discrete_distrib(4)
array([[0.04386058, 0.58727432],
[0.54386058, 0.08727432],
[0.29386058, 0.33727432],
[0.79386058, 0.83727432]])
>>> discrete_distrib(1) # first point in the sequence
array([[0.04386058, 0.58727432]])
>>> discrete_distrib
Lattice (AbstractLDDiscreteDistribution)
d 2^(1)
replications 1
randomize SHIFT
gen_vec_source kuo.lattice-33002-1024-1048576.9125.txt
order RADICAL INVERSE
n_limit 2^(20)
entropy 7
Replications of independent randomizations
>>> x = Lattice(3,seed=7,replications=2)(4)
>>> x.shape
(2, 4, 3)
>>> x
array([[[0.04386058, 0.58727432, 0.3691824 ],
[0.54386058, 0.08727432, 0.8691824 ],
[0.29386058, 0.33727432, 0.1191824 ],
[0.79386058, 0.83727432, 0.6191824 ]],
[[0.65212985, 0.69669968, 0.10605352],
[0.15212985, 0.19669968, 0.60605352],
[0.90212985, 0.44669968, 0.85605352],
[0.40212985, 0.94669968, 0.35605352]]])
Different orderings (avoid warnings that the first point is the origin).
>>> Lattice(dimension=2,randomize=False,order='RADICAL INVERSE')(4,warn=False)
array([[0. , 0. ],
[0.5 , 0.5 ],
[0.25, 0.75],
[0.75, 0.25]])
>>> Lattice(dimension=2,randomize=False,order='GRAY')(4,warn=False)
array([[0. , 0. ],
[0.5 , 0.5 ],
[0.75, 0.25],
[0.25, 0.75]])
>>> Lattice(dimension=2,randomize=False,order='LINEAR')(4,warn=False)
array([[0. , 0. ],
[0.25, 0.75],
[0.5 , 0.5 ],
[0.75, 0.25]])
Generating vector from https://github.com/QMCSoftware/LDData/tree/main/lattice
>>> Lattice(dimension=3,randomize=False,generating_vector="mps.exod2_base2_m20_CKN.txt")(8,warn=False)
array([[0. , 0. , 0. ],
[0.5 , 0.5 , 0.5 ],
[0.25 , 0.75 , 0.75 ],
[0.75 , 0.25 , 0.25 ],
[0.125, 0.375, 0.375],
[0.625, 0.875, 0.875],
[0.375, 0.125, 0.125],
[0.875, 0.625, 0.625]])
Random generating vector supporting \(2^{25}\) points
>>> discrete_distrib = Lattice(3,generating_vector=25,seed=55,randomize=False)
>>> discrete_distrib.gen_vec
array([[ 1, 11961679, 12107519]], dtype=uint64)
>>> discrete_distrib(4,warn=False)
array([[0. , 0. , 0. ],
[0.5 , 0.5 , 0.5 ],
[0.25, 0.75, 0.75],
[0.75, 0.25, 0.25]])
Two random generating vectors both supporting \(2^{25}\) points along with independent random shifts
>>> discrete_distrib = Lattice(3,seed=7,generating_vector=25,replications=2)
>>> discrete_distrib.gen_vec
array([[ 1, 32809149, 1471719],
[ 1, 275319, 19705657]], dtype=uint64)
>>> discrete_distrib(4)
array([[[0.3691824 , 0.65212985, 0.69669968],
[0.8691824 , 0.15212985, 0.19669968],
[0.6191824 , 0.90212985, 0.44669968],
[0.1191824 , 0.40212985, 0.94669968]],
[[0.10605352, 0.63025643, 0.13630282],
[0.60605352, 0.13025643, 0.63630282],
[0.35605352, 0.38025643, 0.38630282],
[0.85605352, 0.88025643, 0.88630282]]])
References
-
Sou-Cheng T. Choi, Yuhan Ding, Fred J. Hickernell, Lan Jiang, Lluis Antoni Jimenez Rugama, Da Li, Jagadeeswaran Rathinavel, Xin Tong, Kan Zhang, Yizhi Zhang, and Xuan Zhou.
GAIL: Guaranteed Automatic Integration Library (Version 2.3), MATLAB Software, 2019.
http://gailgithub.github.io/GAIL_Dev/. -
F.Y. Kuo, D. Nuyens.
Application of quasi-Monte Carlo methods to elliptic PDEs with random diffusion coefficients - a survey of analysis and implementation.
Foundations of Computational Mathematics, 16(6):1631-1696, 2016.
https://link.springer.com/article/10.1007/s10208-016-9329-5. -
D. Nuyens.
The Magic Point Shop of QMC point generators and generating vectors.
MATLAB and Python software, 2018.
https://people.cs.kuleuven.be/~dirk.nuyens/. -
R. Cools, F.Y. Kuo, D. Nuyens.
Constructing embedded lattice rules for multivariate integration.
SIAM J. Sci. Comput., 28(6), 2162-2188. -
P. L'Ecuyer, D. Munger.
LatticeBuilder: A General Software Tool for Constructing Rank-1 Lattice Rules.
ACM Transactions on Mathematical Software. 42. (2015).
10.1145/2754929.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dimension
|
Union[int, ndarray]
|
Dimension of the generator.
|
1
|
replications
|
int
|
Number of independent randomizations. |
None
|
seed
|
Union[None,int,np.random.SeedSeq
|
Seed the random number generator for reproducibility. |
None
|
randomize
|
str
|
Options are
|
'SHIFT'
|
generating_vector
|
Union[str, ndarray, int]
|
Specify the generating vector.
|
'kuo.lattice-33002-1024-1048576.9125.txt'
|
order
|
str
|
|
'RADICAL INVERSE'
|
m_max
|
int
|
\(2^{m_\mathrm{max}}\) is the maximum number of supported samples. |
None
|
Source code in qmcpy/discrete_distribution/lattice/lattice.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
Halton
Bases: AbstractLDDiscreteDistribution
Low discrepancy Halton points.
Note
- The first point of an unrandomized Halton sequence is the origin.
- QRNG does not support multiple replications (independent randomizations).
Examples:
>>> discrete_distrib = Halton(2,seed=7)
>>> discrete_distrib(4)
array([[0.83790457, 0.89981478],
[0.00986102, 0.4610941 ],
[0.62236343, 0.02796307],
[0.29427505, 0.79909098]])
>>> discrete_distrib
Halton (AbstractLDDiscreteDistribution)
d 2^(1)
replications 1
randomize LMS DP
t 63
n_limit 2^(32)
entropy 7
Replications of independent randomizations
>>> x = Halton(3,seed=7,replications=2)(4)
>>> x.shape
(2, 4, 3)
>>> x
array([[[0.70988236, 0.18180876, 0.54073621],
[0.38178158, 0.61168824, 0.64684354],
[0.98597752, 0.70650871, 0.31479029],
[0.15795399, 0.28162992, 0.98945647]],
[[0.620398 , 0.57025403, 0.46336542],
[0.44021889, 0.69926312, 0.60133428],
[0.89132308, 0.12030255, 0.35715804],
[0.04025218, 0.44304244, 0.10724799]]])
Unrandomized Halton
>>> Halton(2,randomize="FALSE",seed=7)(4,warn=False)
array([[0. , 0. ],
[0.5 , 0.33333333],
[0.25 , 0.66666667],
[0.75 , 0.11111111]])
All randomizations
>>> Halton(2,randomize="LMS DP",seed=7)(4)
array([[0.83790457, 0.89981478],
[0.00986102, 0.4610941 ],
[0.62236343, 0.02796307],
[0.29427505, 0.79909098]])
>>> Halton(2,randomize="LMS DS",seed=7)(4)
array([[0.82718745, 0.90603116],
[0.0303368 , 0.44704107],
[0.60182684, 0.03580544],
[0.30505343, 0.78367016]])
>>> Halton(2,randomize="LMS",seed=7)(4,warn=False)
array([[0. , 0. ],
[0.82822666, 0.92392942],
[0.28838899, 0.46493682],
[0.6165384 , 0.2493814 ]])
>>> Halton(2,randomize="DP",seed=7)(4)
array([[0.11593484, 0.99232505],
[0.61593484, 0.65899172],
[0.36593484, 0.32565839],
[0.86593484, 0.77010283]])
>>> Halton(2,randomize="DS",seed=7)(4)
array([[0.56793849, 0.04063513],
[0.06793849, 0.37396846],
[0.81793849, 0.7073018 ],
[0.31793849, 0.15174624]])
>>> Halton(2,randomize="NUS",seed=7)(4)
array([[0.141964 , 0.99285569],
[0.65536579, 0.51938353],
[0.46955206, 0.11342811],
[0.78505432, 0.87032345]])
>>> Halton(2,randomize="QRNG",seed=7)(4)
array([[0.35362988, 0.38733489],
[0.85362988, 0.72066823],
[0.10362988, 0.05400156],
[0.60362988, 0.498446 ]])
Replications of randomizations
>>> Halton(3,randomize="LMS DP",seed=7,replications=2)(4)
array([[[0.70988236, 0.18180876, 0.54073621],
[0.38178158, 0.61168824, 0.64684354],
[0.98597752, 0.70650871, 0.31479029],
[0.15795399, 0.28162992, 0.98945647]],
[[0.620398 , 0.57025403, 0.46336542],
[0.44021889, 0.69926312, 0.60133428],
[0.89132308, 0.12030255, 0.35715804],
[0.04025218, 0.44304244, 0.10724799]]])
>>> Halton(3,randomize="LMS DS",seed=7,replications=2)(4)
array([[[4.57465163e-01, 5.75419751e-04, 7.47353067e-01],
[6.29314800e-01, 9.24349881e-01, 8.47915779e-01],
[2.37544271e-01, 4.63986168e-01, 1.78817056e-01],
[9.09318567e-01, 2.48566227e-01, 3.17475640e-01]],
[[6.04003127e-01, 9.92849835e-01, 4.21625151e-01],
[4.57027115e-01, 1.97310094e-01, 2.43670150e-01],
[8.76467351e-01, 4.22339232e-01, 1.05777101e-01],
[5.46933622e-02, 7.79075280e-01, 9.29409300e-01]]])
>>> Halton(3,randomize="LMS",seed=7,replications=2)(4,warn=False)
array([[[0. , 0. , 0. ],
[0.82822666, 0.92392942, 0.34057871],
[0.28838899, 0.46493682, 0.47954399],
[0.6165384 , 0.2493814 , 0.77045601]],
[[0. , 0. , 0. ],
[0.93115665, 0.57483093, 0.87170952],
[0.48046642, 0.8122114 , 0.69381851],
[0.58055977, 0.28006957, 0.55586147]]])
>>> Halton(3,randomize="DS",seed=7,replications=2)(4)
array([[[0.56793849, 0.04063513, 0.74276256],
[0.06793849, 0.37396846, 0.94276256],
[0.81793849, 0.7073018 , 0.14276256],
[0.31793849, 0.15174624, 0.34276256]],
[[0.98309816, 0.80260469, 0.17299622],
[0.48309816, 0.13593802, 0.37299622],
[0.73309816, 0.46927136, 0.57299622],
[0.23309816, 0.9137158 , 0.77299622]]])
>>> Halton(3,randomize="DP",seed=7,replications=2)(4)
array([[[0.11593484, 0.99232505, 0.6010751 ],
[0.61593484, 0.65899172, 0.0010751 ],
[0.36593484, 0.32565839, 0.4010751 ],
[0.86593484, 0.77010283, 0.8010751 ]],
[[0.26543198, 0.12273092, 0.20202896],
[0.76543198, 0.45606426, 0.60202896],
[0.01543198, 0.78939759, 0.40202896],
[0.51543198, 0.23384203, 0.00202896]]])
>>> Halton(3,randomize="NUS",seed=7,replications=2)(4)
array([[[0.141964 , 0.99285569, 0.77722918],
[0.65536579, 0.51938353, 0.22797442],
[0.46955206, 0.11342811, 0.9975298 ],
[0.78505432, 0.87032345, 0.57696123]],
[[0.04813634, 0.16158904, 0.56038465],
[0.89364888, 0.33578478, 0.36145822],
[0.34111023, 0.84596814, 0.0292313 ],
[0.71866903, 0.23852281, 0.80431142]]])
References:
-
Marius Hofert and Christiane Lemieux.
qrng: (Randomized) Quasi-Random Number Generators.
R package version 0.0-7. (2019).
https://CRAN.R-project.org/package=qrng. -
A. B. Owen.
A randomized Halton algorithm in R.
arXiv:1706.02808 [stat.CO]. 2017. -
A. B. Owen and Z. Pan.
Gain coefficients for scrambled Halton points.
arXiv:2308.08035 [stat.CO]. 2023.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dimension
|
Union[int, ndarray]
|
Dimension of the generator.
|
1
|
replications
|
int
|
Number of independent randomizations of a pointset. |
None
|
seed
|
Union[None,int,np.random.SeedSeq
|
Seed the random number generator for reproducibility. |
None
|
randomize
|
str
|
Options are
|
'LMS DP'
|
t
|
int
|
Number of bits in integer represetation of points after randomization. The number of bits in the generating matrices is inferred based on the largest value. |
63
|
n_lim
|
int
|
Maximum number of compatible points, determines the number of rows in the generating matrices. |
2 ** 32
|
Source code in qmcpy/discrete_distribution/halton.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
IIDStdUniform
Bases: AbstractIIDDiscreteDistribution
IID standard uniform points, a wrapper around numpy.random.rand
.
Note
- Unlike low discrepancy sequence, calling an
IIDStdUniform
instance gives new samples every time,
e.g., running the first doctest below withdd = Lattice(dimension=2)
would give the same 4 points in both calls,
but since we are using anIIDStdUniform
instance it gives different points every call.
Examples:
>>> discrete_distrib = IIDStdUniform(dimension=2,seed=7)
>>> discrete_distrib(4)
array([[0.04386058, 0.58727432],
[0.3691824 , 0.65212985],
[0.69669968, 0.10605352],
[0.63025643, 0.13630282]])
>>> discrete_distrib(4) # gives new samples every time
array([[0.5968363 , 0.0576251 ],
[0.2028797 , 0.22909681],
[0.1366783 , 0.75220658],
[0.84501765, 0.56269008]])
>>> discrete_distrib
IIDStdUniform (AbstractIIDDiscreteDistribution)
d 2^(1)
replications 1
entropy 7
Replications (implemented for API consistency)
>>> x = IIDStdUniform(dimension=3,replications=2,seed=7)(4)
>>> x.shape
(2, 4, 3)
>>> x
array([[[0.04386058, 0.58727432, 0.3691824 ],
[0.65212985, 0.69669968, 0.10605352],
[0.63025643, 0.13630282, 0.5968363 ],
[0.0576251 , 0.2028797 , 0.22909681]],
[[0.1366783 , 0.75220658, 0.84501765],
[0.56269008, 0.04826852, 0.71308655],
[0.80983568, 0.85383675, 0.80475135],
[0.6171181 , 0.1239209 , 0.16809479]]])
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dimension
|
int
|
Dimension of the samples. |
1
|
replications
|
Union[None, int]
|
Number of randomizations. This is implemented only for API consistency. Equivalent to reshaping samples. |
None
|
seed
|
Union[None,int,np.random.SeedSeq
|
Seed the random number generator for reproducibility. |
None
|