An animal can be in one of two states A or B. An individual in state A will change to state B at an exponential rate α; an individual in stat B divides into two new individuals of type A at an exponential rate β.
Let α =1, β=2. At time 0, there is one cell, and it is type A. Estimate the expected number of cells of each type at time 5 and time 10.
use python/matlab is fine.
from scipy.stats import expon
import random
t=0
a0=1
b0=0
a1=1
b1=0
while t<5:
a0=a1
b0=b1
if b0==0:
s=expon.rvs(scale=1,size=1)
t=s+t
b1=1
a1=a0-1
elif a0==0:
s=expon.rvs(scale=2,size=1)
t=s+t
b1=b0-1
a1=2
else:
s=expon.rvs(scale=1/3,size=1)
t=s+t
u=random.uniform(0,1)
if u<(1/3):
b1=b0+1
a1=a0-1
else:
b1=b0-1
a1=a0+2
print(a0)
print(b0)
while t<10:
a0=a1
b0=b1
if b0==0:
s=expon.rvs(scale=1,size=1)
t=s+t
b1=1
a1=a0-1
elif a0==0:
s=expon.rvs(scale=2,size=1)
t=s+t
b1=b0-1
a1=2
else:
s=expon.rvs(scale=1/3,size=1)
t=s+t
u=random.uniform(0,1)
if u<(1/3):
b1=b0+1
a1=a0-1
else:
b1=b0-1
a1=a0+2
print(a0)
print(b0)
Output looks something like this
2 1 0 6
Thus at t=5, Number of type A animals = 2, Number of type B animals =1
at t=10, Number of type A animals =0, Number of type B animals =6
Get Answers For Free
Most questions answered within 1 hours.