[MUSIC] So, welcome back to a class on the modeling and simulation of natural processes. Now, we're going to start to discuss other techniques called Monte-Carlo method. So, I will be rather short but I will have three modules on this, want to give you the main idea, and then, two others which are more specialized. So, just to understand what's the background of this Monte-Carlo method. I mean, very globally the idea is to sample a physical process. And out of the sampling, we can compute some studies to get a property, and some interesting features of this process. And as an example, I would like to take the problem of tossing a coin. Like you have a coin and then, ou just toss it, and you look whether it's a tail or head, and maybe the question you may want to ask is out of 4 toss, what's the probability to obtain 3 head and 1 tail or 3 tail and 1 head. Had okay? So, this is a very basic problem in probability theory, and the solution is given by this formula which is basically the number of way to have 3 tails out of four launches and there's a probability of tail and there's a probability of head which is in that case the same but you could have loaded coin in case. Give you one quarter but in Monte-Carlo, you don't wanna resort to this formula, you say, maybe I could do a simulation of this process and tact to deduct this, deduce this result from an experiment. And of course, I can do it in front of you. So, I will launch on, so here it's actually tail. This is head. This is tail, this is tail. So, 3 tail,1 head out of 4 tosses. Okay, so, of course, it's only one experiment. I should repeat that many, many time and Oo many many of this experiment, I will be able to decide what's globally probability of having this. Probably, the next time I do it, I will have 2 head, 2 tails or the opposite, but anyway, you imagine that I can play this game. And a bit smarter way would be for us to do this on the computer. So, hereis a very simple pattern. Program and you will learn more about python next week, actually. But just goes through to it. So basically, at the start of the program, I have no success, and I will attempt 10,000 of this tossing. So, I will run through all this 10,000 attempts, and this function randint just returned (0,1) with probability one-half. So, I will just say that 1 is head and 0 is tail. And I just sum up these 4 tosses. And if it's gives me 3, it mean that I got 3 hat, for instance. And then, I just say that success is incremented by 1. Then, that's all. I can now run this program, and see what's the result out of the number of attempts, how many [INAUDIBLE] success I have. And here, in this example out of my 10,000 attempts i get 2559 success. Which is actually not so bad knowing that the official mathematical result is 1/4. So, it's almost 1/4. Of course, if instead of 10,000 I would have 100,000 I would have been closer to this exact result. So, it shows that the Monte-Carlo is a sampling approach but of course you may get some errors and you have to take that into account. Of course, the coin tossing problem is very simple, and per I don't need to have a Monte Carlo method to solve anything cuz the math is good enough for that. But you can think of a more difficult problem for which mathematics is probably hard to apply. And as an example, I'd like to illustrate a card game the card game which is called the war or the battle. So, how does it work? I have a deck of cards. I already separated that into two parts for two players, but that will be the two players at the same time. So this has been shuffled properly. And the idea is that each of the player, they showed a card on the top of the deck, which is basically my example is two. And the stronger card is this one, so it takes the seven, and the winner put it below his deck. So, now we just enter in this process and her,e we see that those have the same value so those is called a battle or a war and then, the way it goes is that you take a card result showing it, and cover it, and then, you do it again with the new card. And five is again stronger than four, so this player is taking everything. And putting that under this deck. And it goes on until there's no more cards. So, one player has just all this deck. So, the question is how long does it last. On average, okay? Maybe you play that game and you noticed that usually it lasts long. So, this is just a simulation when you can just program in your computer this game. It's very simple, okay? And, here on this graph, you see has a function of the round. So, how many times the player play. The number of cards that one of the player has, of course the other player has the complement to 52. And you see that it fluctuates a lot. Here, you may think the guy is almost losing. But no there is fluctuation it goes up again. And after about 898 rounds okay, finally, player number one losses, this is just one instance of the game, playing the computer. Now, I could start doing statistics and say okay, I can repeat this over and over, and have an idea of what's the average duration of the game. I will not show you the result here, but I can tell you that, on our ready class very long. So, 800 is not at all exceptional. You can even have even game that are longer than 10,000 rounds, okay? So, maybe it's of limited practical interest but it shows that here if I had to apply a probability theory it would probably be very difficult. I mean, everything is in the initial distribution of my card in the deck. So, I should consider all possible distribution and then, have a combinatorics to follow the story. And I guess this is a bit too difficult. That's actually card games also the motivation of this method. It's due to the famous scientist of the 40's. 1940's. So from Neuman, Ulam and Metropolis, and they coined this term of Monte-Carlo because Ulam's uncle was gambling in this, in a casino called Monte-Carlo and he was losing this money, he was losing his money playing a solitaire game which was called Canfield Solitaire which is also a card game that you play alone, and if you manage to finish the solitaire then, you get money. If you fail, you lose your money. And of course the question is was to probably due to successfully finish the solitaire game and Ulam started to analyze that in a mathematical way and he gave up and say finally, it matches just to simulate many of these games. And if I play hundred or thousand, I can probably have a good idea of the probability that such a game can be finished. Later on, this technique was taken by these three physicists, von Neumann, Stanislaw Ulam and Metropolis. For the Manhattan Project in Los Alamos, which was about developing the nuclear weapon. So, it started, you know, maybe in an exotical way, but not to be very effective scientific method for modeling. Complicated process. And with this I'd like to finish my introduction to the Monte-Carlo Method. And the next module will go into more mathematical detail. So, thank you for your attention. [MUSIC]