Test for logistic fit and minor fix to fit func
This commit is contained in:
parent
b192a2a76f
commit
25e001e855
3 changed files with 13 additions and 1 deletions
|
@ -11,3 +11,4 @@ def iterate_f(x, r, n_iterations):
|
|||
trajectory[i+1] = f(x, r)
|
||||
x = trajectory[i+1]
|
||||
return trajectory
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ def fit_r(xs):
|
|||
it = len(xs) - 1
|
||||
|
||||
def error(r):
|
||||
return np.linalg.norm(xs - iterate_f(it, x0, r))
|
||||
return np.linalg.norm(xs - iterate_f(x0, r, it))
|
||||
|
||||
errors = []
|
||||
for r in np.linspace(0, 4, 4001):
|
||||
|
|
11
testing_project/test_logistic_fit.py
Normal file
11
testing_project/test_logistic_fit.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from numpy.testing import assert_allclose
|
||||
|
||||
from logistic import iterate_f
|
||||
from logistic_fit import fit_r
|
||||
|
||||
def test_fit_r():
|
||||
r = 3.421
|
||||
trajectory = iterate_f(0.3, r, 23)
|
||||
fit_result_r = fit_r(trajectory)
|
||||
assert_allclose(r, fit_result_r)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue