functionclip
Clip values so they do not extend beyond a given interval
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 clip a list of input values x so that any component x_i of x will be x_i for min ≤ x_i ≤ max, min for x_i < min, and max for x_i > max.
Syntax
Function.clip(x); // {min, max} = {-1,1}
Function.clip(x, {min, max});
Examples
Function.clip({-3,-2,-1,0,1,2,3}); // {-1,-1,-1,0,1,1,1}
Function.clip({-3,-2,-1,0,1,2,3},{-2,2}); // {-2,-2,-1,0,1,2,2}
Notes
This function is closely modeled to Clip in the Wolfram Language.
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[:] | x | List of values to be clipped | |
| Real | interval | {-1, 1} | Interval [min,max] given as a list (default = {-1,1}) |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[size(x, 1)] | y | Clipped values |
Revisions
- Added
Inline = truein v2.1.0.