Skip to main content
Scientific computing
Lesson 58 of 75
Standard practice

Monte Carlo methods

Objective. Estimate quantities with random sampling.

  1. 1. Learn
  2. 2. Worked example
  3. 3. Practice
  4. 4. Feedback
  5. 5. Continue

Learn: the key idea

Monte Carlo methods estimate quantities such as integrals or expectations by generating random samples and averaging a function of them, relying on the law of large numbers for convergence and giving an error that shrinks like 1/√N for N samples. For example, to estimate π, sample N points uniformly in the unit square, count the fraction landing inside the quarter circle x²+y²≤1, and multiply that fraction by 4. With 1000 points and 785 inside, the estimate is 4(785/1000) = 3.14. Increasing N by a factor of 100 only halves the error by a further factor of 10, so Monte Carlo converges slowly compared with deterministic quadrature in low dimensions.

Worked example

A Monte Carlo method estimates π by sampling 500 random points in the unit square and finding that 393 fall inside the quarter circle x²+y²≤1. What is the Monte Carlo estimate of π?

1/4
Fraction bar showing 1 out of 4 parts shaded
  1. 1Compute the sample proportion landing inside the quarter circle: 393/500.
  2. 2Simplify 393/500 = 0.786.
  3. 3Multiply the proportion by 4, since the quarter circle is 1/4 of the full circle's area ratio: 4 × 0.786.
  4. 4Compute 4 × 0.786 = 3.144, the Monte Carlo estimate of π.

Answer: 3.144

Concept mastery

Based on your past attempts at this lesson — the question types to practise again come first.

Complete a practice set to see your concept breakdown here.

Practice

Practice happens on its own screen, one question at a time. Answers stay hidden until you submit yours, and you can stop and pick up at the same question later.

Start practising

Common mistake. A common mistake is assuming doubling the number of samples halves the estimation error; because the standard error scales as 1/√N, the sample size must be quadrupled to halve the error.

Your progress

Tick each step as you finish it. Your exact reading position is saved automatically, so Continue drops you back on the same line.

0 of 5 steps complete

Your place saves automatically as you read.

My dashboard