Given a distribution type,

and we're going to consider normal distributions, discrete distributions,

uniform distributions, triangular distributions,

and something known as the beta part distribution.

So for any distribution,

first of all the the area underneath the curve is always one,

or the area underneath the bars if it's a discrete variable,

it always adds up to one.

All right? So it's a probability.

Depending upon the distribution,

what you want to do for the Monte Carlo simulation is if we have a value A and a value B,

and we have a distribution here,

we want to choose a value between A and B at random.

So we want to randomly select from this distribution.

The way to do this,

and again the area tallies up to one,

we base it on probability.

So, if I randomly choose a number between zero and one,

and there's a nice rand function in Excel,

and there is a nice R & D with or without parentheses in VBA,

it randomly selects at random uniformly,

it'll select a value between zero and one,

which is nice because probability is always between zero and one.

So what we always do for a distribution is we randomly

choose a number between zero and one equally likely,

so it's a uniform distribution,

and maybe I get 0.413.

All right. So I just randomly select a number between zero and one.

Now that's going to be a probability,

and what we do then is we drop a line basically in

our distribution where we start with the left and we fill it up with that random number.

So this is 41.3 percent of one. That's a probability.

We fill it up starting from the left,

and then wherever we get to that is our random number.

So that's what we're going to use,

then this is our random number

that we're going to use in our Monte Carlo simulation. All right.

So if a equals three and b equals seven, then maybe,

depending upon the shape of this curve then maybe we would end up with something like,

I don't know 40 percent,

but it's kind of a weird shaped thing,

so maybe we end up with 4.8.

All right.

If we wanted to generate

another random number that follows this distribution between three and seven,

we would then create another random number between

zero and one uniformly distributed, equally likely.

So anything between zero and one is equally likely.

So maybe we choose 0.990. All right?

So that next time we want to output what number corresponds to 99 percent,

we fill up then 99 percent of the distribution.

So it goes all the way and then this is maybe like 6.95.

So that's how you can select a random number that follows a distribution.

First of all, you take a random number from a uniform distribution between zero and one,

either using the rand function in Excel or the R & D. You don't need the parentheses,

you can just write R & D. You take that number,

then that's a probability or an area,

and you plug that in and you go from the left to calculate your random number.

And in the subsequent screencast I'm going to show you how you

can do this for each of the distributions.

And in general I refer to this as P. So, it's a probability.

P then is the random number between zero and one that follows a uniform distribution.