Logistic map tests #10

Open
eceku wants to merge 5 commits from eceku/2025-plovdiv-testing-debugging:test-2 into main
3 changed files with 13 additions and 1 deletions
Showing only changes of commit 25e001e855 - Show all commits

View file

@ -11,3 +11,4 @@ def iterate_f(x, r, n_iterations):
trajectory[i+1] = f(x, r) trajectory[i+1] = f(x, r)
x = trajectory[i+1] x = trajectory[i+1]
return trajectory return trajectory

View file

@ -24,7 +24,7 @@ def fit_r(xs):
it = len(xs) - 1 it = len(xs) - 1
def error(r): def error(r):
return np.linalg.norm(xs - iterate_f(it, x0, r)) return np.linalg.norm(xs - iterate_f(x0, r, it))
errors = [] errors = []
for r in np.linspace(0, 4, 4001): for r in np.linspace(0, 4, 4001):

View 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)