Expand description
Histribution: inline discrete histogram distribution.
Parse a frequency spec string into an alias table at init time. The name is a portmanteau of “histogram” + “distribution.”
Two formats:
- Implicit labels:
"50 25 13 12"→ outcomes 0,1,2,3 with those weights - Explicit labels:
"234:50 33:25 17:13 3:12"→ outcomes 234,33,17,3
Structs§
- Histribution
- Sample from a histogram-spec distribution. The input should be hashed (uniform); the output is one of the labeled outcomes, selected by weighted alias sampling.
- Parsed
Histribution - Parsed histribution: labels + weighted alias table. The
#[poly_const]setup returns this single struct so the macro can hand the body a borrow of one cached field rather than a tuple. Labeled by indexi→ outcomelabels[i]; sampling goes throughtable.
Functions§
- parse_
histribution - Parse a histribution spec and build an alias table.