Matlab weeks 1-5

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

2<3 in Matlab will product? 4>6? symbol for greater than, greater than or equal to, less than, less than or equal to, equal and not equal in Matlab?

1 0 >, >=, <, <=, ==, ~=

for a=0:10 disp('Hello world') end how many times hello world is displaced and why? what happens when we type in the code a=-1:1:-10 disp('hello world') end ?

11 times in beginning, Matlab get a=0 which will display hello world then end then loop back to a=1 which will display than end. until 10 for which it stops. nothing because, increments of 1 means it will go -1 0 1 2 3 4.. and will Never reach -10. so Matlab shows nothing.

Create a matrix of random numbers with the same size as an existing array.

A = [3 2; -2 1]; sz = size(A); X = rand(sz)

what is the point of these following codes/under how it is run. p=0.1; for i=1:30 p_geom(i)=(1-p)^(i-1)*p; end bar(1:30,p_geom,'b') hold on plot(1:30,p_geom,'r','LineWidth',3) set(gca, 'FontSize', 16) xlabel('Time to first success') ylabel('Probability') box off

Computation of the geometric probability distribution based on its formula:

what happens when you multiple rand with k? and c to that multiple? how do we get a random integer between 3 and 7 inclusive? explain the code how about a random integer between 3 and 7 excluding 5?

[0,k] rand between [c,c+k] rand between floor(5*rand+3) this will create a 3 to 8 interval for which if a number is between 3 and 4, will round down to 3...etc r=4*rand+3 if r<5 r=floor(r); %this will round down else r=ceil(r); %this will round up end

Create a if statement that when g is less than 20, you will display hello and 5, what happens when we input 30 into here?

g=10; if g<20 disp('hello') g=5 end 30>20, so statement is false, Matlab jumps directly to end, g is still 30.

write the code that showcases the use of poissrnd, mu=0.6 number trial is 87 plot

mu=0.6; number_trials=87; random_vector_poiss=poissrnd(0.6,number_trials,1); histogram(random_vector_poiss,0:1:10,'Normalization','probability') xlabel('Values taken by the stochastic variable') ylabel('Probability') box off

complete this script for complex numbers c = [3+4_, 4+3_; -_, 10_] (all are complex)

I or j for all

write the general format of how to use binomial distribution. plot it

binomial_prob_vector=zeros(total_number_steps+1,1); for i=0:(total_number_steps) binomial_coefficient=((factorial(total_number_steps))/(factorial(total_number_steps-i)*factorial(i))); binomial_prob_vector(i+1)=binomial_coefficient*(1/2^total_number_steps); end disp('Sum of probabilities of all possible outcomes (must be equal to 1)') sum(binomial_prob_vector) % verifies the normalization figure plot(0:1:total_number_steps,binomial_prob_vector,'ro'), box off %%% plot results of simulation and results of theoretical distribution clf bin_edges=0:1:total_number_steps; counter_empirical=hist(particle_step_counter(end,:),bin_edges); counter_empirical=counter_empirical/(sum(counter_empirical)); bar(0:1:total_number_steps,counter_empirical) hold on plot(0:1:total_number_steps,binomial_prob_vector,'or'), box off xlabel('Number of steps up') ylabel('Probability') legend('Simulated statistics','Binomial distribution')

create a histogram of 10000 random numbers stimulate a coin flip

r=rand(10000,1) hist(r) r=rand; if r>0.5 disp('H') else disp('T') end

given the code for random numbers between 1 and 20 (write this!) find the sum, min, max, mean, var, std

random_vector=rand(1,20) sum(random_vector) min(random_vector) max(random_vector) mean(random_vector) var(random_vector) std(random_vector)

How does Matlab recognize ; : (interpret C(:,3) linspace

tells us to move to the next row all (_); 1st argument is all rows, 3rd column specify where a vector start, end and how many numbers should be. chooses increments.

how do we know that HIV has a dynamic model? explain the filter paper analogy and how we can deduce that its in steady state(what is steady state?) what does the filter paper analogy NOT tell us? how can we solve what the filter paper not tell us? given a graph of viral concentration over time after administering drug, how would you characterize temporal change in viral load? if viral load goes from 16 RNA copies/ml to 8 RNA copes/ml, how much RNA molecules lost in 24 hours ( a human contain 5L of blood)

After infection; flu symptoms for 4-8 weeks Suddenly go down for 12 years After 12 years, immune system break down for 2-3 years One of the drugs use was ritonavir (protease inhibitor); by preventing dissociation macrocomplex into invidious life protein, you can block virus from spreading so you would too have infected T celll spreading The effect of drug is massive drop of total number of virus without clearance of virus; this is inconsistent with the slow virus hypothesis -> something must be dynamic -------- water flow in = virus coming into blood water in the filter (current virus level in blood) outflow is degregation of virus over time Now this is dynamic -> some liquid poured in, some liquid poured out, you are interested in tracking amount of liquid din filter paper You have influx, outflux of virus; you are going to have concentration of virus that is found in blood that is constant up to 20 years steady state implies inflow=outflow ----- What this is not telling us yet is if inflow and outflow are large or small If low inflow/outflow...the virus would just stay into our body If high inflow/outflow...high turnover of virus-> would need high replication rate Need experiment to test which one When David ho used his drug, he stopped the inflow, suddenly, virus cannot have increase (so you block liquid INTO filter); the liquid will go down (virus amount will go down because not compensated by inflow if slow inflow drain slowly, if fast inflow, drain fast ------- very fast since this is a log graph-> clearance rate of virus must be large during latent phase ----- 4x10^8

What are the main properties associated with the 1D motion of an ensemble of Brownian "particles" (in other words an ensemble of random walks in 1D)? Can you say anything about the average displacement from the initial position and standard deviation of the displacement? How does a population of bacteria grow in conditions where nutrients are not rate- limiting? How can you describe this growth mathematically? Why are ODEs important in describing biological systems? What is the difference between analytical and numerical approaches to solving ODEs? Can any ODE be "easily" solved analytically? How does Kv and y and dNv/dt= y-kv.Nv(t) affect the solution of ODE? why are log linear pilots useful to compute the exponents of exp. function? can you cure HIV? what is a random walk? What is an independent variable? A dependent variable? What does "stochastic" and "probabilistic" mean as opposed to "deterministic"?

Average position doesn't change, cannot predict exact prediction ; position always stays at zeros We can see that brownian particles has binomial distraction and thus can use the standard deviation for bionaml -- Exponentially Dn/dt=(+ or -) constant * current population -- As time progress how things ar echanign, letting us model tings, apply formula to summarize a whole set of changes and movement Solution to ODE is a function -- anaylrically is doing the calculus actually Numerical is more of an approximation some can -- for second part, solve for the analytically equation to get Co * e^-kv + y/k, larger kv means degrade faster and lower threshold, larger y means higher threshold -- Going in log scale convert exp to straight line to get slope -- You can treat and maintain and its manageable but even one virus will restart it again -- On a path, forward or backward is equally likely -- variable whose variation does not depend on the other variable whose variation depends on the other -- randomness in occurred events vs known causes of the events

Probabilty has two variable which are? for probability, use a limit to explain it The probability always adds up to _ and is always between? flip coin 10 tines, prob all heads? When two probabilistic processes A and B are independent, what is the probability of observing each process p(A and B)? flip coin 10 times, prob 6 are H? When two probabilistic processes C and D are mutually exclusive, what is the probability of observing any of these two processes p(C or D)? what is the combination equation? What is the probability of observing k tails in n coin flips? How can this be calculated based on the binomial distribution? write the code for flip a coin 10 times, probability of 6 H's? explain the code (what is this method called?)

N=# trails n=# times event occurs -- P=lim N-> inf n/N -- 1 0=<n=<N -- 1/2 for each coin flip, flip of coin does not affect other clips so this is an independent event (1/2)^10 -- mutually exclusive event, there is x specific way you can orientate this such as HHHHHHTTTT or TTTTHHHHHH. (if you have HHHHHHTTTT there is not way you can simuteanous have TTTTHHHHHH) you will add (1/2)^10 + 1/2^10 to solve this, for each case find the independent probability then add each independent provability together p=(10 C 6) (1/2)^10 -- N!/k!*(N-K)! where N is the spots and k is what we want to place -- we know P=lim N-> inf n/N; we make N large and finite and then we are going to keep track of how many times we get that specific condition -- numtrials=100000; % large N numsix=0; %counter for n that has condition for I=1:numtrails r=rand(10,1) %creates 10 random # if sum(r>0.5)==6 numsix=numsix+1; end end prob=numsix/numtrials -- numtrials=100000; % large N -- numsix=0; %counter for n that has condition -- for I=1:numtrails r=rand(10,1) %creates 10 random # -- if sum(r>0.5)==6 numsix=numsix+1; % if condition is actually met, it will always produce 6 and if that happens add to counter end end prob=numsix/numtrials

when flipping a coin, we expect that the probability of observing heads as the outcome is 1/2. where does this expectation come from? give the sample space for the 2 consecutive independent coin flips independence of random events P(A&B)=? provability of heads and heads? what is the normalization condition? what's the probability of obtaining 1 heads and 1 tails as the outcome of two consecutive coin flips? what are the iconic physical system that are intrinsically random? what is Brownian motion? where does the ranomdness come from? can anything be predicted about this process? how can brownian motion be related to our first codin assignment? Can the exact position of a Brownian particle moving in 1D be predicted at any given time? Can the average position of an ensemble of Brownian particles be predicted at any given time?

P(head)= lim Ntot-> infinity N heads/Ntotal =0.5 -- head; head, head; tails, tails; heads, tail; tail list of all possible distinct outcomes -- P(A) * P(B) 1/2 * 1/2 -- Σk P(k)=1 = P(H H)+ P(H T) + P(T H) + P(T T) =1/4+1/4+1/4+1/4=1 -- can have H T or T H, so 1/4+ 1/4=1/2 -- coin flipping, Sequence of waiting time between blips of light emitted by dim light source, Observation of a pollen seed (micrometer- size particle) undergoing free motion in water -- random motion of particles suspended in fluid -- Motion of pollen seeds results from the impact of millions of water molecules. The direction and magnitude of the net (resultant) force on pollen seed vary constantly over time. -- Although this process is fundamentally random, we know that the motion is constrained: the seed won't make a 1m jump in 1s! -- related to random walks as the process is fundamentally random -- no -- yes; on average, the particles go nowhere

assign a to 1 b to 2 c to 3 from that, add a and b and assign it to a variable c. to a cosine function on a and assign it to variable. multiple a with b and assign it to variable e. given a=2 b=2, c=a+b; if a change to equal 10, what will happen to c? A=Randi(10,3,5) C=5 what is A<C?

a=1 b=1 c=1 c=a+b d=cos(a) e=a*b no changes after assignment, C is indpendent of value of a nd b row or column (1d) vector is a matrix tho contain rows or columns (2D) = is the assignment operator, == is the relational operator

i=0; while i<6 i=i+1; j=i*2 k=i+j; disp(k+i) what does this show?

loop until test condition is no longer true

create a if statement where you can assign a value to a variable depending on the size of a random number: 'low', 'medium', or 'high'. In this case, the random number is an integer between 1 and 100.

num = randi(100) if num < 34 sz = 'low' elseif num < 67 sz = 'medium' else sz = 'high' end

Consider the following initial condition and parameter values: Nv(0)=0 production rate is 10^9 (RNA molecules/day) degradation rate is 0.5 number of intergragation steps is 100 over 24 hours write the ODE script for this explain the script what is an alternative way to write this for loop? after all this, how can we compute the analytical solution to this? (given the equation Nv(t)= yv/kv(1-e^-(kv)t) plot both solutions.

initial_time=0; final_time=24; production_rate=1e9; degradation_rate=0.5; N_0=0; number_integration_steps=100; step_size=final_time/number_integration_steps N_num=zeros(number_integration_steps,1); N_num(1)=N_0; Time_num=zeros(number_integration_steps,1); for i=2:number_integration_steps inst_change_rate=production_rate-degradation_rate*N_num(i-1); N_num(i)=N_num(i-1)+inst_change_rate*step_size; Time_num(i)=Time_num(i-1)+step_size; end -- clear % Ensure you don't access previously used % variables and vectors in this script %%% % Definition of parameters of the model %%% -- initial_time=0; % in day final_time=24; % in day production_rate=1e9; % RNA molecules/day degradation_rate=0.5; % 1/day N_0=0; % initial number of viruses -- number_integration_steps=100; % try different numbers: 10 to 1000 step_size=final_time/number_integration_steps %%% -- % Initialization of the variable %%% -- N_num=zeros(number_integration_steps,1); % vector with time course of number of virus N_num(1)=N_0; Time_num=zeros(number_integration_steps,1); -- %%% % For loop with i defined based on i-1 %%% for i=2:number_integration_steps inst_change_rate=production_rate-degradation_rate*N_num(i-1); N_num(i)=N_num(i-1)+inst_change_rate*step_size; Time_num(i)=Time_num(i-1)+step_size; end -- for i=1:(number_integration_steps-1) inst_change_rate=production_rate-degradation_rate*N_num(i); N_num(i+1)=N_num(i)+inst_change_rate*step_size; Time_num(i+1)=Time_num(i)+step_size; end -- % Computes the analytical solution N_exact=production_rate/degradation_rate*(1-exp(-degradation_rate*Time_num(:))); -- plot(Time_num(:),N_num(:),'-.b') hold on plot(Time_num(:),N_exact(:),'m') ylim([0 2.5e9]) legend('Numerical simulations','Analytical solution')

definition of derivative; integral (what does it correspond to geometrically?) give a curved distance over time graph, draw the derivates of them on the distance graph. write out the equation of the derivate. now draw out the speed over time graph and mark the places where the derivates WERE on the previous graph Now using the speed over time graph, how can we find how much he traveled? draw this out. how does this corrposnd to the distance over time graph? what is the difference between delta T and dt? why does this difference matter? Explain the origin for the definition of the derivate.

"slope of tangent to the curve'; area under the curve (in terms of the derivate graph or a point on the distance graph) -- v(t)=de/dt(slope of the tangent at a given point -- Dt is a really small delta T -- given v=de/dt, multiple the dt to the v side to get de=v(dt) or the change in distance is equal to the velocity times the change in time. These are points on the distance over time graph. -- ???? -- given f(x) with a tangent line draw at one point, we want to find the formula for the slope of the tangent line. we are going to take the point at which the tangent line touches graph (x) and then we are going to take another point on the graph (x+h). we are going to find the slope of the line that connects x and x+h (the secant line). Notice though that we are interested in the tangent line, therefore, we must have points x+h than get closer and closer to matching the tangent line slope. in essence, the secant lines start matching the tangent lines. therefore, the slope of the tangent equal to the limit of the slope of the secant lines. so lets draw f(x) again. on the tangent line, we have a point x. on the secant line, we have the point x+h. therefore now we have two points (x,f(x)) and (x+h, f(x+h)) so the slope the secant line is (f(x+h)-f(x))/h. we said that we want the secant line to get closer to the tangent line, so that would entail our h value getting smaller and smaller and essential approach the value zero. therefore now we have df/dx=lim(x->0) f(x+h)-f(x)/h so IN SUMMARY: all we are recognizing is that we are taking limit of slopes of secant line so it can get closer and closer to the tangent line which is the derivate.

For logical operators and has the symbol_. or _. not _. create truth tables for the logical operators. evaluate these statement for true or false. (2<3)&(4>6) (2<3)|(4>6) ~(4>6)

&, |, ~ if both T, True. If one is false, false. if both false false. If both true, or one true, true. if both false, false. for what is true, it is false for what is false, it is true. false true false

How does MATLAB view order of operations? write a user defined function and explain it write a function that will take two numbers as inputs and double the smallest of the two (how do we find help on the function?)

1) () 2) raise power 3) * and / 4) + and - ie 1/3^x+4 -- function f=triple (x) f=3*x end >> triple (5) % Matlab will find the triple function and execute% 15 -- function f=double_smallest(x,y) if x<y f=2*x; else f=2*y; end end help double_smallest

What are the main cellular functions? how are these function implemented bio? what is feedback regulation? describe the notation for regulation interaction. what is the sign of x on its own activity (x -| x)? (-| x -> y -) (-| x -| y-) what is the rule for the sign of a given feedback loop? what is the boolean caricature for the state variable? how does boolean relate to ODE what are the rules of simulating the system behavior using boolean? say you have a table of x(t) 0 and 1, what is the x(t+1) side of the table? what kind of inhibition is this? what is the state sequence (ie x(1), x(2), x(3), etc..) what is the function of the above mentioned? given a (-| x -| y-), set up the boolean formalism, update reels and state transition and state sequences? draw the phase portraits for the above what is an attractor? define attractors for the problem above. given (-| x -| y -| z -) How many different states can this system take? what is the boolean formalism state transition? state sequence what is the phase portrait? what is the function?

