Skip to main content

Module probability

Module probability 

Source
Expand description

Probability modeling nodes.

Deterministic building blocks for modeling probabilistic behavior in Polydat graphs. All hash-based nodes are pure functions — “randomness” comes from hashing the input, not from a stateful RNG. The same input always produces the same output.

Primary use cases: model adapter result kernels (simulated latency, error injection, bimodal distributions), but usable anywhere in a Polydat pipeline.

DefaultOr rides the rule that PolyWire (Value-typed) args auto-emit accepts_none_inputs() -> true, so the body’s coalesce logic sees Value::None instead of the kernel’s Rule 1 short-circuit.

OneOf rides the Const<Vec<String>> workload-list shape; its non-empty-values check fires at eval time rather than at construction (the macro-emitted new() is infallible). OneOfWeighted rides the #[poly_const] setup pattern, parsing the spec once into a cached WeightedTable.

Structs§

Blend
Weighted linear blend of two f64 values.
Chance
Probability chance returning f64-bits in u64 form: returns 1.0_f64.to_bits() with probability p, else 0.0_f64.to_bits().
DefaultOr
Returns the first input if it is not None, otherwise the second.
FairCoin
Fair coin flip: returns 0 or 1 with 50/50 probability.
NOf
N-of-M deterministic fractional selection.
OneOf
Uniform selection from N constant string values.
OneOfWeighted
Weighted selection from a spec string, returning a String.
Select
Binary conditional selection: returns if_true when cond != 0, else if_false.
UnfairCoin
Unfair coin flip: returns 1 with probability p, else 0.
WeightedTable
Pre-parsed value table for one_of_weighted. The cumulative vector is normalised so the last entry is exactly 1.0, letting the eval body locate the matching bucket with a single binary search.

Functions§

n_of_m_eval
Core n-of-m evaluation: hash the input’s position within its window and check whether its rank falls within the selected n.