diff --git a/logistic.py b/logistic.py index e49d1c2..da2f799 100644 --- a/logistic.py +++ b/logistic.py @@ -1 +1,8 @@ # Your code goes here +def f(x,r): + return r * x * (1-x) + +def iterate_f(x,r,it): + result = [] + for _ in range(it): + result.append(f(result[-1],r)) \ No newline at end of file diff --git a/test_logistic.py b/test_logistic.py index 9391bee..f64831f 100644 --- a/test_logistic.py +++ b/test_logistic.py @@ -1,5 +1,5 @@ from numpy.testing import assert_allclose - +import pytest from logistic import f # Add here your test for the logistic map @@ -14,3 +14,14 @@ def test_f_corner_cases(): for x, r, expected in cases: result = f(x, r) assert_allclose(result, expected) + + + +@pytest.mark.parametrize('x, r, expected', [ + (0.1,2.2,0.198), + (0.2,3.4,0.544), + (0.5,2,0.5) + ]) +def test_f_generic_values(x,r,expected): + result = f(x, r) + assert_allclose(result, expected) \ No newline at end of file