1. Decision-making (switch-like behavior) 2. Homeostasis (maintenance of desired state) 3. Oscillations (creating internal clocks) Feedback occurs when the output of a system is routed back as input as part of a chain of cause-and- effect that forms a circuit or a loop Feedback regulation is a control mechanism that uses the consequences of a process to regulate the rate at which the very same process occurs A->B is activation (element A activates element B) A -| B is inhibition (concentration of A represses the expression of gene B) negative negative postive A feedback loop is "positive" when the number of negative interactions is even A feedback loop is "negative" when the number of negative [!] interactions is odd -- if a is absent (think about it as something that will bind to a receptor), then no expression of x. That we will define as x=0; if a is present, then there will be expression of x. That we will define as x=1. -- ...? -- dynamics of the system is taken as a discrete time series where the state of the entire network at time t + 1 is determined by evaluating each variable's update rule (function) on the state of the network at time t. x is the state variable. Boolean formalism is x=0 or 1. time is discretized (t=0,1,2..) update rule x(t+1)= not (x1) -- not 0 so 1 not 1 so 0 negative self inhibition 0 ->1 -> 0 -> 1 -- homostasis -- x and y are state variables x(t)y(t)={00 10 01 11} x(t+1)=not (y(t)) y(t+1)=not(x(t)) t side (00 11 01 10) t+1 side (11 00 01 10) 00 -> 11 -> 00 -> 11 [01] and [10] memory function -- see lecture -- Attractor: state toward which a system tends to evolve: • steady state • cycle see lecture -- 8 use formula 2^N where N is the number of elements xyz=000,001,...) x is not z y is not x z is not y -- 000 111 001 011 010 110 011 010 100 101 101 001 110 100 111 000 -- 000 -> 111 -> 000 -> 111 -> 001 -> 011 -> 010 -> 110 -> 100 -> 101 -> -- see lecture. -- osccialtion

counter=0; for I=0:1:10 counter=counter+(I<5); end counter final value of counter? counter=0; for I=2:2:20 if counter==i disp('counter and I have the same value') end counter=counter+1; end counter value of counter? counter=4; for I=1:4 if counter>=i disp('counter is larger than i') counter=counter-1; end end counter value of counter? will these give the same value? counter_1=zeros(10,1); for i=1:9 counter_1(i+1)=counter_1(i)+1; end counter_1(10) counter_2=zeros(10,1); for i=2:10 counter_2(i)=counter_2(i-1)+1; end counter_2(10)

5 10 3 yes

make matrix of 3 columns and 4 rows. measure the size of that matrix. alter the 1 row third column position of the matrix with number 9. out of the matrix, find the 3rd row, 2nd column position. out of the matrix, find the 1 column entirely. out of the matrix, find the 1 row entirely what is an index? given vec=[0:2:10] what does vec(1:3) show? vec([2,5]) show? vec(end)? vec(end-2)? vec([2,5:end]) how many arguments are in vec([2,5:end])? out of a matrix, find the 2nd thru 4th rows combine with the 3rd column out of a matrix, find the 2 row and the 2nd column to the last column what does length() do?

>> C=[1 0 6; 1 3 4; 5 6 2; 3 7 4] C = 1 0 6 1 3 4 5 6 2 3 7 4 -- >> size(C) ans = 4 3 -- >> C(3,2) ans = 6 -- >> C(1,3)=9 C = 1 0 9 1 3 4 5 6 2 3 7 4 -- >> C(:,3) ans = 9 4 2 4 -- >> C(1,:) ans = 1 0 9 --- position of one or more elements in an array -- [0 2 4] [2 8] [10] [6] [2 8 10] -- one argument with multiple elements -- m(2:4,3) m(2,2:end) -- returns number of elements in vector or in the largest dimension of matrix

Create a vector with numbers 1 through 8 with step of 1. DO NOT WRITE OUT NUMBERS OUT (ie v=1 2 3 4..) create vector starting with 0 and ending at 3 with step of 0.5. create a vector starting with 0 and ending at 3 with exactly 7 elements. create a backward counting series.

>> H = 1:8 H = 1 2 3 4 5 6 7 8 -- >> t=0:0.5:3 t = 0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 -- >> t2=linspace(0,3,7) t2 = 0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 backward_series=2:-1:-2

assign variable S to 2. find a way to make T also equal 2 (do not to t=2). make vector with 1 row with numbers 1 2. show the three ways this can be done (documentation wise) make vector with 1 column with number 5 and 6. using the [x:y:z] format, how can we make a vector with 2 4 6 8

>> s=2 s = 2 -- >> t=s t = 2 -- >> A=[1 2] OR A=[1,2] A = 1 2 -- >> B=[4;3] B = 4 3

Imagine a random variable x1 that is uniformly distributed over -0.5 and 0.5. imagine that another random variable x2 is defined as x2(i)=-x1(i)/2. will the sum of x1 and x2 tend towards a Gaussian distribution? same question if x2(i)=-x1(I-1)/2. (PRACTICE PROBLEM) when tracking the progression of a motor through high res microscopy, what are steps and pauses? how would you characterize the behavior of this motor? what does the motion of the myosin motor have? why do we not describe the motion as speed? What is the origin of the variability in wait times? what is the stochastic dimension of the problem? what are the assumption when we model the motor? what is the Markov property? given an example? A friend rolls a six-sided die but doesn't show you the result, and then ask if you would like to place a bet that wins if the die landed with 5 facing up. Before you reply, another friend comes by and adds the information that the die is showing some odd number. calculate the probability. what is conditional probability? prove statistical independence. given a number line 1 to 10 where 1 to 2 and 2 to 3 represent delta T, what are two question we want to ask in order to model myosin walking? what will be the output of this random process? define the following. P(Ei) (the symbol?)? P(Ei+j)? P(Ei+j | Ei) = P(E I+j ∩ Ei)/P(Ei)? P(E I+j ∩ Ei)? P(E I+j ∩ Ei) can be expressed in terms of 𝜉 as? What's the probability distribution over t alpha? what is interesting about this? how does the geometric distrubtion look like? what is <j> in geometric series? (PROBLEM) A patient is waiting for a suitable matching kidney donor for a transplant. If the probability that a randomly selected donor is a suitable match is p=0.1: (i) What is the likelihood that more than 2 donors will be tested before a matching donor is found? (ii) What is the expected number of donors to be tested before a match is found? apply the motor walking to a continuous poisson process. what is the Probability density function (PDF) for a Poisson process with rate 𝛽. what are wait time distributed according to? apply the PDF to a dim light source blip what is the difference between a poisson distrubtion and a poisson process? For a Poisson process of parameter 𝛽, what is the probability of observing 𝑙 number of "blips" during the time interval 𝑇? what is the mean number of blips? what is 𝛽? Imagine two independent Poisson processes with a mean rate equal to 𝛽- and 𝛽., respectively. Question: What is the process resulting from the combination of both Poisson processes? why go through all this trouble?

? -- Steps of the motor appear as vertical jumps Pauses between steps appear as horizontal plateaux. staircase -like behavior -- a stochastic process with variable wait times -- The motion of the myosin motor has a stochastic component: the time interval between steps. Given that the motors move by sudden steps, it is irrelevant to describe their motion in terms of "speed" -- • Each step requires that the motor binds an ATP molecule. • ATP molecules are available, but they are outnumbered by other molecules. • The motor's ATP-binding domain is bombarded by molecular collisions at a high rate. • Almost all collisions are un-productive until an ATP molecule successfully binds to the domain (rare event). -- High rate of collisions on ATP-binding domain of the motor. The majority of these collisions are unsuccessful. -- A collision occurs at every ∆𝑡 time step. • Each collision has a tiny probability 𝜉 of being productive (setting the motor in motion). • Every collision is independent from other collisions. • After an un-productive collision, the motor stays in the same internal state. • After a productive collision, the motor moves one step, but its internal is directly reset. The motor has no memory of having taken one step (Markov property). -- given the present, the future state of a system does not depend on its past states Example we have already studied: Brownian motion 𝑥𝑖 =𝑥(𝑖−1)±𝛿 -- probability of observing a 5 is 1/6 probability of observing a 5 if all even are discarded is 1/3 P(E5 given that Eodd= P(E5 | Eodd) = P(E5∩Eodd)/P(Eodd) -- is a measure of the probability of an event (𝐸=) given the knowledge that another event (𝐸>??) has occurred -- E1,odd - obtain an odd number on first roll E2,5 - obtain a 5 on second roll these two are independent random events If P(E2,5 and E1,odd)= P(E2,5).P(E1,odd) P(E2,5 | E1,odd)= P(E2,5 ∩ E1,odd)/P(E1,odd)=P(E2,5).P(E1,odd)/P(E1,odd)= P(E2,5) this proves that P(E2,5) is independenct of the outcome of E1,odd -- What is the likelihood that a motor step occurs at this time point i (ie 3) What is the likelihood that j time points elapse before the next motor step takes place? (ie 9) t1 t2 t3.. tn (series of wait times) -- probability that a step happens at time 𝑖 𝜉 probability that a step happens at time 𝑖 + 𝑗 step after 𝑗 time steps given that step took place at time 𝑖 probability that a step happens at time 𝑖 and at time 𝑖 + 𝑗, but not between both steps: -- 𝜉.(1-𝜉)^j-1.𝜉 -- P(Ei+j | Ei) = P(E I+j ∩ Ei)/P(Ei)=(𝜉.(1-𝜉)^j-1.𝜉)/𝜉=𝜉.(1-𝜉)^j-1= p(geom) (j,𝜉) where j=1,2.. Interestingly, this quantity does not depend on 𝑖 ! -- see lecture -- 1/𝜉 or the. average number of Bernoulli trials needed to observe a success -- ? -- IN the example of the molcular motor Δt (time interval between collision is very small. And so will be the probability of success of each collision 𝜉. 1. A Poisson process is a random process for which the probability of a "blip" (an event) occurring in any small time interval ∆𝑡 is 𝜉 = 𝛽. ∆𝑡. (if you wait long ∆𝑡, the probability of a blip (step) is high. But you don't want to wait 1 hr because you have many steps. consider small delta t, delta t limit will cause 𝜉 to be really small. but 𝛽 is still fixed 2. The occurrence of a blip during the present ∆𝑡 is independent of what has happened at past ∆𝑡. 3. A continuous time limit is taken for ∆𝑡 → 0 while keeping 𝛽 fixed. -- take the limit as 𝜉 and ∆𝑡 ->0 (dont need to know math) P(tw; 𝛽)= 𝛽.e^-𝛽.tw where tw is the wait time variable Wait times are distributed according to a negative exponential distribution with parameter (or rate) 𝛽 porbabilt that after this wait time, you will take a step given this rate beta -- see lecture -- Each "draw" from a discrete Poisson distribution is an integer (whole number). example: number HIV viruses infecting a given T-cell Each "draw" from the exponential distribution is a real number. example: time interval between the production of 2 RNAtranscritps -- Ppoisson(l;𝛽.T)=1/l! . (𝛽.T)^l . e^-𝛽.T ( a poisson distrubtion!); u1=𝛽.T -- 𝛽 is called the mean rate of the Poisson process -- 𝛽1 + 𝛽2; The merged process is a Poisson process itself with a mean rate of 𝛽12 -- promoter has transcription factor activotr for which the production of a gene will follow Poisson process with rate 𝛽+ proportional to concentration of transcription factor A turnover will also follow Poisson process with rate 𝛽_ proportional to concentration of gene product B

Given a = [1 2 3; 4 5 6; 7 8 10], create a 3x6 matrix with just a. create a 6x3 matrix with just a.

A = [a,a] A = 3×6 1 2 3 1 2 3 4 5 6 4 5 6 7 8 10 7 8 10 A = [a; a] A = 6×3 1 2 3 4 5 6 7 8 10 1 2 3 4 5 6 7 8 10

What conclusion can be drawn from the coffee filter paper analogy about phase (*) of the viral infection? A: The virus is at steady steady. Nothing is happening for ~10 yrs. B: The virus is necessarily undergoing a very fast fast turnover. C: It is possible that the virus undergoes a fast turnover. But it is also possible it does not! D: When trying to solve a hard problem of biology, always pay a coffee to a friend physicist. Two filter paper systems are observed: their water levels remain constant over time, but both levels are different. A: This observation is impossible: if the water level is at steady state, the inflow must be equal to the outflow and therefore the two water levels must be identical. B: This observation would not be incompatible with the notion of steady state. C: This observation is uncertain: confusion in the observations could arise due to a parallax effect. 𝐶virus(𝑡) = 𝐶* 𝑒^(-kt).; Question: What is the value of 𝐶virus(𝑡 = 0)? A: 0 B:𝐶* 89 C: 𝐶* . 𝑒 D: Infinity E: I don't know How many free parameters does this model have? A: 0 B: 1 C: 2 D: 3 E: I don't know

C B B C

In these graphs, different patients show different levels of viral load. Is this compatible with the idea that the virus dynamics is at steady state? describe the schematic diagram of the infection process. what is the law of mass action ration and how does that apply to the infection rate of T cells? what is the degradation/production rate of virions? Give the ODE system underlying infection process. How many parameters are here? what are we looking for in the ODE model? upon addition of the antiviral drug, what happens to the ODE model? solve the dNt/dt analytically what are the dynamics of infected T cells and virions upon drug addition? Shortly after drug addition, can the population of infected T-cells (N") be considered at equilibrium? solve for the analytical solution of dNi/dt given a initial condition of Ni(t=0)=N(io). what does it mean? how can the result of the previous help clarify dNv/dt? what is the diffeq for the rate of variation of population of virions? rewrite to make the diffeq simpler Is the solution for Nv(t) compatible with the "plateau" or even the rise that follows drug administration? what is the difference between our first estimate of Kv and now? how can we finally estimate Kv? so in summary what is kv, Nv,o k1 and b/(kv-ki)? what is the general half life formula? derive it. what is a half life? half life for infected T cell (ki=0.52?) what about virus (kv=1.4?) how do you calc Probability of observing a particular mutation at a given site of the virus genome? what is the Number of T-cells carrying a particular mutation at any given time point during the latent phase? what is the consequence of this? consider the graphs of exp. decay function, a graph with a high k value will look _ compared to a graph with a low k value. How does the sum of two negative exponentials behave if the two exponential do not have the same decay constant (or exponent)? What is the long-term behavior of this function?

Different filter papers can produce different steady levels of coffee -- Target cell GOING OUT kt (clearance rate) k (going to infected cell) Target Cell GOING IN λ T cell constant production rate infected cell GOING OUT k1 (cell clearance) Ρ (release of virus upon cell burst) infected cell GOING IN k(coming from target cell) Virus GOING IN Ρ virus GOING OUT Kv (virus clearance also virus is going into the target cell... -- rate of any chemical reaction is proportional to the product of the masses of the reacting substances k*NvT*NtT -- k1*NiT; ρ*k1*NiT (production) -- dNt/dt= λ - kt*NtT-k*NvT*NtT dNi/dt=k*NvT*NtT-ki*NiT dNv/dt=ρ*ki*NiT-kv*NvT -- top row: λ, kt , k middle: k1 bottom: ρ, kv so 6 -- NiT because each infected T-cell has the potential of being different (mutagenesis takes place during the reverse transcriptase phase once a virion infects a T-cell) Ki because this allows us to infer the daily rate of T-cell infections as dNi/dt=0 -> k Nv Nt = Ki * Ni -- dNt/dt= λ - kT*NtT dNi/dt=-ki*NiT dNv/dt=ρ*ki*NiT-kv*NvT -- NtT= (λ/kT)+ C*e^(-kT*t) with C a constant -- clearance of infected cells in absence of new infection and production of virions (release from infected cells) and clearance of virions -- no -- NiT=N(io)e^(-kiT); expoential decay for k1>1 -- sub. NiT into dNv/dt=ρ*ki*NiT-kv*NvT to get βe^(-kiT)-kv*NvT with β = ρ k1 N(io) -- βe^(-kiT)-kv*NvT -- NvT= αi e^(-kiT)+ αv e^(-kvT) -- yes for certain parameters -- A linear regression led us to conclude that Kv was on the order of 0.52 day-1. This conclusion was incorrect. Actually, virus is cleared faster than infected cells, so NvT= αi e^(-kiT) models viral decay and Ki is the one to look at NOT kv. the long term behavior of NvT follows NvT is proportional to e^-k1T -- take the derivate when slope is 0 and time zero to go Kv=1.4 day -1 1.4 day -1, 1.4 10^5 RNA/ml 0.52 day -1 2.4 10^5 RNA/ml -- N(t)=No*e^-kt=No/2 τ(1/2)=ln(2)/ki -- 1.3 .5 -- (1/3) x (1/3) x 10-4 ≈ 10-5 -- 10-5 x 10^7 = 10^2 cells! at any time during the latent phase of the infection, all possible single point mutations are present. This explains the rapid development of resistance to single-drug treatment and the Use three-drug cocktails to outcompete the ability of the virus to adapt through point mutations. -- reach zeros much faster than lower one -- one with greater constant will overtake in short run, but long term graph will match the one will less constant

Explain 2 ways to multiple a random matrix 2000x2000. for loops are the _ way. Vectors and matrix are the _ way. Add the integers from 1 to 1000000. Show 2 ways.

MegaM=rand(2000,2000); size(MegaM) for i=1:2000 for j=1:2000 MegaM_10_1(i,j)=MegaM(i,j)*10; end end MegaM_10_2=MegaM*10; slow fast sum_1_1e6=0; tic for i=1:1000000 sum_1_1e6=sum_1_1e6+i; end toc sum_1_1e6 vector_1_1e6=1:1000000; sum(vector_1_1e6)

Why integrating biological measurements into mathematical & physical models? mysterious_series=-1:1:5 length(mysterious_series) Question: Consider the command above. How many elements do you think mysterious_series will include? A) 5 B) 4 C) 7 D) 0 disp('Matlab, please count from 1 to 5') for k=1:-1:5 k % Return integers from 1 to 5 end Question: Consider the for loop above. Something went wrong with its execution since no number was returned. What went wrong? A) k is not a legitimate variable for a loop. I should have used variable i instead. B) No number is returned because the for loop will run forever due to a syntax error. C) The expression over which k is defined leads to an empty vector. D) Unlike Siri, Matlab doesn't know how to answer questions. % A blank series disp('Matlab, please count from 1 to 5') for k=1:1:5 i end % end a for loop is essential Question: Consider the new loop above. Something went wrong again with its execution: no number was returned. What went wrong? A) The expression over which k is defined leads to an empty vector. B) The last line contains two "end" in a row, which creates a bug. C) Matlab doesn't know how to count. D) i is not the variable over which the for loop is implemented.

