Added the possibility to use constrained fit parameters. Added correlated least squares.

This commit is contained in:
Simon Kuberski 2021-11-15 16:39:50 +01:00
parent 4bf95da346
commit dbe1c26362
3 changed files with 183 additions and 34 deletions

View file

@ -1196,6 +1196,8 @@ def covariance(obs1, obs2, correlation=False, **kwargs):
if true the correlation instead of the covariance is
returned (default False)
"""
if set(obs1.names).isdisjoint(set(obs2.names)):
return 0.
for name in sorted(set(obs1.names + obs2.names)):
if (obs1.shape.get(name) != obs2.shape.get(name)) and (obs1.shape.get(name) is not None) and (obs2.shape.get(name) is not None):
@ -1287,6 +1289,9 @@ def covariance2(obs1, obs2, correlation=False, **kwargs):
return gamma
if set(obs1.names).isdisjoint(set(obs2.names)):
return 0.
if not hasattr(obs1, 'e_names') or not hasattr(obs2, 'e_names'):
raise Exception('The gamma method has to be applied to both Obs first.')