1
- """
2
- Create samples from the `Halton sequence`_.
3
-
4
- In statistics, Halton sequences are sequences used to generate points in space
5
- for numerical methods such as Monte Carlo simulations. Although these sequences
6
- are deterministic, they are of low discrepancy, that is, appear to be random
7
- for many purposes. They were first introduced in 1960 and are an example of
8
- a quasi-random number sequence. They generalise the one-dimensional van der
9
- Corput sequences.
10
-
11
- Example usage
12
- -------------
13
-
14
- Standard usage::
15
-
16
- >>> distribution = chaospy.J(chaospy.Uniform(0, 1), chaospy.Uniform(0, 1))
17
- >>> samples = distribution.sample(3, rule="halton")
18
- >>> samples.round(4)
19
- array([[0.125 , 0.625 , 0.375 ],
20
- [0.4444, 0.7778, 0.2222]])
21
- >>> samples = distribution.sample(4, rule="halton")
22
- >>> samples.round(4)
23
- array([[0.125 , 0.625 , 0.375 , 0.875 ],
24
- [0.4444, 0.7778, 0.2222, 0.5556]])
25
-
26
- .. _Halton sequence: https://en.wikipedia.org/wiki/Halton_sequence
27
- """
1
+ """Create samples from the Halton sequence."""
28
2
import numpy
29
3
30
4
from .van_der_corput import create_van_der_corput_samples
33
7
34
8
def create_halton_samples (order , dim = 1 , burnin = - 1 , primes = ()):
35
9
"""
36
- Create Halton sequence.
10
+ Create samples from the Halton sequence.
37
11
38
- For ``dim == 1`` the sequence falls back to Van Der Corput sequence.
12
+ In statistics, Halton sequences are sequences used to generate points in
13
+ space for numerical methods such as Monte Carlo simulations. Although these
14
+ sequences are deterministic, they are of low discrepancy, that is, appear
15
+ to be random for many purposes. They were first introduced in 1960 and are
16
+ an example of a quasi-random number sequence. They generalise the
17
+ one-dimensional van der Corput sequences. For ``dim == 1`` the sequence
18
+ falls back to Van Der Corput sequence.
39
19
40
20
Args:
41
21
order (int):
@@ -49,8 +29,21 @@ def create_halton_samples(order, dim=1, burnin=-1, primes=()):
49
29
The (non-)prime base to calculate values along each axis. If
50
30
empty, growing prime values starting from 2 will be used.
51
31
52
- Returns (numpy.ndarray):
53
- Halton sequence with ``shape == (dim, order)``.
32
+ Returns:
33
+ (numpy.ndarray):
34
+ Halton sequence with ``shape == (dim, order)``.
35
+
36
+ Examples:
37
+ >>> distribution = chaospy.J(chaospy.Uniform(0, 1), chaospy.Uniform(0, 1))
38
+ >>> samples = distribution.sample(3, rule="halton")
39
+ >>> samples.round(4)
40
+ array([[0.125 , 0.625 , 0.375 ],
41
+ [0.4444, 0.7778, 0.2222]])
42
+ >>> samples = distribution.sample(4, rule="halton")
43
+ >>> samples.round(4)
44
+ array([[0.125 , 0.625 , 0.375 , 0.875 ],
45
+ [0.4444, 0.7778, 0.2222, 0.5556]])
46
+
54
47
"""
55
48
primes = list (primes )
56
49
if not primes :
0 commit comments