From 5dd365a997629eea82247bd3a4dacb9c6e25d929 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Fri, 4 Mar 2022 11:10:59 +0000 Subject: [PATCH] feat: Warning added when trying to estimate a covariance matrix from observables with too few samples. --- pyerrors/obs.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyerrors/obs.py b/pyerrors/obs.py index bea49bbb..a806c597 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -1354,6 +1354,11 @@ def covariance(obs, visualize=False, correlation=False, **kwargs): ''' length = len(obs) + + max_samples = np.max([o.N for o in obs]) + if max_samples <= length: + warnings.warn(f"The dimension of the covariance matrix ({length}) is larger or equal to the number of samples ({max_samples}). This will result in a rank deficient matrix.", RuntimeWarning) + cov = np.zeros((length, length)) for i in range(length): for j in range(i, length):