rescale

Rescale values from one range to another

Information

This information is part of the Business Simulation Library (BSL). Please support this work and ► donate.

The function will rescale the input to run from range y_min to y_max over the range min to max.

Syntax


Function.rescale(x, {x_min, x_max});                 // {y_min, y_max} by default assumed to be {0,1}
Function.rescale(x, {min, max}, {y_min, y_max}); 

Examples


Function.rescale(5, {0, 10});                 // 0.5
Function.rescale(5, {0, 10}, {10, 20}); // 15.

Notes

This function is closely modeled to Rescale in the Wolfram Language.

See also

Functions.rescaleVector

Syntax

y = rescale(x, x_range, y_range)

Inputs (3)

x

Type: Real

Description: Value to be transformed

x_range

Type: Real[2]

Description: Original range [min,max] given as a list

y_range

Default Value: {0, 1}

Type: Real[2]

Description: Rescaled range [y_min, y_max] given as a list (default = {0,1})

Outputs (1)

y

Type: Real

Description: Rescaled value to run from y_min to y_max over the range min to max

Revisions

  • Added Inline = true in v2.1.0.