Skip to main content

Module confidence

Module confidence 

Source
Expand description

How far a layer trusts one of its estimates.

A Confidence holds a Level, the Reasons behind it and an optional spread, or states that the layer made no estimate. The level is stored, not derived: each estimator sets it from its own signals. A confidence is never one float, because the agent that reads the report needs the level and the reasons to decide what to override.

The spread is typed: Confidence<Octaves> describes a cutoff whose spread is in octaves, Confidence<Cents> a unison offset whose spread is in cents. An estimate that has no spread, such as a menu choice, uses Confidence<NoSpread>.

In a report a confidence is one JSON object:

{"level": "medium", "reasons": [{"code": "active_frames", "value": 412}], "spread": 0.3, "estimate": true}

spread is left out when there is none. A “no estimate” state writes "estimate": false, no level, no spread and at least one reason. Deserialization applies the same rules as the constructors.

Structs§

Confidence
The confidence of one estimate: a level with an optional spread, or no estimate. Either state carries at least one Reason.
ConfidenceError
A Confidence or a Reason whose parts do not fit together.
Estimate
A value with its confidence. The value is present exactly when the confidence is an estimate.
Reason
A reason code with the value of its signal.

Enums§

Level
How far an estimator trusts its value. The order is Low < Medium < High, so a per-layer cap is level.min(cap).
NoSpread
The spread type of an estimate that has no spread, such as a menu choice. It has no values, so a Confidence<NoSpread> never holds a spread.
ReasonCode
Why an estimator chose its level, or why it made no estimate.
Signal
The value of the signal behind a ReasonCode.

Traits§

Spread
A unit a spread can be given in: every unit type except Bpm, whose range excludes zero, or NoSpread.