Skip to main content

answer_margin

Function answer_margin 

Source
pub fn answer_margin(answer: &Answer) -> f32
Expand description

How narrowly the answer won: the top probability minus the runner-up, never negative.

The runner-up is the larger of the second reported probability and the mass nobody reported (1 - sum, at least zero): a provider reporting only {"true": 0.55} has left 0.45 on the other side, so its margin is 0.10, not 0.55. With no probabilities at all the top is Answer::confidence and the rest of the mass is the runner-up, so the margin is 2 * confidence - 1.

A NaN among the numbers it is computed from gives a NaN, which clears no threshold and is stored as absent, rather than a made-up zero.