[MUSIC] Hello, so we'll continue in your class on the simulation modeling of natural processes, with our last module on Monte-Carlo method. So, I'd like to discuss what some people call the kinetic or dynamic Monte-Carlo and to illustrate this, I will take a simple example. So, I'll take an abstract chemical reaction which is described on the slides and saying that's some species A transformed into species B with some rate k1, and conversely B can turn back to an A molecule with rate k2. So this is a very simple process, and we know how to write a differential equation for this. Okay, and this is this equation which is written on the metrics form. Again, I don't really want to insist too much about that. But you will see more about dynamical system later in this course. But just to know that we know how to write an equation to describe this. And we even know how to solve it. So again, it will give me basically, the concentration of molecule A and concentration of molecule B as a function of time. And of course, it depends on this rate of transformation and the initial concentration of A and B, and see there's here an exponential which [COUGH] vanishes as time goes on. So basically, the long time limit you get this true value which are the equilibrium density of A and B molecule in the system. Okay, so this is a solution or a model in term of a differential equation, ordinary differential equation. Now, could we do some Monte-Carlo approach? So could we sample these processes with some random processes, okay? And the answer is yes, we can try at least. So what's the idea of this system? So you have a molecule A that suddenly turn into a molecule B with some Rate and conversely. So there's a probability that during a given interval, there's a transformation. So I will choose a time step delta t so that the rate of transformation times is delta t. For both species and both direction are smaller than one so I can interpret that as a probability of transformation. So then my sampling process will be the following. I will just choose randomly one particle among all my molecule, whether A or B. So in total I have N of such molecule and, of course, the fact that A transform into B and conversely, mean that I always have the same number of particle in the total. Okay. I've always have N molecule. So I pick one out of those uniformly and of course if I have a lot of A molecule I've more chance to pick and an A. If I have more B particle, I have more chance to pick a B. But I do it with a random number generator and here you have a practical way to do it. So I just take a random number between zero and one and I compare it to a concentration of A divided by the total concentration. And if it's more than this quantity, I assume that I picked a A and otherwise, I picked a B molecule. Okay, so now I decide whether this A or B molecule is transformed to the other species, okay? So, I know that this happened with a probability k1 times delta t. So again, I take a random number and if this random number is smaller than k1 delta t assume that the event takes place. Mean that I lose one particle of A and I gain one particle of B. And symmetrically speaking, it can do exactly the same with the B particle. In fact, pick the B particle. I can transform it or not into an A particle. And if it's successful, then I will increase the number of A and decrease the number of B. Okay, now I can repeat these steps n times because I have n particle so at least I give a chance to all the particles to get this information. And that means that I dedicated one time step or one delta t of time evolution in my system. And finally, I repeat the process between 0.2 to 0.4, until I reach the final time of my simulation, which here is called t max. So if I plot the result of this stochastic process, of picking particles at random, decided to transform them at random, I get the following picture. So in red you have maybe the density of A particle. In blue, the density of B particles, so they sum up to the same value, so they're always the reflection of each other. And you see that it kind of oscillate and fluctuate, but maybe you can see this line here, that's the analytical solution from the differential equation and that's the original value which is the steady-state result. So basically I follow rather well what theory tells me. I'm just fluctuating around it. So maybe I should just repeat that many times and actually, if I do that I will get closer and closer to the analytic curve. But this is only one run and with one run I cannot expect to, of course, have the average behavior at once. So statistics are needed. Of course, this algorithm I just show you is rather simple, and people have been working on it. And I mean, if you really wanna apply Monte-Carlo for chemical reaction, usually you would prefer the Gillespie algorithm. It's the same idea but it's a bit more sophisticated and I just would like now to go over the different steps. So the main point is that you have several reactions, or several events, which are numbered from 1 to n, and the rate at which they can take place is know as ri, okay? So that's a input to the problem. So icould be, as in our example before, the reaction rate for chemical transformation. For instance, if A molecule plus B molecule gives us C molecule, then the rate would be given by this equation which is well know for chemical system. So now what you do is, you compute what's called cumulative rates, or you sum all the rate. Sorry, that should be a j. For 1, 2, 3 until the end event, and you call this partial cumulative sum or i. Okay? And then you have a process which is to decide which of the events you will actually execute. So for this, you choose a random number between 0 and 1, and you select which of the rk, has this property to be between two event, and that's the k that you will Select. So maybe it's easier to give you a little image so here if you have all your n events which are shown with a length which is proportional to the writ. Okay, so the idea is that you pick a random number and basically this random number will stop somewhere. And it will select which event you wanna execute. And of course an event which has a big rate has more chance to be selected at an event which has a small rate. So basically, this picture is an illustration of what you would do here. Okay, so once you have selected this event, you execute it. For instance, in our example, to combine a molecule A with a molecule B to produce a new molecule C. And then you advance the time by quantity which is more complex than before. You see that you again take a random number, take the logarithm in natural basis of the inverse of this number, and you multiply that by the total rate of all the, inverse total rate of all this. And that tells you how the time has evolved doing that. So this is a bit more difficult to understand. I will not mention it or discuss it longer, but that's the way the algorithm is proposed. So it mean that the evolution of the time is more like a personal type of distribution. And in this algorithms only one event can take place during a given time interval. Okay. So, with this I just terminate my discretion of the Monte Carlo method. I hope that I could give you some intuition of what it mean by sampling. Processes by some stochastic system, and with this, we also finished our week one of the course, which was a global introduction and general concept. And next week, you will learn about Python programming, which is, of course, essential for this course, to know a little bit how to program the example we will develop. So I thank you for your attention. [MUSIC]