Does someone know how to do part c and d using the code I have provided? I would
ID: 3863925 • Letter: D
Question
Does someone know how to do part c and d using the code I have provided? I would really appreciate it!
#beta start
betastart=1/37.0
#beta stop
betastop=1/6.0
#beta for synthesis
betasynth = 5*betastop
gamma=np.log(2)/50
tmax=200
def step(n):
r_gene = betastop+ betastart
xi_gene = betastart/r_gene
if (np.random.rand()<xi_gene):
state=1 #on
else:
state=0 #off
#mrNA synthesis
r=betasynth+gamma*n # rate that "something" will happen
dt=-np.log(np.random.rand())/r # time increment
xi=betasynth/r
if (np.random.rand()<xi):
dn=1 * state #birth
else:
dn=-1 #death
return dn,dt
#average mRNA molecules
def average(storedata):
means = np.zeros(tmax)
for time in range(tmax):
n = 0
for i in range(2000):
for pair in storedata[i]:
# check number of mRNA for each time instance
if pair[0] >= time:
n = n + pair[1]
break
means[time] = n
return means
storedata = []
for i in range (2000):
nc=0 #molecules
tc=0 #time
pairs = []
while (tc<tmax):
dn,dt=step(nc)
tc+=dt
nc+=dn
pairs.append([tc,nc]) #stores ti,ni
storedata.append(pairs)
means = average(storedata)
t=np.linspace(0, tmax, num=tmax)
plt.plot(t,means)
plt.show()
#numpy.var()
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
**
Tests if a tree meets the conditions to be a
binary search tree (BST). Uses the efficient
recursive helper.
*/
public boolean isBST2() {
return( isBST2(root, Integer.MIN_VALUE, Integer.MAX_VALUE) );
}
/**
Efficient BST helper -- Given a node, and min and max values,
recurs down the tree to verify that it is a BST, and that all
its nodes are within the min..max range. Works in O(n) time --
visits each node only once.
*/
private boolean isBST2(Node node, int min, int max) {
if (node==null) {
return(true);
}
else {
// left should be in range min...node.data
boolean leftOk = isBST2(node.left, min, node.data);
// if the left is not ok, bail out
if (!leftOk) return(false);
// right should be in range node.data+1..max
boolean rightOk = isBST2(node.right, node.data+1, max);
return(rightOk);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.