Skip to content

Monte Carlo estimate of pi and its error

Question

How can you estimate π\pi with a Monte Carlo simulation, and how does the error shrink with the number of samples?

Short answer

Draw (x,y)(x,y) uniformly in the unit square and multiply the fraction with x2+y2≤1x^2+y^2\le1 by 44. The quarter disc has area π/4\pi/4, so each point is a Bernoulli trial with that success probability. The estimator's standard deviation is π(4−π)/n≈1.64/n\sqrt{\pi(4-\pi)/n}\approx1.64/\sqrt n, so error falls like n−1/2n^{-1/2}.

Adapted from Zhou, A Practical Guide to Quantitative Finance Interviews, sec. 7.3 Numerical Methods, 'Monte Carlo simulation E', p.187; question and answer rewritten by SelfMadeQuant.com.

See the hint and the full worked solution in the question bank (free account).

Open the worked solution

Lessons behind this question

Start with a free lesson: Basic Statistics and Regression is part of a free topic. Create a free account, no card needed, to read it in full with worked solutions.

Read it free