total_variance
std.stats.total_variance · Level L3The law of total variance on a finite probability space, with the conditioning given by a partition of the outcomes into cells (g[s] the cell of s): the expected conditional variance E[Var(X | G)], the variance of the conditional mean Var(E[X | G]), and Var(X), which is their sum. A zero-mass cell contributes nothing; its conditional values are determined only almost surely, so it is never divided by. The two parts are not interchangeable, and the cells need not be independent.
Signature
total_variance(p: f64[n], x: f64[n], g: i64[n], cells: f64[k]) → f64[], f64[], f64[]
Structure
The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.
- input
- operation
- constant
- call
- output
Verification
- Signature proven by NOVA’s shape solver, for every size.
- Equal to the reference
cell masses, conditional means and variances, in exact arithmeticin exact rational arithmetic, on all 40 test cases. - All 120 float64 results inside the running error bound; the closest uses 22% of it.
- Interpreter and NumPy backend return bit-identical results.
- At float32 too: the 40 test cases rounded to float32, and 40 of them inside the running error bound at u = 2⁻²⁴; the closest uses 11% of it.
- correctly rounded (the float64 nearest the exact value)
- 70%
- bit-equal to the NumPy formula in float64
- 79%
- largest error, in units in the last place
- 171
Large ulp counts appear where a result is tiny next to the numbers it is computed from (after cancellation, for example), so one unit in the last place is tiny too; the absolute error is still inside the bound. Results within their own error of zero are not counted.
Identity
sha256:b1e53e785848a25f7f7e002a313a11040062ad85e638174938b9440b850568e2The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.
Control handle
- Symbol
- Ω:std.stats.total_variance · Ω:total_variance
- Pins
sha256:5442887cb74be492db3cfae7a45f8ea54be2b441849d66719076b853a600226cthis graph and the 1 it reaches through calls- Evidence
sha256:40f15d97dc38a8e464eb3d4accc4f8d58592e0eb5f1b0a8c23f2e093bd9bf921the hash of its verification record- Needs
- no capability: a pure function
Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.