functionrescaleVector
Rescale a list of values from one range to another
Extends from BusinessSimulation.Icons.Function (Icon for functions).
Information
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.
Syntax
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});
Examples
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.}
Notes
This function is closely modeled to Rescale in the Wolfram Language.
See also
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[:] | x | List of values (vector) to be rescaled | |
| Real[2] | x_range | {min(x), max(x)} | Original range [min,max] given as a list (default = {min(x), max(x)}) |
| Real[2] | y_range | {0, 1} | Rescaled range [y_min, y_max] given as a list (default = {0,1}) |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[size(x, 1)] | y | Rescaled value to run from y_min to y_max over the range min to max |
Revisions
- Corrected documentation errors, simplified implementation and added
Inline = truein v.2.1.0.