Intuitions and verbal descriptions can be misleading... the laws of physics (and chemistry) can be qualitatively bent without you noticing this type of inconsistencies! C C D

for A=[2 4 6] B=[3 5 1] and C=A<B, what is produced and why? write a code that will fish out the true elements of A in the previous statement

Matlab goes through element wise and compares C=[1 1 0] >> d=a(a<b) d = 2 4

write the code for fib sequence

N = 100; f(1) = 1; f(2) = 1; for n = 3:N f(n) = f(n-1) + f(n-2); end f(1:10)

for the equation dC/dt=y-kt explain what produces the negative values of the concentration of GFP for the ODE. discuss how ODE model should be corrected to include a standard first order decay kinetics for GFP. upon this change do you still expect to find value fo GFP concentration that are negative? What is the typical scale of a biological process? for a binomial distribution in 1D: n=10^12, p=0.5, 𝛿=10^-9, Are these properties suitable to approximate the Binomial distribution as a Poisson distribution? for a binomial distribution in 1D: n=10^12, p=0.5, 𝛿=10^-9 what happens to the distrubtion of position xi(n) in this limit? Are these step increments by multiple of 2 compatible with the random walk? prove this mathematically. what is the graph for 3 Binomial distribution for different trial numbers? What are the differences between these three distributions? How do we rescaling through a change in random variable? what happens to the graph after a change in random variable? what is the change of random variable equation? in the change of random variable equation, what happens when k>>1? what does the rescaled b_d becomes? what is the normal distribution? how do we calculate the probability that x takes a value between x and x+dx? what is the central limit theorem? Give a specific example of the CLT? Imagine the random variables x1 and x2 have the following probability distributions. Does the central limit theorem state that the sum of the probability distributions for x1 and x2 give a gaussian? what do many biological qualities result in? In the lab, what do we make? what are some limitation to the gaussian distrubtion?

