Skip to main content

Math functions

trichotomy

Commentary

added in 0.4.18

Buckets a numeric value into one of three tiers: low, middle, or high.

Low is defined as strictly less than the lower bound, and high as strictly greater than the high bound. Anything in between falls into the mid bucket.


Examples

Bucketing a value

Use bounds and results to create the bucket allocations.

{
"_gen": "trichotomy",
"value": 1,
"low": {
"bound": 0,
"result": "L"
},
"high": {
"bound": 3,
"result": "H"
},
"mid": {
"result": "M"
}
}
[
"M"
]

Specification

JSON schema

{
"type": "object",
"properties": {
"value": {
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"_gen": {
"type": "string"
}
},
"required": [
"_gen"
]
}
]
},
"low": {
"type": "object",
"properties": {
"bound": {
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"_gen": {
"type": "string"
}
},
"required": [
"_gen"
]
}
]
},
"result": {}
},
"required": [
"bound",
"result"
]
},
"high": {
"type": "object",
"properties": {
"bound": {
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"_gen": {
"type": "string"
}
},
"required": [
"_gen"
]
}
]
},
"result": {}
},
"required": [
"bound",
"result"
]
},
"mid": {
"type": "object",
"properties": {
"result": {}
},
"required": [
"result"
]
}
},
"required": [
"value",
"low",
"mid",
"high"
]
}