utils.stats.normalize_X

utils.stats.normalize_X(X, eps=1e-12)

Normalize array X to [0, 1] in each dimension.

For dimensions where all values are identical (X_max == X_min), the normalized value is set to 0.5 to avoid division by zero.

Parameters

Name Type Description Default
X np.ndarray Input array of shape (n, d) to normalize. required
eps float Small value to avoid division by zero when range is very small. Defaults to 1e-12. 1e-12

Returns

Name Type Description
np.ndarray np.ndarray: Normalized array with values in [0, 1] for each dimension. For constant dimensions, values are set to 0.5.

Examples

>>> from spotoptim.utils.stats import normalize_X
>>> X = np.array([[1, 2], [3, 4], [5, 6]])
>>> normalize_X(X)
array([[0. , 0. ],
       [0.5, 0.5],
       [1. , 1. ]])
>>> # Constant dimension example
>>> X_const = np.array([[1, 5], [1, 5], [1, 5]])
>>> normalize_X(X_const)
array([[0.5, 0.5],
       [0.5, 0.5],
       [0.5, 0.5]])