conditional_expectation
std.stats.conditional_expectation · Level L0The conditional expectation E[Y | X = i] = Σⱼ yⱼ·P(Y = yⱼ | X = i) for a finite joint table and the values yⱼ of Y. Averaging it over P(X) gives E[Y], the law of total expectation.
Signature
conditional_expectation(joint: f64[m, n], y: f64[n]) → f64[m]
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
(joint @ y) / joint.sum(axis=1)in exact rational arithmetic, on all 40 test cases. - All 166 float64 results inside the running error bound; the closest uses 27% 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 57% of it.
- correctly rounded (the float64 nearest the exact value)
- 65%
- bit-equal to the NumPy formula in float64
- 54%
- largest error, in units in the last place
- 95
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:2845a5f2ba21cdd30dfbfdca235bf675238384b5d56abb1dfd09c52e72029ff7The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.
Control handle
- Symbol
- Ω:std.stats.conditional_expectation · Ω:conditional_expectation
- Pins
sha256:af1777a9104238e52c147a1dbaed542f33b638dc7cc7ce3f2ef69170ad0b5f0ethis graph and the 1 it reaches through calls- Evidence
sha256:cfe26f6459b0f34a22c527bc5d910365a5278ca5f6f7018f4a6e629a4ddf5ae5the 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.