feat: Warning added when trying to estimate a covariance matrix from

observables with too few samples.
This commit is contained in:
Fabian Joswig 2022-03-04 11:10:59 +00:00
parent cec0ec83d7
commit 5dd365a997

View file

@ -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):