transform
scale(X, lower, upper)
Sample scaling from unit hypercube to different bounds.
Converts a sample from [0, 1)
to [a, b)
.
Note: equal lower and upper bounds are feasible.
The following transformation is used:
(b - a) * X + a
X (array): Sample to scale. lower (array): lower bound of transformed data. upper (array): upper bounds of transformed data.
(array): Scaled sample.
Examples:
Transform three samples in the unit hypercube to (lower, upper) bounds:
import numpy as np from scipy.stats import qmc from spotPython.utils.transform import scale lower = np.array([6, 0]) upper = np.array([6, 5]) sample = np.array([[0.5 , 0.75], [0.5 , 0.5], [0.75, 0.25]]) scale(sample, lower, upper)
Source code in spotPython/utils/transform.py
1 2 3 4 5 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 |
|