Fundamentals 6 min read

Monte Carlo Method: Five Illustrative Examples

This article introduces the Monte Carlo method and demonstrates its versatility through five examples covering π estimation, integral calculation, traffic‑jam simulation, product thickness reliability, and securities market profit forecasting, highlighting its simplicity, power, and broad applicability.

Qunar Tech Salon
Qunar Tech Salon
Qunar Tech Salon
Monte Carlo Method: Five Illustrative Examples

This article presents the Monte Carlo method through five examples.

1. Overview

The Monte Carlo method is a computational technique that uses a large number of random samples to understand a system and compute desired values. It is powerful, flexible, simple to implement, and often the most straightforward or only feasible approach for many problems.

The method originated in the 1940s U.S. Manhattan Project; its name comes from the gambling city Monte Carlo, symbolizing probability.

2. Calculating π

The first example shows how to estimate π using Monte Carlo. A square contains an inscribed circle; the area ratio is π/4.

By randomly generating 10,000 points inside the square and counting those that fall inside the circle, the proportion approximates π/4; multiplying by 4 yields an estimate of π. A R script with 30,000 points gave an error of only 0.07%.

3. Computing Integrals

The same idea extends to estimating any integral. For example, the integral of y = x² over [0, 1] corresponds to the area of the red region under the curve.

Generating many random points in the unit square and counting those with y < x² gives a proportion equal to the integral value. A Matlab simulation with one million points produced 0.3328.

4. Traffic Jam Simulation

The Monte Carlo method can also simulate stochastic systems, such as single‑lane traffic congestion using the Nagel‑Schreckenberg model. The rules are:

Current speed is v.

If the road ahead is clear, speed increases to v + 1 up to a maximum limit.

If the distance to the car ahead is d < v, speed reduces to d − 1.

With probability p, the driver randomly decelerates, reducing speed to v − 1.

Simulating 100 cars on a line with p = 0.3 produces the space‑time diagram below, where black clusters indicate emergent traffic jams even without external causes.

5. Product Thickness Reliability

A product consists of eight stacked parts; the total thickness must stay below 27 mm. Each part’s thickness varies probabilistically. By sampling 100,000 random thickness sets, the simulation finds a pass rate of 99.9979%, meaning a 0.0021% (≈21 per million) chance of exceeding the limit.

6. Securities Market Profit Forecast

The method is applied to estimate expected net profit under three market conditions (quiet, active, moderate) with given average prices and volumes. Assuming a cost per share uniformly distributed between 5.5 ¥ and 7.5 ¥ (average 6.5 ¥), 1,000 random scenarios are simulated. The average net profit obtained is $92,427.

Original source: http://www.ruanyifeng.com/blog/2015/07/monte-carlo-method.html

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

simulationstatistical methodsprobabilityMonte CarloComputational Mathematics
Qunar Tech Salon
Written by

Qunar Tech Salon

Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.