Or

4
Tutorials that teach
Simulations

Take your pick:

Tutorial

Hi. This tutorial covers simulations. So let's start with the definition of simulation. So simulation, also known as the Monte Carlo method, is a method that can be used to estimate probabilities.

All right. So let's take a look at an example. And then we're actually going to use simulation to estimate a probability. So the theoretical probability of having two boys among four children is 0.375.

OK. So let's simulate this situation using a roll of a die to estimate the probability of two boys. We're going to let an odd roll represent a boy and an even roll represent a girl. So that's actually how we're going to do the simulation with a die.

But you can also do it on a calculator. And I'll just show you one way that you can use the calculator. So what I can do is I can-- if I'm doing the same simulation, boys and girls, what I could do is I could do Rand-- I could generate a random number.

So I could use the calculator function called RandInt. And if I put in 1 comma 2, that's going to represent-- that's going to generate a random digit between-- either a 1 or a 2. So it gave me a 2. So if I said a 2 was a girl, that would represent a girl.

If I wanted to randomly select four numbers, I could put it in as here-- 1 comma 2 comma 4. That's going to generate four random digits. And actually, I got all 2's there. So this would represent four girls. OK. And then I could continue to generate numbers that way.

I'm going to use a roll of a die, though, to do this simulation. So I'm going to keep track of my outcomes from my simulation, or the trials of my simulation, in this table here. So I'm going to do four rolls of the die.

If I get two boys, I'm going to mark a tally in this row. If I don't get two boys-- if I get one boy or no boys or three boys or four boys-- I'm going to put a tally here. I'm going to do this probably about 10 times and then calculate the probability of getting a family of two boys down here.

So I'll just show you one to begin with. So an odd is a boy, so that's one boy, two boys, three boys, and four boys. So this would be a family with-- that does not have two boys in it. OK.

One boy. That's a girl, so still at one boy. Another girl, so that's one boy. And that's another girl-- four. So this would be another not boy.

So I'm going to do about eight more. And then we'll calculate the probability.

So that is 10 simulations of families of size four. And what I found out is that four families ended up with two boys out of four children. And six families ended up with something other than two boys.

So what my probability then-- so if the probability of two boys-- remember, I take my number of outcomes where two boys showed up divided by the total number of trials-- or excuse me-- there are four trials that ended up with two boys, and there are 10 total trials. So my probability here is 4 out of 10, which is equal to 0.4.

OK. So this simulation provided a pretty good estimate of the theoretical probability of 0.375.

Now, if I wanted that even-- an even better approximation, recall that the Law of Large Numbers tells us the number-- that as the number of simulations increase, the simulated probability should approach the theoretical probability. So sometimes simulation can help verify a calculation or give insight into a complicated probability problem. So instead of working out the theoretical probability by hand, sometimes it's easier to just simulate the probability. And if you do your simulation enough times, sometimes you can get a pretty close estimate of what that theoretical probability should be.

All right. So that has been the tutorial on simulation. Thanks for watching.