sampling.lhs
sampling.lhs
Functions
| Name | Description |
|---|---|
| rlh | Generates a random Latin hypercube within the [0,1]^k hypercube. |
rlh
sampling.lhs.rlh(n, k, edges=0, seed=None)Generates a random Latin hypercube within the [0,1]^k hypercube.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| n | int | Desired number of points. | required |
| k | int | Number of design variables (dimensions). | required |
| edges | int | If 1, places centers of the extreme bins at the domain edges ([0,1]). Otherwise, bins are fully contained within the domain, i.e. midpoints. Defaults to 0. | 0 |
Returns
| Name | Type | Description |
|---|---|---|
| np.ndarray | np.ndarray: A Latin hypercube sampling plan of n points in k dimensions, with each coordinate in the range [0,1]. |
Examples
>>> from spotoptim.sampling.lhs import rlh
>>> import numpy as np
>>> # Generate a 2D Latin hypercube with 5 points and edges=0
>>> X = rlh(n=5, k=2, edges=0)
>>> print(X)
# Example output (values vary due to randomness):
# [[0.1 0.5 ]
# [0.7 0.1 ]
# [0.9 0.7 ]
# [0.3 0.9 ]
# [0.5 0.3 ]]