diff --git a/tests/fits_test.py b/tests/fits_test.py index b6236fb9..374550e4 100644 --- a/tests/fits_test.py +++ b/tests/fits_test.py @@ -157,6 +157,28 @@ def test_correlated_fit(): assert(diff.is_zero_within_error(sigma=5)) +def test_fit_corr_independent(): + dim = 50 + x = np.arange(dim) + y = 0.84 * np.exp(-0.12 * x) + np.random.normal(0.0, 0.1, dim) + yerr = [0.1] * dim + + oy = [] + for i, item in enumerate(x): + oy.append(pe.pseudo_Obs(y[i], yerr[i], str(i))) + + def func(a, x): + y = a[0] * anp.exp(-a[1] * x) + return y + + out = pe.least_squares(x, oy, func) + out_corr = pe.least_squares(x, oy, func, correlated_fit=True) + + assert np.isclose(out.chisquare, out_corr.chisquare) + assert (out[0] - out_corr[0]).is_zero(atol=1e-5) + assert (out[1] - out_corr[1]).is_zero(atol=1e-5) + + def test_total_least_squares(): dim = 10 + int(30 * np.random.rand()) x = np.arange(dim) + np.random.normal(0.0, 0.15, dim)