a y will inflow. a kt will linearly increase over time (decrease in this case). for t<y/k=2, inflow>outflow so dC/dT>0 and C(t) will grow. for t>y/k=2, inflow<outflow so dC/dt<0 so C(t) will decrease. The outflow must be depends on C(t). When C(t) = 0, the outflow must be equal to 0 since there is nothing left to decay! Therefore we modify equation to have 1st order reaction kinetics (t is not first order reaction kinetics) so we will have dC/dt=y-k.C(t) with C(0)=0. no, solving the nonjomoegnous ODE will produce a graph that will not have negative values. Lysozyme: Typical step length of its "walk" is 𝛿=10^-9; Typical step rate (frequency) of its "walk": 10^12 s -1 No ...? ...? If we assume that $ refers to the steps made toward the right side (positive): x=k.(+1)+(n-k).(-1) =k-(n-k) =2.k-n for k=5, x=10-10=0; for k=4, x=8-10=-2 for k=6, x=12-10=2 here we see increments of 2! -- see lecture -- 1. Position of the means/SD 2. Width of the distributions 3. Maximum values of the distribution (result from ∑all k p(k)=1) first x=k-uK (centers the new variable on the mean). Imagine also Mean - Mean will bring the graph to zero. now with the previous graph, do the same minus business to all the graphs centered on zero. x=k-uK/σ (normalizes the centered distrubtion by the SD; division by SD will somehow have all the binomial distribution look the same) -- see lecture -- x=k-uK/σ (normalizes the centered distrubtion by the SD -- unitary differences in the values of k are insignificant -> it is more relevant to reason in terms of intervals or ranges of value such as k+/- dk= 10^5 +/- 10^2; x +/- dx = 1+ 10^-4 (continuous approximation) -- undistinguishable from the Normal/Gaussian distribution: p(k)dk -(apply the change of random variable equation)-> p(x)dx= 1/sqrt(2pi).e^-x^2/2.dx -- p(x)= 1/sqrt(2pi).e^-x^2/2 for any probability of success p (mu=0, σ=1) -- application of the Gaussian distribution P(x;mu x; σx)= 1/sqrt(2pi)σx . e^-(x-mu k)^2/2σx^2 where n-> infinite, p is finite and n.p>>0 -- The central limit theorem (CLT) establishes that when independent random variables are added, their sum tends toward a normal distribution upon proper normalization even if the original variables themselves are not normally distributed. -- suppose that x1 is given by rand. suppose x2 and x3 are also given by rand. the CLT asserts that the random variable defined as x1+x2+x3 will approximately follow a gaussian distrubtion -- no, not adding shape, need to add point in the probability that are independent -- Many biological quantities results from the additive effects of many independent random variables. For instance, height combines the effects of hundred of genes. In first approximation, these genes have an additive effect → height follows a Gaussian distribution -- In the lab, you make many independent measurements. To calculate the average of these measurements, you take their sum (uK=∑ all k k.(nk/n)) The sum (and thereby the average) of these measurements is expected to follow a Gaussian distribution. -- 1. Some random events do not follow a Gaussian distribution. For instance, the number of mutations observed during the reverse-transcriptase of a HIV virus. Rare events follow a Poisson distribution. 2. A quantity might be the sum of contributions from many sources. However these sources might be interdependent. For instance, neurons connected in a network do not "fire" (produce action potentials) independently of each other (e.g., epileptic seizures).

write code simulating the LD experiment show the stats for the darwin model and the LM model. plot the results

alpha=2.5e-9; number_trials=87; number_generations=21; number_resistant_colonies_Darwin=zeros(number_trials,1); number_resistant_colonies_Lamarck=zeros(number_trials,1); final_number_bacteria=150*2^21; for j=1:number_trials NWild=zeros(1,number_generations+1); NMutant=zeros(1,number_generations+1); NWild(1)=150; NMutant(1)=0; for i=1:number_generations New_born_mutants=poissrnd(alpha*NWild(i)); NWild(i+1)=(2*NWild(i))-New_born_mutants; NMutant(i+1)=(2*NMutant(i))+New_born_mutants; end number_resistant_colonies_Darwin(j)=NMutant(end); number_resistant_colonies_Lamarck(j)=poissrnd(alpha*final_number_bacteria); end -- sum(number_resistant_colonies_Darwin>9) disp('Probability of observing more than 9 colonies for Darwinian model') sum(number_resistant_colonies_Darwin>9)/length(number_resistant_colonies_Darwin) disp('Largest number of resistant colonies observed in one trial for Darwinian model') max(number_resistant_colonies_Darwin) -- disp('Probability of observing more than 9 colonies for Lamarckian model') sum(number_resistant_colonies_Lamarck>9)/length(number_resistant_colonies_Lamarck) disp('Largest number of resistant colonies observed in one trial for Lamarckian model') max(number_resistant_colonies_Lamarck) -- close all figure subplot(2,1,1) histogram(number_resistant_colonies_Darwin,-0.5:1:25.5,'Normalization','probability') % Plot the histrogram with the resuls of the Darwinian model xlabel('Number of resistant colonies') ylabel('Percentage (probability)') title('Results of Darwinian model') box off subplot(2,1,2) histogram(number_resistant_colonies_Lamarck,-0.5:1:25.5,'Normalization','probability') % plot the histrogram with the resuls of the Lamarckian model xlabel('Number of resistant colonies') ylabel('Percentage (probability)') title('Results of Lamarckian model') box off

what is the point of these following codes/under how it is run. clear all prob_success=1/2; for i=1:1001 prob_dist_large_bino(i)=binopdf(i-1,1000,prob_success); end x_value=-4:0.1:4; for i=1:length(x_value) prob_dist_gauss(i)=normpdf(x_value(i)); end - mean_large_bino=1000*prob_success; std_large_bino=sqrt(1000*prob_success*(1-prob_success)); k_rescaled_large_bino=((0:1:1000)-mean_large_bino)/std_large_bino; y_scaling=max(prob_dist_gauss)/max(prob_dist_large_bino); clf plot(k_rescaled_large_bino,y_scaling*prob_dist_large_bino,'b','LineWidth',2) ylabel('Probability density') xlabel('Random variable x') set(gca, 'FontSize', 20) box off xlim([-4 4]) hold on --

clear all prob_success=1/2; for i=1:1001 % compute probability for k ranging from 0 to 1000 -- prob_dist_large_bino(i)=binopdf(i-1,1000,prob_success); % i-1 since k=0 corresponds to index 1 -- end % Range of values corresponding to the rescaled k x_value=-4:0.1:4; % Compute the Gaussian distribution on this range for mean=0 and stdev=1 -- % (Normal distribution) -- for i=1:length(x_value) prob_dist_gauss(i)=normpdf(x_value(i)); end *Binomial with very large trial number We will repeat the same procedure with a very large value for the number of trials: n=1000* ----- % Apply same rescaling procedure as before to the Binomial distribution for % N_step = 1000 -- mean_large_bino=1000*prob_success; std_large_bino=sqrt(1000*prob_success*(1-prob_success)); k_rescaled_large_bino=((0:1:1000)-mean_large_bino)/std_large_bino; y_scaling=max(prob_dist_gauss)/max(prob_dist_large_bino); -- % Plot the Normal and rescaled Binomial distribution -- clf -- % First the rescaled Binomial distribution -- plot(k_rescaled_large_bino,y_scaling*prob_dist_large_bino,'b','LineWidth',2) ylabel('Probability density') xlabel('Random variable x') set(gca, 'FontSize', 20) box off xlim([-4 4]) hold on ------ % Next plot the Normal distribution N(mu=0,sigma=1) plot(x_value,prob_dist_gauss,'--r','LineWidth',3) ylabel('Probability density') xlabel('Random variable x') legend('Rescaled Binomial for n=1000','Normal distribution') set(gca, 'FontSize', 20) box off xlim([-4 4])

write script for reproduction of the binomial distribution for equal probability of moving up and down plot (step)

clear all tic total_number_steps=10; total_number_of_particles=1e4; probability_of_success=0.5; particle_step_counter=zeros(total_number_steps+1,total_number_of_particles); particle_position_table=zeros(total_number_steps+1,total_number_of_particles); for current_particle_index=1:total_number_of_particles for current_step_index=1:total_number_steps if (rand<probability_of_success) particle_position_table(current_step_index+1,current_particle_index)=particle_position_table(current_step_index,current_particle_index)+1; particle_step_counter(current_step_index+1,current_particle_index)=particle_step_counter(current_step_index,current_particle_index)+1; else particle_position_table(current_step_index+1,current_particle_index)=particle_position_table(current_step_index,current_particle_index)-1; particle_step_counter(current_step_index+1,current_particle_index)=particle_step_counter(current_step_index,current_particle_index); end end end toc % Plot the histogram of the statistics of steps up figure histogram(particle_step_counter(end,:),'Normalization','probability') xlim([0 total_number_steps]) xlabel('Number of steps up') ylabel('Probability')

now modify this code to simulate the trajectories of multiple Brownian particles now inspect the first 5 trajectories in a single graph now analyze the positions of the 1000 particles at specific times (0, 50, 200 and 1000) after the beginning of the trial.

clear all total_number_steps=1000; total_number_of_particles=1000; particle_position_table=zeros(total_number_steps,total_number_of_particles); for current_particle_index=1:total_number_of_particles for current_step_index=2:total_number_steps if (rand<0.5) particle_position_table(current_step_index,current_particle_index)=particle_position_table(current_step_index-1,current_particle_index)-1; else particle_position_table(current_step_index,current_particle_index)=particle_position_table(current_step_index-1,current_particle_index)+1; end end end toc -- figure number_of_shown_trajectories=5; for i=1:number_of_shown_trajectories plot(particle_position_table(:,i)) hold on end xlabel('Time (a.u.)'),ylabel('Position of individual particles') -- clf %%% DISTRIBUTION AT t=0 histogram_bin_edges=-100:10:100; % vector defining the bin edges subplot(2,2,1) histogram(particle_position_table(1,:),histogram_bin_edges,'Normalization','probability') xlabel('DPositions'),ylabel('Position densities') title('Distribution of position at time t=0') %%% DISTRIBUTION AT t=50 subplot(2,2,2) histogram(particle_position_table(50,:),histogram_bin_edges,'Normalization','probability') xlabel('DPositions'),ylabel('Position densities') ylim([0 1]) title('Distribution of position at time t=50') %%% DISTRIBUTION AT t=200 subplot(2,2,3) histogram(particle_position_table(200,:),histogram_bin_edges,'Normalization','probability') xlabel('Positions'),ylabel('Position densities') ylim([0 1]) title('Distribution of position at time t=200') %%% DISTRIBUTION AT t=1000 subplot(2,2,4) histogram(particle_position_table(1000,:),histogram_bin_edges,'Normalization','probability') ylim([0 1]) xlabel('Positions'),ylabel('Position densities') title('Distribution of position at time t=1000')

write the code to count the number of seconds in one week. explain this code

count =0 for d=1:7 for h=1:24 for m=1:60 for s=1:60 count=count+1; end end end end disp(count) d=1, h=1, m=1, s=1.....60 (because of count+1) then m=2, s=1....60 and so on until m=60 then h=1, m=1....60 and so on until h=24 then d=2, process repeats seconds is 604800

Write the code to gain the statistical result of two consecutive coin flip explain the code plot it

counter=zeros(3,1); total_number_coin_flips=100; for current_step_index=1:total_number_coin_flips result=(rand>0.5)+(rand>0.5); counter(result+1)=counter(result+1)+1; end coin_flip_fractions=counter/sum(counter); disp('Fraction of heads-heads:') coin_flip_fractions(1) disp('Fraction of heads-tails (in any order):') coin_flip_fractions(2) disp('Fraction of tails-tails:') coin_flip_fractions(3) explain the code counter=zeros(3,1); % convention about recording of results: % heads = 0; tails = 1 % heads;heads = 0 % heads;tails = 1 % tails;tails = 2 % counter(1) will record all the heads;heads % counter(2) will record all the heads;tails and tails;heads % counter(3) will record all the tails;tails -- total_number_coin_flips=100; for current_step_index=1:total_number_coin_flips result=(rand>0.5)+(rand>0.5); -- counter(result+1)=counter(result+1)+1; % increase the count corresponding to the outcome of the present trial -- end % Convert count numbers into proportions coin_flip_fractions=counter/sum(counter); % Display the results -- disp('Fraction of heads-heads:') coin_flip_fractions(1) disp('Fraction of heads-tails (in any order):') coin_flip_fractions(2) disp('Fraction of tails-tails:') coin_flip_fractions(3) -- %%% MORE ADVANCED % Display the results of the 2 consecutive coin flips % Use bar function to plot a bar graph clf labels=categorical({'heads-heads','heads-tails','tails-tails'}); coin_flip_fractions bar(labels,coin_flip_fractions), box off ylabel('Fraction of events (probability)')

write the code for the stats produced by 4 coin flips DO BOTH THE FAST WAY AND SLOW WAY plot it plot the predicted

counter=zeros(5,1); total_number_4flips=1e4; for current_step_index=1:total_number_4flips coin_flips=rand(4,1); result=0; for i=1:4 result=result+(coin_flips(i)>0.5); end faster result=sum(coin_flips>0.5); counter(result+1)=counter(result+1)+1; end % Plot results % Use bar function to plot a bar graph coin_flip_fractions=counter/total_number_4flips; labels=categorical({'0 tails','1 tails','2 tails','3 tails','4 tails'}); bar(labels,coin_flip_fractions), box off ylabel('Probablity of outcome') -- Binomial_dist=zeros(5,1); for i=0:4 binomial_coefficient=factorial(4)/(factorial(4-i)*factorial(i)); Binomial_dist(i+1)=(1/2^4)*binomial_coefficient; end % Create a table with the simualted and predicted probabilities compare_stats_vector=[coin_flip_fractions(1) Binomial_dist(1); coin_flip_fractions(2) Binomial_dist(2); coin_flip_fractions(3) Binomial_dist(3); coin_flip_fractions(4) Binomial_dist(4); coin_flip_fractions(5) Binomial_dist(5)] % Plot comparison of simulated and theoretical distributions labels=categorical({'0 tails','1 tails','2 tails','3 tails','4 tails'}); bar(labels,compare_stats_vector), box off ylabel('Probability') legend('Emperical (simulated)','Theoretical (Binomial)')

Do the more advanced way of the coin flip explain the code

cumulated_number_of_observed_tails=zeros(total_number_coin_flips,1); cumulated_number_of_observed_tails(1)=flip_outcome(1); for i=2:length(flip_outcome) cumulated_number_of_observed_tails(i)=cumulated_number_of_observed_tails(i-1)+flip_outcome(i); end clf plot(cumulated_number_of_observed_tails) hold on plot([0 total_number_coin_flips],[0 total_number_coin_flips/2],'r') legend('Virtual flips','Chance') xlabel('Trial number') ylabel('Cumulated number of observed tails') %%% MORE ADVANCED, but fun... % Compute the cumulated number of observed tails cumulated_number_of_observed_tails=zeros(total_number_coin_flips,1); % cumulated number of observed tails -- % Enter outcome of first coin flip cumulated_number_of_observed_tails(1)=flip_outcome(1); -- for i=2:length(flip_outcome) % instead of length(flip_outcome), I could have written total_number_flips -- cumulated_number_of_observed_tails(i)=cumulated_number_of_observed_tails(i-1)+flip_outcome(i); end -- % Plot the results of the cumulated number of observed tails (values=1) % Compare the empirical observation to chance (1/2 outcomes are expected to be tails) clf plot(cumulated_number_of_observed_tails) hold on -- plot([0 total_number_coin_flips],[0 total_number_coin_flips/2],'r') % plot predicted outcome for chance -- legend('Virtual flips','Chance') xlabel('Trial number') ylabel('Cumulated number of observed tails')

What is modified diffeq for the realistic model of virus growth and decay? what is the units of inflow and degradation rate? explain the degradation rate? what is a non homogenous ODE? what is the solution of a non homogenous ODE? find the particular solution to the non homogenous ODE described previous? how do you check this? find the general solution to the non homogenous ODE N(0)=0? using the general solution to the nonhomogenous ODE, what is the number of virus in two extreme condition? show this on graph What are the three main bio facts about HIV? how is HIV targeted? what is reverse transcription? when is the immune system compromised? what are the main protagonist included in the model of HIV? What is the meaning of the negative and positive terms on the right side of the ODEs discussed during the class about HIV dynamics? What is a zero-order production term? A first-order degradation term? in the following ODE, what is the meaning of Kv or y? dNv/dt=y-kv*Nv(t)/ how do these variable affect the solution to the ODE?

dN/dt=inflow-outflow where unit of y is molecules/day and unit of degredation rate is 1/day; probability that a RNA molecules is degraded during a certain period of time dN/dt=-k*N(t) (outflow) and dN/dt=y (inflow) so you get dN/dt=y-k*N(t) -- presence of a term that doesn't depend on the independent variable t) -- The solution of a non-homogenous ODE is given by the sum of the general solution of the homogeneous ODE and a particular solution to the non-homogeneous ODE. -- N(t)=y/k; plug y/k back into dN/dt and N(t) and see if both are equal -- N(t)=y/k+Co*e^-k*t for N(0)=0: y/k +Co = 0 -> Co = -y/k N(t)=y/k(1-e^-k*t) -- N(0)=y/k(1-e^0)=0 N(inf)=y/k(1-e^-inf)=y/k approach y/k value -- genome=10,000 base 9 genes 19 proteins -- reverse transcription, limited proteolysis -- Rogue DNA integrated in host produces more viral RNA: ~1000 virions/infected T-cell Reverse transcriptase is the step responsible for the virus' mutagenesis. -- immune system is seriously compromised when less than 20% of normal T cell population remains -- Nv(t) -number of free virions (viral load) Nt (t)- number of uninfected T-cells NI (t)- number of infected cells -- decreasing rate, increasing rate -- a constant, something that depends on a pool of something -- y is the rate constant of virus flowing in, Kv is the degradation rate of virus ?? --

write code for the LD experiment with the LM model mu=1 k is 20 Computing the likelihood of trials leading to a large number of resistant colonies:

estimated_mu=1; m=0:1:20; poisson_prob_m=zeros(length(m),1); for i=1:length(m) poisson_prob_m(i)=(1/factorial(m(i)))*(estimated_mu^m(i))*exp(-estimated_mu); end bar(m(1:10),poisson_prob_m(1:10),'k') xlabel('Number of resistant colonies') ylabel('Probability') box off disp('Probability of observing 10 colonies') poisson_prob_m(9+1) sum(poisson_prob_m(10:20))

using the previous, Representation of the time course of the mean position of the particles: and find the slope too.

figure % Computer the mean position of the group of simulated particles mean_position_vector=zeros(total_number_steps,1); % time course of the mean position for i=1:total_number_steps mean_position_vector(i)=mean(particle_position_table(i,:)); end plot(mean_position_vector) xlabel('Time') ylabel('Position') -- disp('Speed of movement up:') (mean_position_vector(end)-mean_position_vector(1))/length(mean_position_vector)

Write the code for the previous for the Representation of the time course of the variance of the particule positions:

figure std_position_vector=zeros(total_number_steps,1); for i_step=1:total_number_steps std_position_vector(i_step)=std(particle_position_table(i_step,:)); end plot(std_position_vector) hold on plot(sqrt(1:1:1000),'r') legend('Simulations','Sqrt(t)') ylabel('Standard deviation of positions') xlabel('Time (a.u.)')

write script to simulate the stochastic production and degradation of a gene product (mRNA) explain it. what is the significance of it being discrete?

function [molecule_counter, step_sequence]=BirthDeathProcess_discrete number_step=2880; prod_rate=1; deg_rate=0.02; molecule_counter=zeros(number_step,1); for i=2:(number_step) probability_production=prod_rate/(prod_rate+deg_rate*molecule_counter(i-1)); if rand <= probability_production molecule_counter(i)=molecule_counter(i-1)+1; else molecule_counter(i)=molecule_counter(i-1)-1; end end close all step_sequence=0:(number_step-1); plot(step_sequence,molecule_counter) xlabel('Time (min)') ylabel('Number of mRNA molecules') title({['Time course of the number of mRNA molecules for a production rate of ', num2str(prod_rate),' (molecule/min)'],[ 'and a degradation rate of ', num2str(deg_rate), ' (1/min)']}) ---- function [molecule_counter, step_sequence]=BirthDeathProcess_discrete number_step=2880; % Total number of steps in min (equivalent to 2 days) -- prod_rate=1; % Production rate (molecules/min) deg_rate=0.02; % Degradation rate (1/min) -- % Time vector logging the number of molecules at each time step -- molecule_counter=zeros(number_step,1); % The initial value at t=1 is assumed to be 0. -- for i=2:(number_step) % The reaction starts from the initial condition n=0 at the first step. --probability_production=prod_rate/(prod_rate+deg_rate*molecule_counter(i-1)); -- % Propensity of reaction corresponding to production -- if rand <= probability_production % Picks a random number and defines whether production or degradation takes place (Monte Carlo method). molecule_counter(i)=molecule_counter(i-1)+1; % Implements production -- else molecule_counter(i)=molecule_counter(i-1)-1; % Implements degradation end --- end % Plots the number of molecules as a function of time -- close all % closes open figure windows -- step_sequence=0:(number_step-1); first mRNA molecule (which is zero) to line up with minute zero instead of minute 1 plot(step_sequence,molecule_counter) xlabel('Time (min)') ylabel('Number of mRNA molecules') title({['Time course of the number of mRNA molecules for a production rate of ', num2str(prod_rate),' (molecule/min)'],[ 'and a degradation rate of ', num2str(deg_rate), ' (1/min)']}) ----- we decided to degrade in 1 minute interval, in reality, this is not how system works, degradation time is more random

write a script stimulating the LD experiment (USING A FUNCTION) explain it show the stats for both model final num bacteria=150*2^21

function [number_resistant_colonies_Darwin,number_resistant_colonies_Lamarck] = LuriaDelbruckSimulator(alpha) % alpha represents the probability of acquiring resistance at each cell % devision. It is an input argument to the function. Run the simulations with value: alpha=1e-8; % number_trials=10000; number_generations=21; number_resistant_colonies_Darwin=zeros(number_trials,1); number_resistant_colonies_Lamarck=zeros(number_trials,1); final_number_bacteria=150*2^21; for j=1:number_trials NWild=zeros(1,number_generations+1); NMutant=zeros(1,number_generations+1); NWild(1)=150; NMutant(1)=0; for i=1:number_generations New_born_mutants=poissrnd(alpha*NWild(i)); NWild(i+1)=(2*NWild(i))-New_born_mutants; NMutant(i+1)=(2* NMutant(i))+New_born_mutants; end number_resistant_colonies_Darwin(j)=NMutant(end); number_resistant_colonies_Lamarck(j)=poissrnd(alpha*final_number_bacteria); end close all figure subplot(2,1,1) histogram(number_resistant_colonies_Darwin,-0.5:1:25.5,'Normalization','probability') xlabel('Number of resistant colonies') ylabel('Percentage (probability)') title('Results of Darwinian model') subplot(2,1,2) histogram(number_resistant_colonies_Lamarck,-0.5:1:25.5,'Normalization','probability') xlabel('Number of resistant colonies') ylabel('Percentage (probability)') title('Results of Lamarckian model') -- sum(number_resistant_colonies_Darwin>9) disp('Probability of observing more than 9 colonies for Darwinian model') sum(number_resistant_colonies_Darwin>9)/length(number_resistant_colonies_Darwin) disp('Largest number of resistant colonies observed in one trial for Darwinian model') max(number_resistant_colonies_Darwin) Same for Lamarckian model: disp('Probability of observing more than 9 colonies for Lamarckian model') sum(number_resistant_colonies_Lamarck>9)/length(number_resistant_colonies_Lamarck) disp('Largest number of resistant colonies observed in one trial for Lamarckian model') max(number_resistant_colonies_Lamarck)

Write the script for the simulation of stochastic production of mRNA molecules as a series of continuous stochastic time steps: explain the code

function [time_log,molecule_counter]=BirthDeathProcess_continuous(max_time,prod_rate,deg_rate) if nargin == 0 max_time=1e3; prod_rate=1; deg_rate=0.02; end current_time=0; step_counter=1; time_log=0; molecule_counter=0; while current_time < max_time wait_time=-log(rand)/(prod_rate+(deg_rate*molecule_counter(step_counter))); prob_prod=prod_rate/(prod_rate+deg_rate*molecule_counter(step_counter)); current_time=current_time+wait_time; step_counter=step_counter+1; time_log(step_counter)=current_time; if rand < prob_prod molecule_counter(step_counter)=molecule_counter(step_counter-1)+1; else molecule_counter(step_counter)=molecule_counter(step_counter-1)-1; end end if nargin == 0 close all subplot(2,1,1) plot(time_log(1:500),molecule_counter(1:500)) ylabel('Number of mRNA molecules') xlabel('Time (min)') title('Full time course of the number of mRNA molecules') subplot(2,1,2) plot(time_log(1:50),molecule_counter(1:50),'*-') hold on plot(time_log(1:50),ones(50,1),'r*') legend('Number of mRNA molecules','Timestamp of reaction event','Location','northwest') title('Initial change in the number of mRNA molecules') ylabel('Number of mRNA molecules') xlabel('Time (min)') hold off end ------ function [time_log,molecule_counter]=BirthDeathProcess_continuous(max_time,prod_rate,deg_rate) if nargin == 0 % Default values. Test whether max_time is defined externally. nargin refers to the number of argument of the function (i.e., the number of parameters entered as an input) ----- max_time=1e3; ---- prod_rate=1; % Production rate (molecules/min) ---- deg_rate=0.02; % Degradation rate (1/min) --- end % Initialization of parameter current_time=0; step_counter=1; time_log=0; molecule_counter=0; ----- while current_time < max_time % Use a while loop to increase the current time until it exceeds the maximum value max-time. ------ wait_time=-log(rand)/(prod_rate+(deg_rate*molecule_counter(step_counter))); % Simulated wait time: makes use of the fact that production and degradation are two independent Poisson processes. -------prob_prod=prod_rate/(prod_rate+deg_rate*molecule_counter(step_counter)); % Propensity of mRNA production ------ current_time=current_time+wait_time; % Update current time ----- step_counter=step_counter+1; % Update the number of steps (reactions) associated with the experiment. ---- time_log(step_counter)=current_time; % Add the current time to the time log ----- if rand < prob_prod % Defines whether production takes place based on Monte Carlo method. ------molecule_counter(step_counter)=molecule_counter(step_counter-1)+1; % Implements production else -----molecule_counter(step_counter)=molecule_counter(step_counter-1)-1; % Implements degradation end ------ end if nargin == 0 % Plot results only when the number of input argument into the function is 0 (i.e., when the function is executed directly from the editor) ----- close all subplot(2,1,1) plot(time_log(1:500),molecule_counter(1:500)) % Plots only the first 500 transitions ----- ylabel('Number of mRNA molecules') xlabel('Time (min)') title('Full time course of the number of mRNA molecules') subplot(2,1,2) plot(time_log(1:50),molecule_counter(1:50),'*-') % Plots only the first 50 transitions ------ hold on plot(time_log(1:50),ones(50,1),'r*') legend('Number of mRNA molecules','Timestamp of reaction event','Location','northwest') title('Initial change in the number of mRNA molecules') ylabel('Number of mRNA molecules') xlabel('Time (min)') hold off end

write the script for the wrapper Matlab code allowing to simulate several trial and to extract their averages explain the code.

function [time_vector,matrix_molecule_counter,average_number_molecules,stdev_number_molecules]=BirthDeathProcess_averaging number_trial=1500; max_time_of_each_trial=4e2; time_vector=0:1:max_time_of_each_trial; matrix_molecule_counter=zeros(number_trial,length(time_vector)); prod_rate=0.15; deg_rate=0.014; for i=1:number_trial [timevec_temp,molvec_temp]=BirthDeathProcess_continuous(max_time_of_each_trial,prod_rate,deg_rate); matrix_molecule_counter(i,:)=interp1(timevec_temp,molvec_temp,time_vector); end average_number_molecules=mean(matrix_molecule_counter); stdev_number_molecules=std(matrix_molecule_counter); Poisson_expected_mean=prod_rate/deg_rate; dist_theoretical=poisspdf(0:1:20,Poisson_expected_mean); close all figure time_of_analysis=250; histogram(matrix_molecule_counter(:,time_of_analysis+1),-0.5:1:20.5,'Normalization','probability') hold on plot(0:1:20,dist_theoretical,'*-') legend(['Experimental data at t=',num2str(time_of_analysis),' min'],['Poisson probability distribution for mean=',num2str(Poisson_expected_mean)]) ylabel('Probability density') xlabel('Count number per cell') hold off figure plot(time_vector,average_number_molecules) hold on plot(time_vector,stdev_number_molecules,'r') plot(time_vector,sqrt(average_number_molecules),'g') hold off xlabel('Time (min)') ylabel('Number of mRNA molecules') legend('Average number of mRNA molecules','Standard deviation of mRNA molecules','Sqrt(Average)','location','northwest') ---- function [time_vector,matrix_molecule_counter,average_number_molecules,stdev_number_molecules]=BirthDeathProcess_averaging % Initialization of the parameters and variables number_trial=1500; ---- max_time_of_each_trial=4e2; time_vector=0:1:max_time_of_each_trial; matrix_molecule_counter=zeros(number_trial,length(time_vector)); % This is a matrix where each row corresponds to the time course of the mRNA molecules associated with a given tial. ---- prod_rate=0.15; % Use in connection with the experiment of Golding & Cox 2005 --- deg_rate=0.014; % Use in connection with the experiment of Golding & Cox 2005 for i=1:number_trial % calls the continuous function with wait time defined by Poisson process --- [timevec_temp,molvec_temp]=BirthDeathProcess_continuous(max_time_of_each_trial,prod_rate,deg_rate); --- % Each trial corresponds to a different series of time steps corresponding to % the occurence of successive reations. From this series of steps of % inequal sizes, we will create a vector with the number of molecules corresponding to a % series of steps of equal size (given by time_vector). This procedure requires interpolating the % number of molecules between the defined steps of inequal sizes. matrix_molecule_counter(i,:)=interp1(timevec_temp,molvec_temp,time_vector); end % Computes the average number of molecules across all trials. Does the same % for the standard deviation of the number of molecules. ---- average_number_molecules=mean(matrix_molecule_counter); % Note that this function will calculate the average number of molecules for each time point of the experiment. The result is a (time) vector. --- stdev_number_molecules=std(matrix_molecule_counter); % Plots the results. % Defines the expected mean number of mRNA molecules (steady state) ----- Poisson_expected_mean=prod_rate/deg_rate; % Output variables from BirthDeathProcess_continuous function ----- dist_theoretical=poisspdf(0:1:20,Poisson_expected_mean); %calculate poisson probability density with given expected value close all % Closes all existing figures. ---- figure % Opens a first figure ---- time_of_analysis=250; % Picks a time at which the statistics of the number of mRNA molecules are analyzed. ----- histogram(matrix_molecule_counter(:,time_of_analysis+1),-0.5:1:20.5,'Normalization','probability') % Represents the histrogram of the number of molecules at time t=200 min. hold on ----- plot(0:1:20,dist_theoretical,'*-') %Overlays theoretical values over the histogram. legend(['Experimental data at t=',num2str(time_of_analysis),' min'],['Poisson probability distribution for mean=',num2str(Poisson_expected_mean)]) ylabel('Probability density') xlabel('Count number per cell') hold off figure % Opens a second figure plot(time_vector,average_number_molecules) hold on plot(time_vector,stdev_number_molecules,'r') plot(time_vector,sqrt(average_number_molecules),'g') hold off xlabel('Time (min)') ylabel('Number of mRNA molecules') legend('Average number of mRNA molecules','Standard deviation of mRNA molecules','Sqrt(Average)','location','northwest')

Explain the dynamics of birth and death process in terms of a spring. what is the problem with the arbitrariness of the timescale? How can we use the poisson process to get a more realistic model of the transcription of RNA? what is Gillespie alg? what can we say about the dynamics of mRNA molecules for two independent trials? given the distortion of mRNA per cell at time t=500, which distrubtion would you use to model the number of molecule/cell? if the model was gaussian, can you say anything about the relationship between mean and SD? how do we validate that the poisson nature of BNP? what is a signal to noise ratio? what is more noisy? what is less noisy? how do we find mu in SNP? to make real life predication about RNA numbers in cell, what do we need to use You want to build a synthetic gene expression system leading to fluctuations on the average number of molecules <5%. What should be the min. number of molecules expressed by this system? What are the two conclusion drawn from mRNA and BNP? if our goal is to monitoring mRNA populations in living cells through microscopy, what is our general solution? what was the technique to do it? consequence? what can be gained from the consequence? what was the experimental protocol? what was the mismatch between theory and experiments? what is the new hypothesis? what is the conclusion?

given n ^=y/k; when the spring is down it wants to up just like n<n^ which will cause the P(+)=y/y+kn > P(-)=k.n/y+kn, this is because n is small in this case, which mean P(-) is small and P(+) is large so it will increase. vice verse with spring up. -- ...? though it seems that sometime the stochastic model matches the ODE, but that depends on the time step used -- trans. of RNA molecules is complex process analogous to the step made by a molecular motor thus with the poisson process, we can get the distrubtion of the wait time for synthesis (ni+1) P(t+;y)=y.e^-y.t+; similarly, we can do the same for degradation (ni-1) P(t_;k.ni)=k.ni.e^-k.ni.t adding this up, the compound process is P(t;y+k.n)=(y+k.n).e^-(y+k.n).t -- 1. Draw a wait time delta t from the exp dis. with the merged rate y+k.n(t) 2. determine which reaction happens after delta t by drawing from the ber. trial distribution with probability 𝜉=y/y+k.n(t) 3. update the number of molecules n(t+delta t) base don the outcome of 2. 4. repeat the whole procedure. -- analysis of fluc. at time t=500 with 2 cells do this for 100 cells and you will see avg value is 10, matches with n=y/k=10 (from the ODE model -- not neg exp. because it is about continuous wait time, not geometric because that is about how long you have to wait to observe success not binomial because the probability of producing will change per trial could be poisson since we are getting a smaller number or gaussian, it is poisson why? if you push the mean to 2 or 3, you will see that is look poisson instead no, in gaussian SD can be anything -- consider 100 cell and take the number of mRNA molecules at different time points and get the mean and standard deviation; compare it the real SD to see that it is true. -- compare 3 to 10, 10 will have less noisy SNP, strength of fluc. (SD) will be assessed relative to the mean; formula is mu/sd = mu/sqrt(mu)=sqrt(mu) find mu by doing mu=y/k -- use SNP -- ...? -- The relative fluctuations over the mean (sd/mu) will decrease as the number of mRNA molecules increases. • Whenthenumberofmoleculesinthesystemislarge,the continuous deterministic approximation (ODE) becomes accurate. Under this condition, the number of molecules can be treated as a continuous variable (concentration) whose dynamic can be predicted by applying the law of mass action. or n(t) -> n(t+delta t)= n(t)+1 or n(t+ delta t) n(t)-1 -(if n>>1) -> dx(t)/dt=y-k.x(t) -- application of a novel technique to count the number of mRNA molecule in a cell in real time -- Technique to count number of mRNA molecule in a cell in real time. Bacteria are modified to host two artificial genes. 1. The first gene expresses RFP fused to a non-coding region that contains 96 copies of a binding sequence recognized by the MS2 protein. 2. The second gene expressed GFP coupled to the MS2 protein. Consequence: each mRNA transcript is bound by dozen of GFP molecules. Individual mRNA molecules can be visualized through their fluorescence -- Distribution of fluorescence per cell enables the quantification of the number of mRNA molecules per cell -- Experimental protocol: • mRNA production starts at t=0 min. • mRNA counts is averaged over 50 cells in 3 experiments. look at graph in lecture BD is birth death process, seems to match actual data (use of gillisype model) good because this model can be use for few number of transcript per cell -- Experimenters had control over the induction rate of the gene of interest. Parameter y could be experimentally manipulated. at SS, mu = y/k so if you increase y, you increase mu. for poisson mode, mu= sd^2.. what will happen if you plot SD over mu is a slope of one. actual data does not give a slope of one. instead, we get that mu < sd^2. -- 1) Gene transcription is a bursting process: a gene makes spontaneous transitions between an active and an inactive states. 2) These transitions can be modeled as a Poisson process with mean rates βstart and βstop. Other mismatch with "simple" birth-and-death model: the delay between transcriptional induction and the rise in mRNA molecules does not decrease as predicted from y.e^-yt. Longer delays are observed experimentally. -- 1. Law of parsimony: The authors started by exploring the simplest physical model possible: the birth-and-death process. 2. Testable predictions: The authors established contact points between their theory (average & variance of number of mRNA molecules) and values that were quantifiable experimentally. 3. All models are wrong, but some are useful: As the initial model proved to be insufficient to explain important aspects of the experimental data, the authors advanced to the next "simplest" model. 4. Within the same organism, some genes are expressed in bursts. Others aren't. Transcriptional bursting is a controlled feature.

