mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
tests: test added that checks that correlated and uncorrelated fits give
the same result if the input data is uncorrelated.
This commit is contained in:
parent
6cb1e98647
commit
c9f65298b4
1 changed files with 22 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue