The formal way to draw a value

**x**from a probability distribution with a cumulative distribution function

**F(x)**is by randomly choosing a value

**y**between 0 and 1 in a uniform law of probability and then doing:

x = F(-1)(y)

where

**F(-1)**is the inverse function of

**F**, i.e:

x = F(-1)(y) <=> y = F(x)

But it is not always necessary to obtain

**F**in order to draw a value from a probability distribution.

If your population comes from a normal (gaussian) law of probability, it is much easier to use the

**Box-Müller**algorithm:

1.- Choose a value

**u**from a

**U[0,1]**(uniform law of probability in [0, 1]).

2.- Choose another value

**v**from a

**U[0,1]**(uniform law of probability in [0, 1]).

3.- Draw a value

**x**from a

**N(mu, sigma)**(gaussian with mean

**mu**and standard deviation

**sigma**) according to the following formula:

x = mu + sigma * square_root(2 * ln(1 / (1 - u))) * cos(2 * PI * v)

**ln**is neperian logarithm an

**PI**is 3.141592...

I hope this helps

So, before doing Monte-Carlo on some distribution, you need to get the distribution itself.

You further considerations are very non-mathematical, using some examples, etc., so they are hard to understand.

Usually, the libraries can give you only the uniform distribution (with some good or not so quality), sometimes, something else, like Gauss. Your task is to convert this distribution into some other distribution. For this, you need to write some function which converts uniform output into non-uniform, according to your requirements. Now, you have a simple mathematical problem (actually its simplicity depends on the distribution function you require :-). Now, it's your turn...

—SA