Logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2025 Patrick Müller. All rights reserved.

qspec.analyze.covariance_matrix  (  cov = None sigma = None corr = None k = None n = None  )[source]

Helper function to construct covariance matrices $\mathbf{\Sigma}_i\in\mathbb{R}^{n\times n}$ from standard deviations $\vec{\sigma}_i\in\mathbb{R}^n$ and correlation matrices $\mathbf{\rho}_i\in\mathbb{R}^{n\times n}$.

Parameters:
covndarray | Iterable

The covariance matrices $\mathbf{\Sigma}_i$. Must have shape (k, n, n), where k is the number of data points and n the number of dimensions of each data point. If None, the other parameters are used. Else, all other parameters are ignored.

sigmandarray | Iterable

The standard deviations of the data vectors. Must have shape (k, n). If None, all diagonal elements of the covariance matrix equal 1.

corrndarray | Iterable

The correlation matrices of the data vectors. Must have shape (k, n, n). If n == 2 it can have shape (k, ). If None, all off-diagonal elements of the covariance matrix are 0.

kint

The number of data points. It is omitted if sigma or corr is specified.

nint

The number of dimensions $n$ of each data point. It is omitted if sigma or corr is specified.

Returns:
covndarray

Covariance matrices $\mathbf{\Sigma}_i$ constructed from sigma and corr.

API navigation