Add iterating function and the test for it
This commit is contained in:
parent
4736cc7ac9
commit
b192a2a76f
2 changed files with 32 additions and 11 deletions
|
@ -1,4 +1,13 @@
|
|||
# Your code goes here
|
||||
import numpy as np
|
||||
|
||||
def f(x, r):
|
||||
return r * x * (1 - x)
|
||||
|
||||
def iterate_f(x, r, n_iterations):
|
||||
trajectory = np.zeros(n_iterations+1)
|
||||
trajectory[0] = x
|
||||
for i in range(n_iterations):
|
||||
trajectory[i+1] = f(x, r)
|
||||
x = trajectory[i+1]
|
||||
return trajectory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue