rescaleVectorRescale a list of values from one range to another |
This information is part of the Business Simulation Library (BSL). Please support this work and ► donate.
The function will rescale the input vector to a vector whose elements run from range y_min
to y_max
over the range min
to max
.
Function.rescaleVector(x); // min = min(vec), max = max(vec), y_min = 0, y_max = 1 Function.rescaleVector(x, {min, max}); // y_min = 0 , y_max = 1 Function.rescaleVector(x, {min, max}, {y_min, y_max});
rescaleVector({0,1,2,3,4,5,6,7,8,9,10}); // {0.,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0} rescaleVector({4,5,6},{0, 10}); // {0.4, 0.5, 0.6} rescaleVector({4,5,6},{0,10},{10,20}); // {14.,15.,16.}
This function is closely modeled to Rescale
in the Wolfram Language.
x |
Type: Real[:] Description: List of values (vector) to be rescaled |
---|---|
x_range |
Default Value: {min(x), max(x)} Type: Real[2] Description: Original range [min,max] given as a list (default = {min(x), max(x)}) |
y_range |
Default Value: {0, 1} Type: Real[2] Description: Rescaled range [y_min, y_max] given as a list (default = {0,1}) |
y |
Type: Real[size(x, 1)] Description: Rescaled value to run from y_min to y_max over the range min to max |
---|
Inline = true
in v.2.1.0.