given K slow is 1, k fast is 10, graph the exponential function sum the two exp equations. plot the result run this script and explain what you see different. figure time_vector=0.1:0.01:10; v_exp_fast=exp(-time_vector) v_exp_slow=exp(-0.1*time_vector) v_exp_sum2=-0.5*v_exp_fast+0.5*v_exp_slow; figure plot(time_vector,-v_exp_fast,'b') hold on plot(time_vector,v_exp_slow,'g') plot(time_vector,v_exp_sum2,'r') box off xlabel('Time (a.u.)') legend('Rise (short-term) exponential','Fall (long-term) exponential','Linear combination')

k_slow=1; k_fast=10; time_vector=0:0.01:10; v_exp_fast=exp(-k_fast*time_vector) v_exp_slow=exp(-k_slow*time_vector) plot(time_vector,v_exp_fast,'r') hold on plot(time_vector,v_exp_slow,'b') xlim([0 3]) xlabel('Time'), ylabel('Exponential function') legend('Fast exponential','Slow exponential') box off time_vector=0:0.01:10; v_exp_fast=exp(-time_vector) v_exp_slow=exp(-0.1*time_vector) v_exp_sum=0.5*v_exp_fast+0.5*v_exp_slow; clf plot(time_vector,v_exp_fast,'b') % 'b' to plot in blue hold on plot(time_vector,v_exp_slow,'c') % 'c' to plot in cyan plot(time_vector,v_exp_sum,'g') % 'g' to plot in green xlabel('Time'), ylabel('Exponential function') legend('Fast exponential','Slow exponential','Sum of slow and fast exponentials')

do the graphically representation of P D for different value of parameter mu

number_k_considered=19; range_of_mu=[0.5 1 2 5 10]; poisson_distribution=zeros(number_k_considered+1,length(range_of_mu)); for i=1:length(range_of_mu) for k=0:1:number_k_considered poisson_distribution(k+1,i)=(1/factorial(k))*((range_of_mu(i))^k)*exp(-range_of_mu(i)); end end figure plot(0:1:number_k_considered,poisson_distribution,'-o') xlim([0 20]) xlabel('Number of successes') ylabel('Probability') legend('mu=0.5','mu=1','mu=2','mu=5','mu=10') box off

write the script to see how much percent of a set of 100 random numbers is below 0.5 and above 0.5.

number_of_random_numbers=100; random_vector=rand(1,number_of_random_numbers); counter_below_05=0; counter_above_05=0; for i=1:length(random_vector) if random_vector(i) < 0.5 counter_below_05=counter_below_05+1; else counter_above_05=counter_above_05+1; end end disp('The fraction > 0.5 is:') counter_below_05/(counter_below_05+counter_above_05) disp('The fraction < 0.5 is') counter_above_05/(counter_below_05+counter_above_05)

write the code that will emulate the stock market.

number_steps=1000; daily_value=zeros(number_steps,1); for i=2:number_steps daily_odds=rand; if daily_odds>0.5 % Key daily_value(i)=daily_value(i-1)+1; else daily_value(i)=daily_value(i-1)-1; end end figure; time_vector=1:1:number_steps; plot(time_vector,daily_value) xlabel('Time (days)') ylabel('Stock Index')

Explain how you wrote the code you just did.

