Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello could you help me answer this question in python? This question continues

ID: 3861816 • Letter: H

Question

Hello could you help me answer this question in python? This question continues from a previous assignment. I have the code it is asking about here:

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import poisson

beta=0.15
gamma=0.015
tmax=2000

def step(n):
   r=beta+gamma*n
dt=-np.log(np.random.rand())/r # time increment
   xi=beta/r
if (np.random.rand()<xi):
dn=1 #birth
else:
dn=-1 #death
return dn,dt

# three realizations
for i in range (0,3):  
n=[0]
t=[0]
nc=0
tc=0
while (tc<tmax):
dn,dt=step(nc)
tc+=dt
nc+=dn
n.append(nc)
t.append(tc)
plt.plot(t,n)
plt.xlabel(r'time')
plt.ylabel(r'number of cells')
plt.axis([0, 2000, 0, 20])

# analytical mean solution
def f(t):
return (1-np.exp(-t*gamma))*beta/gamma
t=np.linspace(0,2000,100)
plt.plot(t,f(t))
plt.show()
plt.clf()

#histogram of final values
nf=[]
for i in range (0,500):  
nc=0
tc=0
while (tc<tmax):
dn,dt=step(nc)
tc+=dt
nc+=dn
nf.append(nc)

hist, bin_edges = np.histogram(nf,density=True)
bin_centres = (bin_edges[:-1] + bin_edges[1:])/2   
plt.plot(bin_centres, hist, '.-',markersize=15)
n=np.linspace(1,20,20)
plt.plot(n,poisson.pmf(n,beta/gamma))
plt.axis([0, 20, 0, 0.15])
plt.show()

As an application of the birth-death process studied in a previous assignment, consider the synthesis of mRNA with rate Bs, and its clearance from the cell with rate ne. This picture, however, is too simple: the gene that controls the mRNA production makes spontaneous transitions between active ("on") and inactive ("off") states at mean rates Bstart and Bstop Only the active state can be transcribcd, lcading to bursts of m production intersperscd with quiet periods. In effcct this means that whenever the gone is in the "off" state, tho synthesis ratc Bs must be set to zero. The situation is visualized below stg t tivc Nene clear Synthesis O (a) Modify your computer program to implement the transcriptional bursting proccss. Ini- tially the genc is "off" and there are no mRNA molecules in the system. Set ne ln(2)/ (50 min) Bstart 1 37 min Bstop 1/(6 min), BS 3 5Bstop (b) Run the simulation 2000 times for 200 min. Instead of plotting all 2000 trajectories, plot the average number of mRNA moleculcs (m) over all 2000 runs as a function of time. (Hint Storc thc data for cach run in pairs of (ti, ni), where i is a step index. For cvery run, and for every valuc of t bctween 0 and 200 min, find the value of i for which ti t for the first time. The valuc of n corresponding to time t is then ni (c) Tabulate the number of trials in which, for a given timet, the number of mRNA molecules is still zero. Convert this result into a graph of the probability of observing zero mRNA molecules at time t. hat would you have expected for a simple birth-death process (without bursts), and how does the result differ? (d) Compute the ratio "Variance (ngnal)/Mean(nfinal)" for all final valus of n. What do you expect for a simplc Poisson process?

Explanation / Answer

import random import matplotlib.pyplot as plt from math import log, e, ceil, floor,sqrt,pi,exp import numpy as np from numpy import arange,array, empty import pdb from random import randint import copy from operator import add import scipy from scipy.optimize import curve_fit import numpy as np import matplotlib.pyplot as plt import math import scipy def walk(n): time = 0 i = 0 while i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote