top of page

Monte Carlo Method

Monte Carlo Method uses random samples obtained with appropriate probabilities as input to obtain numerical results or evaluate deterministic models. The Monte Carlo Method is an important application of the law of large numbers.

For here, three examples are provided to show the basic idea of Monte Carlo Method.

1. Coin Flip Problem

2. Calculate π with Monte Carlo Method

3. Predict Stock Price with Monte Carlo Method

1. For the flipping coin case, we are referring to a fair coin. Please ignore the Two-Face in Gotham City. By using the Monte Carlo Method, we can prove that, when flipping a fair coin, the probability of showing a head is 1/2. And with increasing coin flips, higher accuracy can be achieved.

In total, I conducted the coin toss for 25000 times, and the final probability I got is 0.50028, which is very close to 1/2. You may refer to the code I used with the link below:

Python Code

Coin_flip2.png
Coin_Flip.png

2. Assuming a circle with radius length of r was put in a square with side length 2r, this give us the area ratio between these two figures, which is (πr^2)⁄(4r^2 )=π/4. To estimate the value of π/4, dots are placed in the square randomly. By counting the dots number in and out of the circle, π/4 can be estimated and further, an approximate value can be generated for π.

In total, 10000 dots are used here to calculate π. The final π obtained is 3.1344, which is close to the real π. You may refer to the code I used with the link below:

Python Code

3. To predict the stock price with respect to time, the assumption is made that the stock price change follows geometric Brownian motion:

where St is the stock price, μ is the expected rate of return, σ is the expected volatility of the chosen stock. Wis Brownian motion. The stock price is predicted for the following 90 days. For each day, the predicted stock price is calculated from 10000 simulations. You may refer to the code I used with the link below:

Python Code

bottom of page