helpers.scale

helpers.scale(arr, lower_bounds, upper_bounds, as_integers=False)

Sample scaling from unit hypercube to different bounds

Parameters

Name Type Description Default
arr numpy.numpy.ArrayLike A numpy ndarray required
lower_bounds list Lower bounds of transformed data required
upper_bounds list Upper bounds of transformed data required
as_integers bool Should scale design to integer values on specified bounds. Defaults to False.s False

Returns

Type Description
numpy.numpy.ndarray Scaled numpy ndarray to [lower_bounds, upper_bounds]

Examples:

import pyLHD
sample = pyLHD.LatinHypercube(size = (10,2), seed = 1)
sample
array([[0.82496353, 0.42496353],
       [0.12496353, 0.92496353],
       [0.92496353, 0.82496353],
       [0.72496353, 0.32496353],
       [0.22496353, 0.22496353],
       [0.62496353, 0.72496353],
       [0.02496353, 0.52496353],
       [0.42496353, 0.62496353],
       [0.52496353, 0.12496353],
       [0.32496353, 0.02496353]])
lower_bounds = [-3,2]
upper_bounds = [10,4]
pyLHD.scale(sample,lower_bounds, upper_bounds)
array([[ 7.72452593,  2.84992707],
       [-1.37547407,  3.84992707],
       [ 9.02452593,  3.64992707],
       [ 6.42452593,  2.64992707],
       [-0.07547407,  2.44992707],
       [ 5.12452593,  3.44992707],
       [-2.67547407,  3.04992707],
       [ 2.52452593,  3.24992707],
       [ 3.82452593,  2.24992707],
       [ 1.22452593,  2.04992707]])
pyLHD.scale(sample,lower_bounds, upper_bounds, as_integers = True)
array([[ 7,  2],
       [-2,  3],
       [ 9,  3],
       [ 6,  2],
       [-1,  2],
       [ 5,  3],
       [-3,  3],
       [ 2,  3],
       [ 3,  2],
       [ 1,  2]])