Académique Documents
Professionnel Documents
Culture Documents
http://localhost:8888/nbconvert/html/Untitled.ipynb?download=false 1/3
12/6/2016 Untitled
prey_values = [prey_pop]
pred_values = [pred_pop]
for i in range (num_steps):
#Here, I will do Euler's method for the current time.
step = eulers(coefficients, prey_pop, pred_pop, time_step)
#Then, I will take the output, and add the relevant
#populations to each population's list.
prey_pop = step[0]
pred_pop = step[1]
#Next, I will adjust any negative outcomes to 0,
#since the population must be a positive number.
if pred_pop < 0 :
pred_pop = 0
if prey_pop < 0 :
prey_pop = 0
#Then, I will add this current value to the list containing
#values from every step. These will be used to create the graph.
prey_values.append(prey_pop)
pred_values.append(pred_pop)
print 'The final prey population is', str(int(round(prey_values[num_step
s])))
print num_steps, pred_values, prey_values
print 'The final predator population is', str(int(round(pred_values[num_
steps])))
http://localhost:8888/nbconvert/html/Untitled.ipynb?download=false 2/3
12/6/2016 Untitled
http://localhost:8888/nbconvert/html/Untitled.ipynb?download=false 3/3