Skip to main content

Function modifiers

clamp

Commentary

added in 0.7.12

Restricts a numeric value within a given lower and upper range.


Examples

Clamping to literal values

Use clamp with a minimum and maxiumum value. In this example, the value will never be below 2 or above 15.

{
"_gen": "normalDistribution",
"mean": 10,
"sd": 7,
"clamp": [
2,
15
]
}
[
15,
7.531646563281007,
13.014154562987816,
15,
15,
15,
2,
2,
15,
15
]

Specification

JSON schema

{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"_gen": {
"type": "string"
}
},
"required": [
"_gen"
]
}
]
}
}