Covmat

Attention

This is the older version of the covariance matrix calculation. If you care about getting the result, but not on the internal details consider using the CovariatedPrediction transformation instead.

Description

Covmat class contains three distinct trasformations used to calculate the covariance matrix.

  1. cov transformation calculates the full covariance matrix based on statistical errors and input Jacobian.

  2. inv transformation calculates the inverse of the input matrix.

  3. cholesky transformation calculates Cholesky decomposition of the covariance matrix, as needed by the Chi2 transformation.

Cov transformation

Description

Calculate the final covariance matrix based on:
  • statistical errors

  • extra systematical part based on the variation of the prediction \(\mu\) due to variation of the systematical parameters \(\eta\).

Inputs

  1. 'stat' — vector with statistical errors \(S\).

  2. Derivative (Jacobian) \(D_1\) of the prediction \(\mu\) over uncertain parameter \(\eta_1\).

  3. Derivative (Jacobian) \(D_i\) of the prediction \(\mu\) over uncertain parameter \(\eta_i\).

  4. etc.

See Derivative transformation. Parameters \(\eta_i\) are meant to be uncorrelated. (To be updated)

Inputs (derivatives) are processed via rank1(data) method.

Outputs

  1. 'cov' — full covariance matrix \(V\).

Outputs are frozen upon calculation.

Implementation

Calculates covariance matrix \(V\) in the linear approximation:

\[V = V_\text{stat} + D D^T,\]

where \(V_\text{stat}\) is a diagonal matrix with \((V_\text{stat})_{ii} = S_i\).

and \(D\) is the complete Jacobian:

\[D = \{ D_1, D_2, \dots \}.\]

Considering prediction column of size \([N \times 1]\) and uncertainties vector of size \(M\) the Jacobian \(D\) dimension is \([N \times M]\) and covariance matrix \(V\) dimension is \([N \times N]\).

The calculation of \(V\) is implemented iteratively:

\[V_i = V_{i-1} + D_i D_i^T, \quad i=1,2,\dots,\]

where \(V_0=V_\text{stat}\).

Inv transformation

Computes the inverse of a matrix.

Inputs

  1. 'cov' — matrix \(V\).

Outputs

  1. 'inv' — matrix \(V^{-1}\).

Cholesky transformation

Computes the Cholesky decomposition of the symmetric positive definite matrix matrix.

Inputs

  1. 'cov' — matrix \(V\).

Outputs

  1. 'L' — lower triangular matrix \(L\), such that \(V=LL^T\).

IMPORTANT: Be sure to use \(L\) as lower triangular matrix (use numpy.tril or triangularView<Eigen::Lower>). Upper triangular part may contain unmaintained non-zero elements.