spyrit.misc.statistics.Cov2Var

spyrit.misc.statistics.Cov2Var(Cov: ndarray, out_shape=None)[source]

Extracts Variance Matrix from Covariance Matrix.

The Variance matrix is extracted from the diagonal of the Covariance matrix.

Args:

Cov (np.array): Covariance matrix of shape \((N_x, N_x)\).

out_shape (tuple, optional): Shape of the output variance matrix. If None, \(N_x\) must be a perfect square and the output is a square matrix whose shape is \((\sqrt{N_x}, \sqrt{N_x})\). Default is None.

Raises:

ValueError: If the input matrix is not square.

ValueError: If the output shape is not valid.

Returns:

np.array: Variance matrix of shape \((\sqrt{N_x}, \sqrt{N_x})\) or \(out_shape\) if provided.