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
]
}
[
9.52779765902852,
7.63692021058792,
15,
15,
8.41533410983157,
11.179519625842072,
10.736047130101047,
2,
2.116485303025301,
10.510891049592923
]
Specification
JSON schema
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"_gen": {
"type": "string"
}
},
"required": [
"_gen"
]
}
]
}
}