Chi2¶
Description¶
Calculates the \(\chi^2\) value.
Inputs¶
Theory \(\mu\) of size \(N\).
Data \(x\) of size \(N\).
Covariance matrix Cholesky decomposition \(L\) of size \(N\times N\).
Optionally \(\mu_2,x_2,L_2,\dots\) of sizes \(N_2,\dots\).
Inputs are added via add(theory, data, cov)
method.
Outputs¶
'chi2'
— chi-squared value \(\chi^2\).
Implementation¶
For the covariance matrix \(V\) (symmetric, positively defined), decomposed as
\[V = L L^T,\]
where \(L\) is a lower triangular matrix the tranformation returns the \(\chi^2\) value:
\[\chi^2 = (x-\mu)^T V^{-1} (x - \mu).\]
The exact implementation follows:
\[y = L^{-1} (x-\mu),\]
\[\chi^2 = y^T y.\]