sobol
Sobol
¶
Bases: Designs
Super class for sobol designs.
Attributes:
Name | Type | Description |
---|---|---|
k |
int
|
The number of factors. |
seed |
int
|
The seed for the random number generator. |
Source code in spotpython/design/sobol.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
__init__(k=2, seed=123)
¶
Initializes a sobol design object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
k |
int
|
The number of factors (dimension). Defaults to 2. |
2
|
seed |
int
|
The seed for the random number generator. Defaults to 123. |
123
|
Source code in spotpython/design/sobol.py
15 16 17 18 19 20 21 22 23 24 25 |
|
generate_sobol_design(n_points, seed=None)
¶
Generates a Sobol sequence design
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_points |
int
|
The number of points to generate in the Sobol sequence. |
required |
seed |
Optional[int]
|
The seed for the random number generator. If None, uses the instance’s seed. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: An array of shape (n_points, n_dim) containing the generated Sobol sequence points. |
Notes
- The Sobol sequence is generated with a length that is a power of 2. The function generates at least n_points and returns the first n_points.
- For n_points not being a power of 2, extra points are generated and truncated.
- Scrambling is enabled for improved uniformity.
Examples:
>>> from spotpython.design.sobol import Sobol
>>> sobol_design = Sobol(k=3, seed=42)
>>> sobol_points = sobol_design.generate_sobol_design(n_points=10)
>>> print(sobol_points.shape)
(10, 3)
Source code in spotpython/design/sobol.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|