| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Harmonic.Traversal.Probabilistic
Description
This module implements probabilistic selection for the generative engine.
The "entropy" knob targets a rank in the sorted candidate list:
entropy * 10 is roughly the median index drawn, so entropy 0.5
wanders around the 5th-ranked candidate and entropy 2 around the
20th. The gamma distribution's right skew keeps mass near the top of
the ranking while allowing occasional deep reaches.
Academic Lineage
Data Science In The Creative Process (South, 2018): the probabilistic
traversal strategy (T component of Wiggins' Creative Systems Framework).
The original implementation used R's rgamma via inline-r; this module
replaces it with a pure Haskell gamma distribution from mwc-random.
Synopsis
- gammaIndexScaledWith :: GenIO -> Double -> Int -> IO Int
Documentation
Arguments
| :: GenIO | Shared random generator |
| -> Double | Entropy (>= 0; 10x the target rank) |
| -> Int | Pool size (e.g., 30) |
| -> IO Int |
Draw an index into a ranked candidate pool (best first, index 0).
Entropy maps to gamma shape (shape = entropy * 10 + 0.5), making the
mean drawn index approximately entropy * 10: entropy 0 usually (but
not always) picks the top candidate, entropy 1 targets around rank 10,
and values above 1 reach proportionally deeper. Negative entropy is
clamped to 0; there is no upper bound.
The shape is capped at poolSize - 1 so a small pool is sampled across
its whole range instead of having the overflow mass collapse onto its
worst-ranked element, and draws past the end are re-drawn (truncation
by rejection) rather than clamped, for the same reason. The cap only
ever lowers the target — a large pool never has its reach extended.