pyesmda.empirical_covariance_upper#

pyesmda.empirical_covariance_upper(ensemble: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]][source]#

Compute the upper triangular part of the empirical covariance matrix X.

The output shape (num_variables, num_observations).

Parameter#

ensemble: NDArrayFloat

Ensemble of values.

Examples

>>> X = np.array([[-2.4, -0.3,  0.7,  0.2,  1.1],
...               [-1.5,  0.4, -0.4, -0.9,  1. ],
...               [-0.1, -0.4, -0. , -0.5,  1.1]])
>>> empirical_covariance_upper(X.T)
array([[1.873, 0.981, 0.371],
       [0.   , 0.997, 0.392],
       [0.   , 0.   , 0.407]])

Naive computation:

>>> approximate_covariance_matrix_from_ensembles(X.T, X.T)
array([[1.873, 0.981, 0.371],
       [0.981, 0.997, 0.392],
       [0.371, 0.392, 0.407]])