0:35

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.

Â 2:16

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.

Â 2:59

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.

Â 7:43

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.

Â