# import modules
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
# nice plotting
import seaborn as sns
import pboc_utils as pboc
define our parameters
# parameters
r = 0.5 # min^-1
gamma = 0.1 # min^-1
# array parameters
M = 20 # maximum number of mRNAs we keep track of
n_steps = 500
# array to store mRNA probabilities
mRNA = np.zeros([M, n_steps])
mRNA[0,0] = 1
# time step
dt = 0.1 # min
# loop through time
for t in range(1, n_steps):
# loop through mRNAS of 1 to M-1
for m in range(1, M-1):
mRNA[m,t] = mRNA[m,t-1] + r*dt*mRNA[m-1,t-1] + gamma*(m+1)*dt*mRNA[m+1,t-1] - \
r*dt*mRNA[m,t-1] - gamma*m*dt*mRNA[m,t-1]
# special case for 0 mRNAS
mRNA[0,t] = mRNA[0,t-1] + gamma*dt*mRNA[1,t-1] - r*dt*mRNA[0,t-1]
# special case for maximum number of mRNAS, M
mRNA[-1,t] = mRNA[-1,t-1] + r*dt*mRNA[-2,t-1] - gamma*(M-1)*dt*mRNA[-1,t-1]
# plot the results
pboc.bar_plot(mRNA, n_slices=6, dy=dt, x_label="mRNA count", y_label="time (mins)" )
mRNA[-1,-1]
Let's see if this distribution is Poisson
plt.plot(mRNA[:,-1],'.')
plt.xlabel("mRNA count")
plt.ylabel("frequency")
# plot poisson distrubtion to compare
n_mRNAs = np.arange(M)
lam = r/gamma
poisson_dist = stats.poisson.pmf(n_mRNAs,lam)
plt.plot(poisson_dist,'.')
plt.legend(["simulation","poisson"])