Question: This exercise is designed to develop a stochastic modeling approach to population dynamics. Unlike our earlier population models, which were deterministic in nature, this approach

This exercise is designed to develop a stochastic modeling approach to population dynamics. Unlike our earlier population models, which were deterministic in nature, this approach treats population events like births and deaths as stochastic events. Whether an individual in the population gives birth to another organism or dies in some given time period is based on the probabilities of these events. Therefore at the level of the individual, birth and death events have an associated randomness and unpredictability. However as you will see, this does not preclude the existence of a certain degree of predictability, particularly for large groups of organisms.
For this exercise, you will be developing a computer program that carries out the specific example in Exercise 20-4 on page 311 of the Keen & Spain text. Initially, use a slightly greater value for the birth coefficient than the death coefficient (b =0.30, d =0.275). You should start with a population size of 10 and run the model for 150 generations. When you get the program working, run it 10 different times and plot your results (population size versus generation). You should also draw a graph (or use the same graph) of the average population size (average the results of all 10 runs for each time step). The model is stochastic and so you should get different results (sometimes very different) for each run.
Next, make another set of 10 runs, but reverse the values for the birth and death rate coefficients (b =0.275 and d =0.30). Produce a similar graph as described in the previous paragraph.
The text for Exercise 20-4 indicates that a plot of log population size versus time should be linear and you may plot your data this way if you choose, but a simple plot of population size versus time is entirely acceptable.
For the Conclusions section of your report, think about how your results compare to the behavior demonstrated by some of our earlier deterministic population models. Also, think about the behavior of an individual population run as compared to the average of many runs. Are the results sensitive to small differences in those rate coefficients?
help me add a loop so i can get all 10 runs in oneimport random
import matplotlib.pyplot as plt
# birth and death rates
b =0.30
d =0.275
# pop size
pop_size =10
# number of generations
num_generations =150
pop_sizes =[]
avg_pop_sizes =[]
p_birth = b *(1-d)
p_death = d *(1-b)
# generate randomness
for i in range(num_generations):
for org in range (pop_size):
if random.uniform(0,1)< p_birth:
pop_size +=1
if p_birth < random.uniform(0,1)<(p_death + p_birth ):
pop_size -=1
pop_sizes.append(pop_size)
avg_pop_size = sum(pop_sizes)/ len(pop_sizes)
avg_pop_sizes.append(avg_pop_size)
# Plot pop sizes and avg pop sizes
plt.plot(pop_sizes)
plt.plot(avg_pop_sizes)
plt.xlabel('Generation')
plt.ylabel('Population')
plt.legend(['Pop Size', 'Average Pop Size'])
plt.show()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!