number_steps=1000; % Steps can be viewed as consecutive days of the stock market. --- daily_value=zeros(number_steps,1); % This vector will contain the time of the market price or stock index. --- for i=2:number_steps daily_odds=rand; % daily_odds is a random variable that defines the daily trend of the market (whether or not it will increase on a specific day) --- if daily_odds>0.5 % Key daily_value(i)=daily_value(i-1)+1; else daily_value(i)=daily_value(i-1)-1; end end --- % The following commands plot the time course of a market price or stock % index y_position figure; ---- time_vector=1:1:number_steps; % This vector corresponds to the number of days during which the market price was recorded (see for loop above) ---- plot(time_vector,daily_value) xlabel('Time (days)') ylabel('Stock Index') EXPLAIN FOR THE DAILY VALUE if daily odds variable has a value more than 0.5, the daily value stored in i-1 will add one. (it will go back to the previous I values basically and pull that value.

what does x=rand x=randi create a 3 by 5 matrix with random number Generate a 10-by-1 column vector of uniformly distributed random integers from the sample interval [-5,5]. Create a 3-by-2-by-3 array of uniformly distributed random integers between 1 and 500. what does the y in rand(x)+y do? do?

x=rand= literally gives you random number - r = rand(5) r = 5×5 0.8147 0.0975 0.1576 0.1419 0.6557 0.9058 0.2785 0.9706 0.4218 0.0357 0.1270 0.5469 0.9572 0.9157 0.8491 0.9134 0.9575 0.4854 0.7922 0.9340 0.6324 0.9649 0.8003 0.9595 0.6787 - draw random integers between 1 and a given number (say 6) - r=rand(3,4) - r = randi(10,5) - r = randi([-5,5],10,1) - X = randi(500,[3,2,3])

what is the point of these following codes/under how it is run. number_trials=1e5; x1_vect=rand(number_trials,1); x2_vect=rand(number_trials,1); x1_vect=x1_vect-0.5; x2_vect=x2_vect-0.5; subplot(1,2,1) histogram(x1_vect,-0.5:0.05:0.5,'Normalization','probability') title('Distribution of x1') ylabel('Probability') box off set(gca, 'FontSize', 16) subplot(1,2,2) histogram(x2_vect,-0.5:0.05:0.5,'Normalization','probability') title('Distribution of x2') box off set(gca, 'FontSize', 16) -- x12_vect=x1_vect+x2_vect; disp('Size of vector withvalues of new random variable x1+x2') size(x12_vect) -- disp('Max value:') max(x12_vect) disp('Min value:') min(x12_vect) disp('Mean value:') mean(x12_vect) disp('Standard deviation:') std(x12_vect) -- clf histogram(x12_vect,-1:0.05:1,'Normalization','pdf') hold on plot(-1:0.01:1,normpdf(-1:0.01:1,mean(x12_vect),std(x12_vect)),'r','LineWidth',3) title('Distribution of x1+x2') ylabel('Probability') box off set(gca, 'FontSize', 16) -- number_random_variables=10; x_array=(rand(number_trials,number_random_variables)-0.5); x_sum=sum(x_array,2); mean_x_sum=mean(x_sum); std_x_sum=std(x_sum); rescaled_x_sum=(x_sum-mean_x_sum)/std_x_sum; clf histogram(rescaled_x_sum,-4:0.05:4,'Normalization','pdf') hold on plot(-4:0.01:4,normpdf(-4:0.01:4,0,1),'r','LineWidth',3) title('Sum of 3 uniformally distributed random variables') set(gca, 'FontSize', 16) box off

number_trials=1e5; x1_vect=rand(number_trials,1); x2_vect=rand(number_trials,1); % recenter the values of the random variable on 0 -- x1_vect=x1_vect-0.5; x2_vect=x2_vect-0.5; % plot a histogram of the values of x1 and x2 (list of outcome of 1e5 trials) -- subplot(1,2,1) histogram(x1_vect,-0.5:0.05:0.5,'Normalization','probability') title('Distribution of x1') ylabel('Probability') box off set(gca, 'FontSize', 16) subplot(1,2,2) histogram(x2_vect,-0.5:0.05:0.5,'Normalization','probability') title('Distribution of x2') box off set(gca, 'FontSize', 16) *Let's define two random variables uniformally distrbuted between -0.5 and 0.5:* -- % Define a new random variable equal to the sum of x1 and x2 x12_vect=x1_vect+x2_vect; disp('Size of vector withvalues of new random variable x1+x2') size(x12_vect) *Introducing a new random variable that is the sum of two random variables defined by rand* -- % What is the domain of variation of x12? disp('Max value:') max(x12_vect) disp('Min value:') min(x12_vect) disp('Mean value:') mean(x12_vect) disp('Standard deviation:') std(x12_vect) ------- % Plotting the histogram of x12 (sum of x1 and x2) on the right domain of variation (-1 to 1) -- clf histogram(x12_vect,-1:0.05:1,'Normalization','pdf') hold on % Plotting the corresponding Gaussian distribution (same mean and std as x12) -- plot(-1:0.01:1,normpdf(-1:0.01:1,mean(x12_vect),std(x12_vect)),'r','LineWidth',3) title('Distribution of x1+x2') ylabel('Probability') box off set(gca, 'FontSize', 16) -- number_random_variables=10; % Number of random variables that will be summed -- x_array=(rand(number_trials,number_random_variables)-0.5); x_sum=sum(x_array,2); % takes the sum over all the columns. Equivalent to a for loop to implement the additions. -- mean_x_sum=mean(x_sum); std_x_sum=std(x_sum); rescaled_x_sum=(x_sum-mean_x_sum)/std_x_sum; clf histogram(rescaled_x_sum,-4:0.05:4,'Normalization','pdf') hold on plot(-4:0.01:4,normpdf(-4:0.01:4,0,1),'r','LineWidth',3) title('Sum of 3 uniformally distributed random variables') set(gca, 'FontSize', 16) box off *Let's repeat the same with the sum of more than two random variables: 10 random variables*

What is the probability of success? failure? what is the probability of a given realization? number of possible realizations? what is the binomial distribution? from the binomial distribution, demonstrate expectation, variance and SD? explain the law of motion. what conclusion can we draw from this? so do brownian particles still go nowhere in the case where there is step bias? Suppose that you roll a fair dice 10 times. How many "6" faces are you most likely to observe out of 10 dice rolls? What is the likelihood of observing zero "6"? Consider a population of 100,000 (105) T-cells and a pool of 300,000 (3x105) HIV viruses. Assumption: Each cell has the same probability of being infected by every virus of the pool. Each virus will infect 1 and only 1 cell. One cell can be infected by more than 1 virus. Question: What is the average number of infections a T-cell will undergo? -- write out the equation for the P D. -- what are the assumption in the P D. -- what are <k>, var(k) and σk for P D. -- During each reverse transcriptase step of a HIV infection, the average number of base change is 0.3. What is the probability that the genome of a virus carries 0, 1 and 2 mutations? -- The HIV genome contains 10,000 bases. What is the number of possible mutants of 1 and 2 base changes? -- knowing the above information, why is 1 base change likely and 2 base change not? -- what is Lamarck theory? Darwin theory? -- what did delbruck and luria mainly do? -- what is a selection assay?

p, q=1-p -- p^k * q(n-k) -- binomial coefficient -- binomal coefficient * p^k * q(n-k) = P(k;n,p) or the probability of observing k successful events with a probability p in n trials -- <k> = Σ k * P(k;n,p) = n * p <(k-<k>)^2> = n * p * (1-p) σk = sqrt(n * p * (1-p)) - apply the law of motion x(n)=[k-(n-k)] * delta =(2k-n) * delta where k is the step up and (n-k) is step down; this equation means the combined displacement is the sum of all the steps up (k) minus the sum of all steps down (n − k) Thus... the distribution of the positions is given by the distribution over the number of "successes" k. <x(n)>= Σ 1/N xi(n)= (2<k>-n) * delta where k is the expectation of the binomial distribution and thus <k>= n * p thus <x(n)>= ( 2 * n * p -n) * delta = (2 * p -1) * n * delta when p=0.5 <x(n)>=0 -- apply equation <x(n)>= (2 * p -1) * n * delta if probability p of a step up is 0.6 and delta = 1: <x(n)>=(2(6/10)-1) * n = 1/5 (n) The average distance of the particles will grow linearly with time (#) from the initial position -- P(k;10,1/6) where k is number of success (outcomes =face "6" n=10 rolls p=1/6 (fair die) apply <k> =n * p = 10/6 = 1.66 -- first determine the probability that one cell get infect 1/number of T cells = 10^-5 (P) this is from the fact if you have one cell, a singular virus cells need to pick that one cell over 100,000. it is like for each possible virus infection, a cell flips a coin that has a probability of 10-5 of landing on its heads. When it does, the cell gets infected by the virus. number of trials (possible infection) by pool of virus is 3x10^5 (N) so we have a scenario where extreme coin-flip scenario with a very small probability of success but a large number of trials. as each virus can indiivula try and affect that one cell. in this case tho the binomial distrubtion breaks since for very large number of trials, n! becomes too large to be computed. this is perfect for the poisson dis. as P->0 and n-> infinity with n and p remaining finite in this case, we just need the mean number of success, which is represent by mu= n * p =3 -- lim (n-> inf, p->0) P(k;n,p)= 1/k! * mu^k * e^-mu prob of observing k events when expected number of events is mu -- 1. The event can be counted in whole numbers; 2. It is possible to count how many successful events have occurred but it is meaningless to ask how many events have not occurred; 3. Individual occurrences are independent, so that one occurrence neither diminishes nor increases the chance of another; 4. The average frequency of occurrence is known (mu). -- mu mu sqrt (mu) -- 1/0! (0.3)^0 e^-.3=0.74 =.22 =.033 -- (10^4 1) x 3 = 3 10^4 for 1 point mutation since 3 nucleotide are possible at each position (10^4 2) x 9 = 4.5 10^8 since 3 nucleotide are possible in each position totaling 9 different combo -- Expected number of mutants with 1 base change: 10^7x0.22=2 106 =2 106/3 10^4 is close to 1 so almost guaranteed to have base change Expected number of mutants with 2 base changes: 107x0.03=3 105 3 105/4.5 10 ^8 = 6.6 10^-4, unlikely to happen -- giraffes inherited long necks from short necked ancestor who continually stretched their necks to reach food Organisms actively create heritable changes in response to environmental challenges. long necked and short necked giraffes once exist together, but long neck giraffes had adaptive advantage Heritable changes in organisms arise spontaneously -- 1. Lay out the two competing hypotheses in a common experimental framework 2. Define testable quantitative predictions -- suspension of bacterial cell suspension spread on petri plate with agar incubate for 2 days visible colonies (each a clone of corresponding single cell) selective plates contain antibodies or phage L1

write the snail and rabbit version for this problem. 100,000 T-cells 300,000 viruses that can infect each cell. One virus can only infect one cell. A cell can be infected by more than 1 virus. include predicted and calculated plot the results

p_infection=1e-5; number_viruses=3e4; number_trials=100; % p_infection=1e-5; % number_viruses=3e5; % number_trials=1000; result_stat=zeros(number_trials,1); for i=1:number_trials % Plot message every time the trial number is a multiple of 10 if mod(i,10)==0 disp(['Current trial number: ',num2str(i)]) end for j=1:number_viruses if rand<p_infection; result_stat(i)=result_stat(i)+1; end end end %%% Rabbit version for i=1:number_trials rand_vector=rand(number_viruses,1); result_stat(i)=XXX((rand_vector<p_infection)); end k_range=0:1:10; mu=p_infection*number_viruses; result_theory=zeros(length(k_range),1); for k=k_range result_theory(k+1)=(1/factorial(k))*((mu^k)*exp(-mu)); end result_theory close all histogram(result_stat,0:1:10,'Normalization','probability') hold on plot(0.5:1:10.5,result_theory,'r*') ylabel('Probability') xlabel('Number of infections') box off

what is the point of these following codes/under how it is run. prob_dists=zeros(3,51); prob_success=0.5; N_step=[5 10 50]; for j=1:length(N_step) for i=0:N_step(j) prob_dists(j,i+1)=binopdf(i,N_step(j),prob_success); end end clf plot(0:1:N_step(3),prob_dists(1,:),'LineWidth',3) hold on plot(0:1:N_step(3),prob_dists(2,:),'g','LineWidth',3) plot(0:1:N_step(3),prob_dists(3,:),'r','LineWidth',3) legend('n=5','n=10','n=50') ylabel('Probability') xlabel('Number of successes (k)') set(gca, 'FontSize', 20) box off what does binopdf(k,n,p) do? - N_step=[5 10 50]; v_mean_k=N_step*prob_success; v_std_k=sqrt(N_step*prob_success*(1-prob_success)); k_common_range=(0:1:N_step(3)); for i=1:3 k_rescaled(i,:)=(k_common_range-v_mean_k(i))/v_std_k(i); end clf plot((0:1:N_step(3)),k_rescaled) xlabel('Original values of k') ylabel('Rescaled values of k (i.e. x)') legend('n=5','n=10','n=50') title('Rescaled values of the random variable k') - for i=1:3 y_scaling_factor(i)=max(prob_dists(3,:))./max(prob_dists(i,:)); end clf plot(k_rescaled(1,:),y_scaling_factor(1)*prob_dists(1,:),'b','LineWidth',3) xlim([-4 4]) ylabel('Probability') xlabel('Rescaled number of successes (k-\mu_k)/\sigma_k') set(gca, 'FontSize', 20) box off - hold on plot(k_rescaled(2,:),y_scaling_factor(2)*prob_dists(2,:),'g','LineWidth',3) plot(k_rescaled(3,:),y_scaling_factor(3)*prob_dists(3,:),'r','LineWidth',3) legend('n=5','n=10','n=50')

prob_dists=zeros(3,51); % 3 Binomial distributions -- prob_success=0.5; N_step=[5 10 50]; % 3 different number of trials -- for j=1:length(N_step) for i=0:N_step(j) prob_dists(j,i+1)=binopdf(i,N_step(j),prob_success); end end % Plotting the 3 Bionomial distributions clf -- plot(0:1:N_step(3),prob_dists(1,:),'LineWidth',3) hold on plot(0:1:N_step(3),prob_dists(2,:),'g','LineWidth',3) plot(0:1:N_step(3),prob_dists(3,:),'r','LineWidth',3) legend('n=5','n=10','n=50') ylabel('Probability') xlabel('Number of successes (k)') set(gca, 'FontSize', 20) box off % Observation: everything looks fine! *Generate the binomial distributions for the number of steps made toward one direction corresponding to different number of trials (N_step: 5, 10 and 50).* -- prob. distribution of b_d ---- \% Change of variables to remap the 3 distributions based on their % respective means and standard deviations -- N_step=[5 10 50]; % 3 different number of trials -- v_mean_k=N_step*prob_success; % compute vector with means based on property of a Binomial distribution -- v_std_k=sqrt(N_step*prob_success*(1-prob_success)); % compute vector with standard deviation -- k_common_range=(0:1:N_step(3)); % vector with 0 -> 50 -- for i=1:3 % index refers to each of the 3 Binomial distributions -- k_rescaled(i,:)=(k_common_range-v_mean_k(i))/v_std_k(i); end clf plot((0:1:N_step(3)),k_rescaled) xlabel('Original values of k') ylabel('Rescaled values of k (i.e. x)') legend('n=5','n=10','n=50') title('Rescaled values of the random variable k') *Replotting the binomial distribution upon a change of variable* ------ % Computing the scaling factors to normalize the maximum of the 3 different probability % distribution functions % Normalize all distributions with respect to condition N_step=50 -- for i=1:3 y_scaling_factor(i)=max(prob_dists(3,:))./max(prob_dists(i,:)); end -- % to ensure that re-defined probability density functions sum to 1 %%% Plot noramized pdf as a function of the rescaled k series -- clf plot(k_rescaled(1,:),y_scaling_factor(1)*prob_dists(1,:),'b','LineWidth',3) xlim([-4 4]) ylabel('Probability') xlabel('Rescaled number of successes (k-\mu_k)/\sigma_k') set(gca, 'FontSize', 20) box off ------ hold on plot(k_rescaled(2,:),y_scaling_factor(2)*prob_dists(2,:),'g','LineWidth',3) plot(k_rescaled(3,:),y_scaling_factor(3)*prob_dists(3,:),'r','LineWidth',3) legend('n=5','n=10','n=50')

write the Matlab code simulating a large number of coin flips (each trial being 20 flips) (C(n,r)=n!(n−r)!r!) explain that code.' how do we streamline this code?

prob_tail=0.5; number_draw=10000; array_cflip=zeros(number_draw,20); for i=1:number_draw for j=1:20 rnd_number_tmp=rand; if rnd_number_tmp <= prob_tail array_cflip(i,j)=1; else array_cflip(i,j)=0; end end end frac_cflip=zeros(21,1); for i=1:number_draw index=sum(array_cflip(i,:))+1; frac_cflip(index)=frac_cflip(index)+1; end frac_cflip=frac_cflip/number_draw; frac_cflip_predicted=zeros(21,1); for i=1:21 frac_cflip_predicted(i)=((1/2)^20) x factorial(20)/(factorial(20-(i-1)) x factorial(i-1)); end close all figure bar(0:20,frac_cflip); hold on plot(0:20,frac_cflip_predicted,'*r'); hold off legend('Simulated distribution','Predicted distribution') xlabel('Number of Tails') ylabel('Frequency/Probability') -- % initial values prob_tail=0.5; % Probability of observing a tail for each coin flip. Value 0.5 corresponds to a fair coin. -- number_draw=10000; % Total number of draws considered. Vary this value from 100 to 10000. Each draw consists in 20 coin flips. -- array_cflip=zeros(number_draw,20); % Array containing the results of the draws. Each draw is associated with 20 coin flips. % Main for loop simulating the draws. for i=1:number_draw % First loop on the individual draws. -- for j=1:20 % Second loop simulating the 20 coin flips associated with a single draw. -- rnd_number_tmp=rand; % Pick a random number between 0 and 1. -- if rnd_number_tmp <= prob_tail % Define whether this random number is smaller or equal to prob_tail. -- array_cflip(i,j)=1; % If the previous condition is verified, the result of the flip is a tail. else -- array_cflip(i,j)=0; % Otherwise the result of the flip is a head. -- end end end % Calculate the fraction of draws with a given number of tails -- frac_cflip=zeros(21,1); % note that you should take state 0000...0 into account -- for i=1:number_draw index=sum(array_cflip(i,:))+1; %sum the value of the entire row, offset with 1 since first element of frac_cflip represents 0 tails -- frac_cflip(index)=frac_cflip(index)+1; end % Normalize the counts to convert them into fractions. frac_cflip=frac_cflip/number_draw; -- % Computed the expected (theoretical) probabilities from the bionomial distribution. frac_cflip_predicted=zeros(21,1); for i=1:21 -- frac_cflip_predicted(i)=((1/2)^20) * factorial(20)/(factorial(20-(i-1))*factorial(i-1)); end -- % Plot result as a bar for the simulated results and as points for the % predicted value using the bionomial distribution. close all figure -- bar(0:20,frac_cflip); % Simulated distribution hold on -- plot(0:20,frac_cflip_predicted,'*r'); % Predicted distribution hold off legend('Simulated distribution','Predicted distribution') xlabel('Number of Tails') ylabel('Frequency/Probability')

what is a moment? what is the 0th moment? what is the 1st moment? what its the 2nd moment? describe an equation that would map the mean displacement after a large number of n steps where do particles go on average? how much to particles spread over time? label the two predication on graph. What is the number of outcomes leading to exactly two tails in 4 consecutive coin flips? how do you find the number of possible outcomes? what is the binomial coefficient? what are the criteria for Bernoulli trial? what is the probability of observing k tails given 4 coin flips? what is the probability of observing k tail given n coin flips? What is this called? from this obtain uK, and Var k and σk what is the probability that two daughter cells inherit from exactly 5 GFP molecules coming from mother cell of 10 GFP? What is the probability of finding a particle 𝑘 steps above (up) the initial position after 𝑛 steps? if you have two mutually exclusive things and one has a probability P, there will be another probability of that thing not working _.

quantitative measure of the shape of a distribution -- Σall k P(K)=1 -- <k> or k bar or uK= Σ (all k) k * P(k) other wise known as the mean or expected value of distribution -- var(k) or σk^2 or <(k-uK)^2= Σ(all k) [(k-uk)^2 * P(x)] OTHERWISE known as variance -- given that Position of the I(th) particle after nth step: is Xi (n) law of motion: Xi(0)=0; Xi(n)=Xi(n-1) + or - delta thus the <x(n)>= Σ (I=1) 1/N xi(n) where 1/N is the frequency of each outcome and Xi(n) is individual outcomes -- <x(n)>= Σ (I=1) 1/N xi(n) = 1/N Σ (I=1) (Xi(n-1) + or - delta) =1/N Σ (I=1) (Xi(n-1) + 1/N Σ (I=1) (+ or - delta) note that the term 1/N Σ (I=1) (+ or - delta) is zero theprobabilitiesof left and right steps on left are equal; number of left and right steps must be equal on average = 1/N Σ (I=1) (Xi(n-1) conclusion: <x(n)>=<x(n-1)>=<x(0)>=0; mean position of particles remains equal to zero -- The root-mean-square displacement (standard deviation) increases as the square root of the number of steps (time) or sqrt(<x^2(n)>)= sqrt(n) * delta -- see graph. - 6 (# of outcomes of each flip)^(n number of coin flips) - ( 4 k)= 4!/k!(4-k)! where 4 could be 2 3 5 6... -- 2 mutually exclusive outcomes (success or failure) probability of success are failure do not change independent trials -- p(K)= # of outcomes with k tails/total number of possible outcomes = ( 4 k)= 4!/k!(4-k)! / 2^4 -- p(k;n;1/2)= 1/2^n * n!/k!(n-k)! where k is # of success, n is number of trial and 1/2 is probability of individual success; binomial distribution -- n/2 n/4 (variance) σk= sqrt(var k) = sqrt(N)/2 SD --- P(5;10;1/2) -- p(k;n;1/2)= 1/2^n * n!/k!(n-k)! -- 1-P

for the distance = rate x time, we can rearrange to have delta x/delta t= v, and if we take the limit, we get dx/dt=v what does this tell us? If given v(t) and we want to find x(t), what do we need first? Describe a cute of coffee ODE. why is this a good equation? in Matlab, what must we specify for ODE?

rate of change of the position is equal to the velocity the initaal condition x(0) we are interested in how fast it cools down for a cup of coffee where T is the temperature of the coffee and Ta is the ambient temperature and k is some positive constant of the coffee cups, the equation dT/dt=-k(T-Ta) describe the rate of the change with temperature with respect to time. we are interested in solving for temperature as a function of time. this is a good equation because if T>Ta, T-Ta>0 -k(T-Ta)<0 dT/dt<0 therefore the temperature is decreasing which is what we expect, hot cup of coffee is decreasing in temprateru if cold beverage (cooler than ambient) T<Ta T-Ta<0 -k(T-Ta)>0 dT/dt>0 therefore the temperature is increasing t(0) = some number

what does the agar plate look like in Darwin? in Lamarck? given Probability acquiring resistance: 2.5 10-9 /replication and Number of bacteria that are replicating: 2.108 Which probabilistic model will you use to calculate the probability of obtaining ! number of antibiotics resistant mutants? A: PBinomial (m;n 2.101, p = 2.5 1056 B: P Poisson (m; mu= 2.5 10-9) C: 2.510-6 ×2.10 8 =0.5 D: pPoisson (m; mu = 0.5) Something in this graph puzzled Luria and Delbruck for several months. Can you see what it is? A: The negative exponential nature of the distribution B: The fact that the distribution wasn't bell-shaped C: Strong evidence suggesting that their results were probably due to a contamination D: The low number of resistant colonies they observed describe the graph in the previous step. for the poisson distribution, what happens when you increase mu? What is the probability of observing 9 phage-resistant colonies? if mu=1 What is the probability of observing more than 9 phage-resistant colonies? what is the conclusion from the past two questions? explain why the Lamarck view will produce less amount of cells while the Darwin view can produce more cells give # of bacteria in Darwin exp is 10^5, calculate mu and the poisson distribution for 1 infection. given # of bacteria is 2 10^8, calculate passion distrubtion for 1. probabiyt of acquiring resistance is 2.5 10^9 interpret these results list the alg. that is general for Darwin and Lamarck processes. how many replication take place between t=0 and t= tf? what is the probability that a resistant strain appears at time t( Darwin model)? what is the point of poissrnd(mu)? what is mu? what is the solution we get from the Lamarck model? what is the algorithm for darwinian model? give 3 characteristics of the darwinian view that related to the algorithm. what is the core of the algorithm that keeps track of two population of cell in Darwin model? what are the 3 conclusions of the lurid delbruck experiments?

resistance spontaneously acquired in culture -> there will be alot more cells on Darwin plate resistance acquired while being challenged on the antibiotics plate alot less cells in Lamarck plate -- C -- C -- Poisson distribution looking like a negative exponential Each cell will acquire resistance with a low probability but the number of cells is very large -- the graph shift rightwards for the number of successes -- p(m;u) -> P(9;1)= 1/9! 1^9 e^-1 = 10^-6 or REALLY SMALL - Σ p(m;1) = 1.1 10^-6 -- Unless millions of plates were assayed, observing a large number of colonies is incompatible with a Poisson distribution. But only 87 plates were assayed by Luria-Delbruck in their original experiment... -- the challenge occurs at the plate; Very few resistant colonies expected. Distribution given by Poisson distribution vs there is spontaneous mutation, if happen earlier on in the replication, all the cells after will have the resistance. when plated, there will be alot of cells -- 2.5 10^4 .3 -- very low probability of being infected for Darwin but if infect will produced alot of cells; thats why the whole plate isn't full of cells fairly high probability of infection of 1, which is why you see cells, but it stops there, cannot multiple; No mutation possible in absence of challenge -- 1. Start of each trial (t = 0): ~150 nonresistant cells 2. End of each trial (t = tf): estimated bacterial population 2.4 108 cells 3. Population challenged by the phage (or antibiotics) at time t=tf 4. The probability that a cell acquires resistance is: p =2.5 10-9 -- 2^g= n(tf)/n(0) -> g= log2 (2.4 10^8/150)= 21 -- Current number of bacteria in the culture: n(T)= 150 * 2^t expected number of mutants: mu(t)=n(t) * p = n(t) * 2.5 10^-9 prob. of observing m mutants: P(m; mu(t))= 1/m! mu(t)^m * e^ -mu(t) -- for each suspension of culture medium (trial), we aim to generate a random number that simulates the outcome of a Poisson distribution. mu=2.4 10^8 x 2.5 10^-9 = 0.6 -- The probability of observing more than 9 resistant colonies is nearly equal to 0 under this probabilistic model. The experimental results are not compatible with a directed mutation (Lamarckian) model.' -- 1. Start of each trial (t = 0): ~150 nonresistant bacteria 2. One trial corresponds to 21 cell duplications (mitosis) 3. The probability that a cell acquires resistance during each mitosis p =2.5 10-9 -- i. Cell divisions are synchronized. They proceed according to discrete time steps like the particles of the random walks. ii. At each division, each cell has a very low (yet non-negligible) probability p=2.5 10-9 of undergoing a mutation that renders its daughter cell resistant. iii. The number of resistant individuals arising after one synchronized round of divisions is a Poisson-distributed random variable. The expected value (mean) of the random variable is proportional to the total population of bacteria prior to a division (factor n in mu=n * p). -- Two variables describing the population of bacteria: Nwild — number of wild-type non-resistant bacteria Nmutant- number of resistant bacteria set initial condition to t=0 Nwild=150 Nmutant(0)=0 synchronized reps will occur where it will look something like this Nwild(0) Nmutant(0) Nwild(1) Nmutant(1) Nwild(2) Nmutant(2) Nwild(3) Nmutant(3) ... Nwild(21) Nmutant(21) ACTUAL IMPLEMENTATION Nwild(1)=2.Nwild(0) -n(1) Nmutant(1)=n(1) N(1) represent newborn resistant cells NEXT CYCLE... Nwild(2)=2.Nwild(1) -n(2) Nmutant(2)=2.Nmutant(1) +n(2) -- 1. Bacteriophage and antibiotics resistance is the result of spontaneous mutations, not the exposure to the survival challenge itself. A similar mechanism underlie viral evolution, like in a single HIV patient. 2. The mutation rate are very low: p<10^-8. Luria and Delbrück experiments provides a framework to measure extremely infrequent events. 3. Luria and Delbrück's method consists in reasoning in terms of probabilities. They made probabilistic predictions and inferred the distribution of the outcome of a large number of trials.

write the code for the for loop starting with s=0, and ending with s= 55. explain the code

s=0; for k=1:10 s=s+k; end disp(s) start with s=0 and k is nothing, once hit for loop, Matlab will assign k=1, once it hit equation, Matlab will assign old value of s (0); will produce s=1 end loop around back to K=1:10, now Matlab assigned k=2, once it hit equation, Matlab will assign old value of s (1), will produce 3 end eventually loop around to k=10, assigned old value of s which will produce s=55

do the derivation for the negative sigmoids/ hill function

see lecture

write code for square of 3. all the trig function are in _. if you prefer to use degrees, write the code for that write code for arctan of 1 if z=1+2i, how do we find real part and imaginary part? if you had a graph with imaginary graph, you can find angle relative to real axis by what code? what about how long the line is? what does the abs in code do? if we need help, what kind of code can we type?

sqrt 3 radians sind(90) atan(1) real(z) imag(z) angle(z) abs(z) absolute value; help sin

explain this code (nested loop) for a=10:10:50 a for b=0:0.1:0.2 b disp('Hola mundo') end end create a nested loop what will display in order, 1 1, 1 2, 2 1, 2 2, 3 1, 3 2 x=0; for I=1:5 x(i)=I^2; end what happens?

start with a=10, then b =0 display hola mundo, then b =0.1 display, then b = 0.2 display, then end. loop back to a, a=20. same as b. for i=1:3 for j=1:2 [i j] end end x=0 is 1x1 matrix x=1 4 9 16 25 this will be inefficient but possible since it doesn't need to

what is the point of these following codes/under how it is run. t_slice=(5+1); subplot(3,1,1),histogram(particle_position_table(t_slice,:),-20:2:20,'Normalization','probability') xlabel('position'),ylabel('probability'),title('Distribution after 5 steps'),ylim([0 0.3]) t_slice=(10+1); subplot(3,1,2),histogram(particle_position_table(t_slice,:),-20:2:20,'Normalization','probability') xlabel('position'),ylabel('probability'),title('Distribution after 10 steps'),ylim([0 0.3]) t_slice=(50+1); subplot(3,1,3),histogram(particle_position_table(t_slice,:),-20:2:20,'Normalization','probability') xlabel('position'),ylabel('probability'),title('Distribution after 50 steps'),ylim([0 0.3]) -- t_slice=(10+1); clf histogram(particle_position_table(t_slice,:),-10.5:1:10.5,'Normalization','probability') xlabel('position'),ylabel('probability'),title('Distribution after 10 steps'),ylim([0 0.3])

t_slice=(5+1); % add 1 since the first index refers to the initial condition -- subplot(3,1,1),histogram(particle_position_table(t_slice,:),-20:2:20,'Normalization','probability') xlabel('position'),ylabel('probability'),title('Distribution after 5 steps'),ylim([0 0.3]) -- % Plot histrogram of positions after 10 steps -- t_slice=(10+1); % add 1 since the first index refers to the initial condition -- subplot(3,1,2),histogram(particle_position_table(t_slice,:),-20:2:20,'Normalization','probability') xlabel('position'),ylabel('probability'),title('Distribution after 10 steps'),ylim([0 0.3]) -- % Plot histrogram of positions after 50 steps -- t_slice=(50+1); % add 1 since the first index refers to the initial condition -- subplot(3,1,3),histogram(particle_position_table(t_slice,:),-20:2:20,'Normalization','probability') xlabel('position'),ylabel('probability'),title('Distribution after 50 steps'),ylim([0 0.3]) *Plot distribution of positions at different time points:* ----- figure -- % Plot histrogram of positions after 10 steps -- t_slice=(10+1); % add 1 since the first index refers to the initial condition -- clf % clear previous plot -- histogram(particle_position_table(t_slice,:),-10.5:1:10.5,'Normalization','probability') xlabel('position'),ylabel('probability'),title('Distribution after 10 steps'),ylim([0 0.3]) *plot the distribution over the position for the time slice t=10 steps with a histogram bin size of 1 instead of 2.* --

create a 5 by 1 column vector of zeros. given vector a = [1 2 3; 4 5 6; 7 8 10], add 10 to each number in the vector. take the sine of each number in vector. transpose the matrix a perform matrix multiplication on a by multiplying by its inverse. display more decimal digit to the previous question display less decimal digits. perform element wise multiplication on a. do the same for division and power.

z = zeros(5,1) z = 5×1 0 0 0 0 0 a+10 sin(a) a' p=a*inv(a) format long p = a*inv(a) format short p = a.*a a.^3 ans = 3×3 1 8 27 64 125 216 343 512 1000 a./a

Explain the regulatory algorithm behind the function of a thermostat give a geometrical description of the system give a mathematical description of the system are all steady state stable? when is a steady state stable? unstable? write out the model for mRNA production using constant and first order terms. what happens if we add transcription rate? given the logic system on slide 20, what is the update rule on x? what is the table? for repression, for the binding of DNA, what are the two important equation? what is the equation for the transcription rate of DNA? for repression, for the binding of DNA and dissociation from DNA, what is the rate? if given the p(unbound at t=0)=1 (100% start unbound) (meaning..?), what is p(bound at t=delta t)? if given p(bound at t=0)=1, what is P(unbound at t=delta t)? calc. probability of being in bound state at time t=delta t: P(bound at t=delta t) in terms of p bound now that we have P(bound at t=delta t) in terms of p bound, let us say the P(bound) become time indepeent at SS. lets assume that SS is reached for large T >>1. what can you infer about the relationship between P(bound at T+delta t) and P(bound at T) at SS? what can be derived from this? what are the steady state probability? describe the noncooperative binding curve in terms of our derivation that we just did. describe how most trans. factor act like dimers? Can you write the ODE describing the dynamics of the monomer r undergoing dimerization? at SS, what does it mean when you isolate r2? what is the assumption in the cooperative binding model? what happens when kd is higher in cooperative model? what does the comparison of noncooperative and cooperative case look like? for higher order cooperative binding curve, what is the steeples and inflection point defined by? how do we apply all this to the paper?

temperature set point -> current time> temp set point -> cold air is injected with fixed flow of hot air -> room temp is decreased -> temperature set point TSP-> current temp < temp set point -> less cold air added to hot air -> room temp increases -> TSP -- flux of hot air is constant while flux of cold air is increase over axis of y (flux of injected air stream) and x (temp). there is a set temperature where the two flux meet. (reference the lecture on ones side...flow hot>flow cold on other side...flow hot <flow cold -- x(t) is temperature as a function of time dx(t)/dt=yhot (constant flux of hot air) -kcold(x(t)-x) (variable flux of cold air) (that symbol is the delta x difference between current temperature and TSP gives us a combo of dx(t)/dt=(yhot+kcold.x)-kcoldx(t) =y-kx(t) -- we could have a well, that would be stable steady state or we could have a saddle, unstable steady state (slight perturbation will cause it to fall) -- A steady state is stable when the system tends to return to this state upon small perturbations: x^st + δx(t) -> x^st • A steady state is unstable when small perturbation will grow over time and draw the system away from the steady state. -- 0 -(y)-> c(t) -(-kc(t))-> 0 activator (a) of transcription will have f(a(t)), repressor r will have f'(r(t)) (see lecture)). -- x(t+1)=y(t) & ~z(t) see lecture -- DNA+2r <->DNA::r2 (bound) Kd=koff/kon -- y(r)=ymax*1/1+(r/Kd)^n -- Kon.r(t) (all molecules have same probability of binding, thats why you have to multiple all the molecules by Kon rate:Koff (only 1 molecules falls off -- transcription is active, binding site unoccupied delta t is after small time step; means that State of the promotor: BOUND (binding site occupied) — transcription is blocked Kon.r(t).deltat -- koff delta t -- P(bound at t=delta t)= P(bound at t=delta t & unbound at t=0) + P(bound at t=delta t & bound at t=0) see lecture slide for derivation and final result -- at high amounts of T, the probably of being bound with T now versus then will be the same, equal, no change see lecture for full derivation to get the binding function which is probably of find the promoter in bound state at SS -- see lecture -- previously, we saw that y(t)=ymax.p^st(unbound). p^st can be sub. for the derived term. the larger the value of Kd, the higher the prbaibliy that the promoter remains in a state that permits transpcriton -- two thing comes together and then they bind to DNA binding site -- dr/dt=-2.kr.r.r + 2.lr.r2 (first part MAR rule, 2 is b/c you lose 2 momonors (thats why negative) ) (second part is the opposite) -- at steady state the concentration of the dimer is proportional to the square of the concentration of the monomer (see lecture for derivation) -- Assumptions: (1) only dimers bind the promoter (2) the dimerization of the repressor molecules takes place on a timescale that is faster than the interactions between the repressor dimers and the promoter (see lecture for derivation); much harder to unbind -- see lecture

explain ODE for hot/cold coffee, mass on spring circuit A+B<->C ODE is the relationship between what two things? what is the notion of a derivate

the solving of the ODE tells us the shape of the Temperature versus time curve for hot going to cold the solving of ODE tells us the shape of the position versus function of time for spring the solving of ODE will give us the shape of the current as function of time the solving of ODE can give the shape of the concentration as function of time graph unknown function x(t) and its derivate Dx/dt we want to know the slope of a tangent at a particular point (like a) so we take the limit as B tend to A lim b->a of x(b)-x(a)/b-a which is the derivate of x'(a) which is dx/dt

Write the code that will simulate the evolution of a population of interacting prey and predators. given time is over a span of 10 years. you start off with 200 of animal 1. 60 of animal 2. the diffeq for animal 1 are dx/dt=4x-(1/10)xy. animal 2 is dy/dt=-2y+1/50(xy) (explain this diffeq)

time_step=1/365; total_number_steps=365*10; x=zeros(total_number_steps,1); y=zeros(total_number_steps,1); t=zeros(total_number_steps,1); x(1)=200; y(1)=60; t(1)=0; for i=2:total_number_steps dx=4*x(i-1)-(y(i-1)*x(i-1)/10); dy=-2*y(i-1)+(y(i-1)*x(i-1)/50); x(i)=x(i-1)+dx*time_step; y(i)=y(i-1)+dy*time_step; t(i)=t(i-1)+time_step; end close all figure plot(t,x,'b',t,y,'r'); xlabel('Time (years)') ylabel('Population') legend('Rabbits','Foxes') figure plot(x,y) xlabel('Rabbit population') ylabel('Fox population') dx/dt=4x-(1/10)xy (4x part is reproduction rate of rabbits) the latter is predation rate dy/dt=-2y+1/50(xy) beginning part is reproduction rate condition on predation latter is natural turnover rate

Explain the code that will simulate the evolution of a population of interacting prey and predators

time_step=1/365; % Time step used to integrate the interactions of the prey-predator dynamics. This step is exressed in year unit. -- total_number_steps=365*10; % Given that the time step is one year, each step corresponds to a single day. -- % initial values x=zeros(total_number_steps,1); % We define x as the population of preys, say a colony of gentle rabbits in a remote island. -- y=zeros(total_number_steps,1); % We define y as the population of predtors, say voracious foxes on the same island as the rabbits. -- t=zeros(total_number_steps,1); % Time vectors associated with the simulated dynamics. -- x(1)=200; % Initial population of rabbits. y(1)=60; % Initial population of foxes. t(1)=0; % Initial time point (arbitrary). -- for i=2:total_number_steps dx=4*x(i-1)-(y(i-1)*x(i-1)/10); % Annual rate of change of the population of rabbits. -- dy=-2*y(i-1)+(y(i-1)*x(i-1)/50); % Annual rate of change of the population of foxes. -- x(i)=x(i-1)+dx*time_step; % Update of the population of rabbits for each time step (daily change). -- y(i)=y(i-1)+dy*time_step; % Update of the population of foxes for each time step (daily change). -- t(i)=t(i-1)+time_step; % Time vector in time_step units (days in the present example) end -- % Plot the time course of the populations of rabbits and foxes close all figure plot(t,x,'b',t,y,'r'); xlabel('Time (years)') ylabel('Population') legend('Rabbits','Foxes') -- % Plot the evolution of the population of rabbits against the population of foxes figure plot(x,y) xlabel('Rabbit population') ylabel('Fox population')

why is the limit x->0 needed? from the equation df/dx(x~)=lim (delta X->0) f(x(~)+delta x)-f(x~)/ delta X; isolate the f(x~+delta x). Explain the isolated parts. now with this information, how would you bring a derivative back to its primitive? what is the goal of the numerical integration Strat? what formula does it apply? what is given? what are the steps? derive the equation for viral growth what is the general solution to the ODE? what is the expected dynamics of the ODE? what is the derivative of N(t)=Co*e^-kt? take the integral of ∫ (t) e^-αs ds take the integral of ∫ (t) 1/s ds? what observation can be drawn from bacterial growth?; describe it mathematically. from N(t+Δt)=N(t)+γ*N(t)*Δt, get dN/dt=γ*N(t). solve dN/dt=γ*N(t) for bacterial growth. what is the more realistic model for bacterial growth? what is an ODE Why are ODEs important in describing biological systems? What is the difference between analytical and numerical approaches to solving ODEs? -- Can any ODE be "easily" solved analytically? -- What is Euler's method to numerically integrate an ODE and how does it work? Why is the precision of Euler's method sensitive to the size of the time step used in the finite integration procedure?

to avoid accident -- f(x+delta x)= f(x)+df/dx(x)*delta x -- f(x) is the inital y value df/dx(x)*delta x represented the PREDICT change in the y value to go to another y value which is f(x+delta x). notice that delta x is the step size and remains constant. For each step size, the slope will change which will change the value of y. Thus, the slope constantly change for each step size, leading to a different value of y every time. This can be made more accurate by having a smaller step size. -- starting from y1=f(x1), do linear approximation +df/dx(x1)*Δx +df/dx(x2)*Δx +df/dx(x3)*Δx +df/dx(x4)*Δx all the way until y5=f(x5) then Σdf/dx(Δx) to get f(x5)=f(x1)+Σdf/dx(Δx) then we make the step size of x super small (lim Δx->0) to get best appox. to get f(x5)-f(x1)=∫ (x5;x1)df/dx(dx) -- define f(x) between xi and xf -- f(x+delta x)= f(x)+df/dx(x)*delta x - df/dx=g(x) lower bound is xi higher bound is xf inital condition f(xi) number integration step: N step - start with inital condition x=xi define the step size which is Δx=(xf-xi)/Nstep apply approx formula and get the new y value. use the next step x+Δx value to apply the approx formula again for N step. - Given a present viral population N(t) and a inflow form resevior of virus γ*Δt where γ represent a constant for influx. the future viral population will be denoted by N(t+Δt) (the virus population a time away from t). therefore N(t+Δt)=N(t)+γ*Δt N(t+Δt)-N(t)=γ*Δt N(t+Δt)-N(t) represent the y portion of the slope of the secant line therefore ΔN=γ*Δt ΔN/Δt=γ reminder that lim t->0 of Δt= dt lim t->0 of N(t+Δt)-N(t) is dN dN/dt=γ -- dN=γ*dt (small changes in number of molecules at time t) ∫ (N(t);No) dN(t)=∫(t;0)γ*dt (sum over all small change in number of molecules between time t0 and t N(t)-No=γ*(t-0) N(t)=γ*t+No (A FUNCTION) -- the number of virus will grow linearly with time -- -k*Co*e^-kt -- =-e^-αt/α +C -- =ln(t)+C -- the relative change in cell number (growth) remains the same at every replication step even though the number of cells grows exponentially! N(t+Δt)=N(t)+γ*N(t)*Δt N(t+Δt)-N(t)=γ*N(t)*Δt N(t+Δt)-N(t)/Δt=γ*N(t) N(t+Δt)-N(t)/Δt * 1/N(t)=y as expected, the relative change in number of bacteria is constant over time -- N(t+Δt)=N(t)+γ*N(t)*Δt N(t+Δt)-N(t)=γ*N(t)*Δt (N(t+Δt)-N(t))/Δt=γ*N(t) lim (t->0) (N(t+Δt)-N(t))/Δt)=lim (t->0) γ*N(t) dN/dt=γ*N(t) -- dN/dt=γ*N(t) dN/N=γ*dt ∫(N(t);N0) dN/N=∫(t;t0)γ*dt ln(N(t))-ln(N(t0))=γ*(t-t0) for t0=0 ln(N(t))=ln(N0)+γ*t N(t)=e^ln(N0)+γ*t N(t)=N0*e^γ*t -- an constant influx γ combined with a degradation rate k. - a differential equation (math function relating some function and derivates) containing one or more functions of one independent variable and the derivatives of those functions. - because they can relate many rates of change at the same time(?) -- ?? -- ?? -- you take your current y value, and then you add your change in y value which is change in x multiple be the slope of the current x and y value to get a NEW y value. y1=y0+deltax time y'.... y2=y1+ delta x times y' the smaller the x, the better the slope will be to predict the new y value

What is the Aim of system bio? what is an algorithm? apply this to fish what is an emergent property? define it in ants. can you start a variable using a number?

to model and discover emergent properties, properties of cells, tissues and organisms functioning as a system. basic set of rules 1. A fish avoids colliding with its neighbors; 2. A fish will tend to move in the same direction as its neighbors; 3. A fish aims to remain close to its neighbors. An emergent property is a property which a collection or complex system has, but which the individual members do not have. AKA collective intelligence ants can form bridges no

Write a script starting with x=9 and ending with x equaling 11. explain how Matlab processes this. write a script starting with x=10 and y=4, end with X equal 14 and Y being 12. explain how Matlab processes this. x=4 x=x-2 Question: Consider the commands above. Which statement do you think is correct about the result of these commands? A) The value of x will be equal to 4. B) Matlab will bug: it will send an error message in red because x cannot be equal to itself minus 2! This would be illogical. C) The value of x will be equal to 2. D) Matlab will assign a random value to x because it has not been previously defined.

x=9; x=x+2; disp(x) locker with label x, put 9. x=x+2 means open that locker, take the 9 out, add 2, and then put it back in. that's why we see 11. x=10 y=4 x=x+y y=12 disp(x) x=10 (locker 1) y=4 (locker 2), x=x+y, open the lockers and take out both and add them, put them back into x locker. y=12, put 12 into y locker. C

write Matlab code simulating the outcome of a lottery where the probability that an individual wins is very low. The code illustrates that this process can be approximated by a Poisson distribution. (e^-μ) (μ^x) / x! -- explain this code -- given Randi(10000,1,25000) y=ans==winner_number %you will see whether each individual players has won sum(y) =1 % there is one winner how do we incorporate this into the code?

total_choice=10000; p_success=1/total_choice; number_player=25000; number_trial=1000; number_winner=zeros(number_trial,1); for t=1:number_trial winner_number=randi(total_choice); for i=1:number_player rnd_number_tmp=randi(total_choice); if rnd_number_tmp == winner_number number_winner(t)=number_winner(t)+1; end end if mod(t,100)==0 display(['Current number of trials: ' num2str(t)]) end end mu=p_success*number_player; prob_Poisson=zeros(1,21); for k=0:20 prob_Poisson(k+1)=(1/factorial(k))*exp(-mu)*mu^(k); end close all hist_edges=-0.5:1:20.5; histogram(number_winner,hist_edges,'normalization','probability'); hold on plot(0:20,prob_Poisson,'*r') hold off legend('Simulated distribution','Predicted Poisson distribution') xlabel('Number of Winners') ylabel('Probability') -- % UNIVERSITY LOTTERY total_choice=10000; % Total number of possible choices of the lottery. Try the following values: 1000, 10000 and 100000 -- p_success=1/total_choice; % Probability of winning per individual. -- number_player=25000; % Approximate number of students at UCSB: 25,000 students -- number_trial=1000; % Fictive number of lottery trials considered to computer the statistics of the number of winners. -- number_winner=zeros(number_trial,1); % Number of winners observed for each lottery trial. -- for t=1:number_trial winner_number=randi(total_choice); % For each of the lottery trial, define the winner number from a flat distribution between 0 and total_number. -- for i=1:number_player rnd_number_tmp=randi(total_choice); % Random number assigned to each player. -- if rnd_number_tmp == winner_number % Evaluates the equality between the number associated with a given player and the winner number. -- number_winner(t)=number_winner(t)+1; % In case a player has won, update the number of player corresponding to the current trial. end end -- if mod(t,100)==0 % Route introduced to monitor the number of lottery trial that has been implemented. The message included in the display statement will print every 1000 trials. -- display(['Current number of trials: ' num2str(t)]) end end % Generation of the expected number of players predicted from a Poisson distribution mu=p_success*number_player; prob_Poisson=zeros(1,21); -- for k=0:20 % Consider the statistics for up to 20 potential winners. prob_Poisson(k+1)=(1/factorial(k))*exp(-mu)*mu^(k); end % Plot simulated and predicted probabilities close all hist_edges=-0.5:1:20.5; -- histogram(number_winner,hist_edges,'normalization','probability'); hold on plot(0:20,prob_Poisson,'*r') hold off legend('Simulated distribution','Predicted Poisson distribution') xlabel('Number of Winners') ylabel('Probability') -- total_choices=1e4; p_success=1/total_choices; num_players=25000; numtrial=1000; number_winner=zeros(numtrial,1); for i=1:numtrial winner_num=randi(10000); random_num=randi(10000,1,25000); final=sum(random_num==winner_num); number_winner(i)=number_winner(i)+final; end

Write the script to flip a coin and record the number of tails. explain the code

total_number_coin_flips=1000; flip_outcome=zeros(total_number_coin_flips,1); for i=1:total_number_coin_flips current_coin_flip=(rand>0.5); flip_outcome(i)=current_coin_flip; end number_tails=sum(flip_outcome)/total_number_coin_flips % convention about recording of results: % heads = 0; tails = 1 total_number_coin_flips=1000; -- flip_outcome=zeros(total_number_coin_flips,1); % vector with outcome of each flip -- for i=1:total_number_coin_flips current_coin_flip=(rand>0.5); % the outcome will 1 (=tails) if true, 0 (=heads) otherwise -- flip_outcome(i)=current_coin_flip; end -- % Calculate the fraction of tails outcome number_tails=sum(flip_outcome)/total_number_coin_flips

using the 1D random walk code that was previously done, modify it to be more general.

total_number_steps=1000; particle_position=zeros(total_number_steps,1); for current_step_index=2:total_number_steps if (rand<0.5) particle_position(current_step_index)=particle_position(current_step_index-1)-1; else particle_position(current_step_index)=particle_position(current_step_index-1)+1; end end plot(particle_position), xlabel('Time'),ylabel('Position of particle')

write the code for 1D random walk with drift. represent the 5 trajectories analyze position of 1000 particles at specific times.

total_number_steps=1e3; total_number_of_particles=1e3; probability_of_success=0.6; particle_position_table=zeros(total_number_steps+1,total_number_of_particles); particle_position_table contains the trajectory of a given particle for current_particle_index=1:total_number_of_particles for current_step_index=1:total_number_steps if (rand<probability_of_success) particle_position_table(current_step_index+1,current_particle_index)=particle_position_table(current_step_index,current_particle_index)+1; else particle_position_table(current_step_index+1,current_particle_index)=particle_position_table(current_step_index,current_particle_index)-1; end end end -- figure for i=1:5 plot(particle_position_table(:,i)) hold on end xlabel('Time (a.u.)'),ylabel('Position of individual particles') xlim([0 1000]) -- figure histogram_bin_edges=-300:10:300; % vector defining the bin edges subplot(2,2,1) histogram(particle_position_table(1,:),histogram_bin_edges,'Normalization','probability') % note that [-60 60] defines the edges of the histogram xlabel('Distance to starting position'),ylabel('Position densities') title('Distribution of position at time t=0') %%% subplot(2,2,2) histogram(particle_position_table(50,:),histogram_bin_edges,'Normalization','probability') xlabel('Distance to starting position'),ylabel('Position densities') ylim([0 0.5]) title('Distribution of position at time t=50') %%% subplot(2,2,3) histogram(particle_position_table(200,:),histogram_bin_edges,'Normalization','probability') xlabel('Distance to starting position'),ylabel('Position densities') ylim([0 0.5]) title('Distribution of position at time t=200') %%% subplot(2,2,4) histogram(particle_position_table(1000,:),histogram_bin_edges,'Normalization','probability') ylim([0 0.5]) xlabel('Distance to starting position'),ylabel('Position densities') title('Distribution of position at time t=1000')

write a script to plot sine function from 0 to 2pi. label the axis and add title. modify the line with a red dashed line. add a additional cosine function into the scrip. modify the line with points. explain what Matlab thinks when it sees plot(x,sin(x)) what does hold on and hold off do? what does m do in plot(x,y,'m')? what is the alternate to hold on? how do we clear a plot? how do we find information about line specifiers?

x = 0:pi/100:2*pi; y = sin(x); plot(x,y) xlabel('x') ylabel('sin(x)') title('Plot of the Sine Function') plot(x,y,'r--') x = 0:pi/100:2*pi; y = sin(x); plot(x,y) hold on y2 = cos(x); plot(x,y2,':') legend('sin','cos') hold off first argument is a list of x value, second argument is list of y values by default, Matlab will delete a plot if you introduce another plot, hold on prevents Matlab from doing that magenta plot(x,sin(x),'b--',x, cos(x),'m-') clf help plot

what are the assumption for the randomness in cellular processes? what is the problem with the assumption? why isn't the continuous description always reasonable? (PROBLEM: DO EULERS ON THIS) what would be the proposed more realistic way? what is our approach for the above problem? what is our stochastic model for counting molecules? what is the origin or randomness in our stochastic model? what are the assumption for our counting model? what is the framework that comes out of this model? what is the state variable in this model? according to the dx/dt=y-k.x(t), what is the probability of producing mRNA molecule per unit time? What will the probability of degrading a molecule be proportional to? explain the discretized time notion. explain the two avenues that ni can go towards. given p(n(I+1) | n1,...,ni)=, what is the meaning of that? what does it equal? is this result trivial what is the simplified probabilistic model in this case? how do we get to the relative propensity/probability? How similar do you expect the birth-and-death dynamics to be compared to the 1D random walk of a Brownian particle? What are the characteristics of BNP in chemical space? After an initial relaxation dynamics, the birth-and- death process tends to fluctuate around an asymptotic value. Can you predict the value of this asymptotic state? [justify your answer quantitatively] what happens to the asymptotic value n(t) when the values of y or k change? how do you find the asymptotic given dx(t)/dt=y-k.x(t)? how realistic is our stochastic model?

• The number of molecules of the gene product is large enough to be treated as a continuous variable. • Biochemical reactions underlying the control of gene expression can be described by the law of mass- action kinetics (well-mixed system). in that you get the description dx(t)/dt=y-k.x(t) --- a cell isn't quite a well mixed reaction tank --- lets observe dx(t)/dt=y-k.x(t) with y=1, k=0.5, x(0)=0; the graph that will be observed will have 0.5 molecules and 1.5 molecules, which doesn't really make sense. ....? see lecture --- adopt a stochastic description used for the analysis of the motion of molecular motors. -- the state space is the number of mRNA molecules. at time t, we have n(t) mRNA. at time t', we have n(t)+1 (production) or n(t)-1 (degregation) mRNA molecules. in essense, the model that we will follow is a random walk in chemical space. -- 1) nature of reaction occurring at a given time: is a molecules produced or degraded 2) wait times between prodcution and degradation events -- • Production and degradation take place on a discrete time scale with time steps ∆t. • The time step ∆t is small enough that the probability of occurrence of 2 or more reactions is so low that it is negligible. • The system is memoryless (Markov property) birth and death process A probabilistic model —a random walk— where the state transitions are of only two types: "births", which increase the state variable by one and "deaths", which decrease the state by one. -- number of mRNA molecules n(t) ~y k.n(t) -- ti is i after t time step Ni is n at ti -- reaction: n(I+1)=ni+1 will have a propensity of reaction of y∆t which correspond to the event of systhesis n(I+1)=ni-1 will have a propensity of reaction k.ni.∆t which correspond to the event of degradation -- the probability of the next step given the history of the rest of the system (aka the system is influencing the next time step y.∆t (synthesis), (k.ni).∆t (degregation), and 0 (if not synthesis of degradation it stays the same, step size is small enough that you will either have synthesis or degradation) No! this property implies that the reaction status at time t(n-1) does not affect the probability of reaction at time t1 due to Markov property of the process. -- p(n(I+1) | n1,...,ni)=y.∆t (synthesis), (k.ni).∆t (degregation) we know that y.∆t (synthesis), (k.ni).∆t (degregation) do not add up to zero. however, if we add y+k.n(t) and divide y and k.n(t) separately, we will get a probability that will add up to 1. note that in this case, the probability will not be a 50/50, it will be a biased coin flip based on what y/y+k.n(t) and k.n(t)/y+k.n(t) is. -- not similar in the first part but similar after that -- it asymptotically goes somewhere -- initially n(0)=0, recall the y/y+k.n(t) and k.n(t)/y+k.n(t) , if n(0)=0, then y/y and 0 for both equation, => 100% probability of going up but when y=k.n(t), 1/2=1/2, so equal chance of going up or down, stays near the an asymptote that is define by y is equal to k.n(t). that only occurs with n(t)=y/k, so the flucattaes there. REMINDER THAT Y IS N(T), X IS THE T it will go up or down depending on if the value get bigger or smaller -- dx(t)/dt=0 x^st=y/k=10/.2=50 -- The deterministic (ODE) model and the stochastic model converge toward the same "steady state" value BUT The relaxation time of the deterministic (ODE) model and the stochastic model are different!

what is the simple quantitative model of outflow dynamics? define the free parameters linearize the equation. what is the conclusion we get from the linearize form? what are the natural log rules? for the function y=f(x), how do we find the slope of f(x)? what is the full expansion of f(x)? using the linearize form of the outflow dynamics equation, how can we fill in the parameter? going back to the original model of outflow dynamics, amend the equation based on the found parameter. What is the relationship between 𝑒" and ln(𝑥) ?

𝐶virus(𝑡) = 𝐶o* 𝑒^(-kt).; -- Co initial concentration; k is decay rate -- ln𝐶virus(𝑡) =ln(𝐶o*𝑒-kt) ln 𝐶virus(𝑡) = ln (𝐶o) + ln(-kt) ln 𝐶virus(𝑡) =ln(𝐶o)−𝑘.𝑡 The logarithm of the viral load is a linearly decreasing function of the time -- ln A.B =ln A +ln) ln A/B =ln A −ln(B) -- k=deltaY/deltaX -- y=k*x+Yo -- log 𝐶virus(𝑡) = log(𝐶o) − 𝑘. 𝑡 Log(Co) is the intercept of the graph, pick two points that are representative or the trend and use their y and x values to find K -- 𝐶virus(𝑡) = 1.6 10^5* 𝑒^(--0.52t).; -- e^x will increase fast, ln(x) will increase slowly


संबंधित स्टडी सेट्स

Exam 3 Chp 15.16.17.18.20.21.22.23

View Set

Architecture Lecture Midterm/Quizes

View Set

MKT210 Marketing Chapter 6 Video : Eaton

View Set

THE SUDETENLAND AND CZECHOSLOVAKIA 1938-39

View Set

Accounting Chapter 10: Journalizing Purchases and Cash Payments Using Special Journals

View Set

A.D. Banker - Life Insurance Prep - Chapter 7

View Set