gaussian_logpdf

std.stats.gaussian_logpdf · Level L3

The log-density of a multivariate normal N(μ, S) at x, computed the stable way: one Cholesky factorization gives both the log-determinant and, by a triangular solve, the quadratic form.

−½·(k·log 2π + log det S + (x − μ)ᵀS⁻¹(x − μ))

Signature

gaussian_logpdf(x: f64[k], mu: f64[k], S: f64[k, k]) → 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.

muf64[k]xf64[k]Sf64[k, k]SubtractdCholeskyLIotaeye_rIotaeye_cSizek1.83788TriangularSolvezEqualeyeMultiplynormMultiplyzzMultiplyLdiagReduceSumqReduceSumldLoglogsReduceSumhalf_logdet2.0MultiplylogdetAddt1Addt2-0.5Multiplylogplogpf64[]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference -0.5 * (k*log(2π) + sum(log(eigvalsh(S))) + (x-μ) @ solve(S, x-μ)) to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 40 float64 results inside the running error bound; the closest uses 32% of it.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
45%
bit-equal to the NumPy formula in float64
55%
largest error, in units in the last place
3.87

Identity

Calls
—
Called by
—
sha256:4922dd95ecdc8550fe28410027ee60aa1b3195141435e13c6319283f929e05e7

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.