Sub topic 10
Going further: Monte Carlo simulation
This chapter assumes you know tasks, dependencies, critical paths, three-point estimates, averages, variances, and standard deviation. It also assumes basic Python. The earlier PERT method summarizes uncertainty with one mean and one standard deviation. Monte Carlo simulation keeps more of the shape of each task’s uncertainty and uses repeated random trials to estimate possible completion dates.
Why simulate instead of using one formula?
The normal approximation is useful when task durations are reasonably independent and the path is fixed. It estimates a completion time from:
- The sum of task means.
- The square root of the sum of task variances.
- A chosen probability, such as 85%.
Real schedules can be less simple. A task may have a long right-hand tail, meaning that extreme delays are more likely than a normal distribution suggests. Different tasks may also have different uncertainty shapes.
Monte Carlo simulation handles this by creating many possible versions of the schedule:
- Draw one random duration for each task.
- Add the durations on the path.
- Store the simulated total.
- Repeat the process thousands of times.
- Sort the totals and read percentiles from them.
An 85th percentile means that about 85% of the simulated totals are at or below that duration. It does not mean that the project has an 85% guarantee. The result is only as credible as the estimates and assumptions used to generate it.
Sampling a PERT-shaped duration
A three-point estimate contains:
- O, the optimistic duration.
- M, the most likely duration.
- P, the pessimistic duration.
A beta distribution is often used to model a bounded duration between O and P. A beta distribution is flexible: it can place more probability near the optimistic value, the most likely value, or the pessimistic value. The beta-PERT form uses the most likely value as a strong center point.
For the common PERT weighting factor of 4, the shape parameters are:
alpha = 1 + 4 * (M - O) / (P - O)
beta = 1 + 4 * (P - M) / (P - O)Python’s random.betavariate returns a value between 0 and 1. Scaling that value to the range from O to P produces one simulated task duration.
The following program simulates a simple path of three tasks. It reports the simulated mean and several percentiles.
import random
from statistics import mean
random.seed(7)
def sample_pert(optimistic, most_likely, pessimistic):
if not optimistic <= most_likely <= pessimistic:
raise ValueError("Estimates must satisfy O <= M <= P")
if optimistic == pessimistic:
return float(optimistic)
alpha = 1 + 4 * (most_likely - optimistic) / (pessimistic - optimistic)
beta = 1 + 4 * (pessimistic - most_likely) / (pessimistic - optimistic)
unit_value = random.betavariate(alpha, beta)
return optimistic + (pessimistic - optimistic) * unit_value
def percentile(sorted_values, probability):
position = int(probability * (len(sorted_values) - 1))
return sorted_values[position]
tasks = [
(2, 4, 8),
(3, 5, 13),
(1, 2, 3),
]
totals = []
for _ in range(10_000):
total = sum(sample_pert(*task) for task in tasks)
totals.append(total)
totals.sort()
print(f"Simulated mean: {mean(totals):.2f} days")
for probability in (0.50, 0.85, 0.95):
value = percentile(totals, probability)
print(f"{probability:.0%} completion level: {value:.2f} days")The program’s output can change if the random seed changes. The order of the percentiles should not change: the 50th percentile should be no greater than the 85th, and the 85th should be no greater than the 95th.
Comparing analytical PERT with simulation
For the same tasks, the analytical PERT calculation gives a path mean of about 12.33 days and a standard deviation of about 1.97 days. A normal approximation can then produce an 85th-percentile estimate.
Simulation may produce a different result because it samples bounded, often-skewed task distributions. That difference is useful information. It shows how much the result depends on the chosen distribution rather than on arithmetic alone.
| Method | Main input | Useful when | Main limitation |
|---|---|---|---|
| Triangular average | O, M, and P | A quick rough estimate is enough | Gives too much weight to the extremes |
| Analytical PERT | Means and variances | Tasks are fairly independent and the path is fixed | Often uses a normal approximation for the total |
| Monte Carlo simulation | A distribution for each task | You need percentiles or skewed uncertainty | Cannot correct poor estimates or missing dependencies |
Use enough trials for stable results. Ten thousand trials is a common starting point. Increasing the number of trials reduces random sampling noise, but it does not make the model more accurate if the model is wrong.
Modeling a complete schedule
A simple path simulation adds every sampled task duration. A real project may contain parallel tasks. In that case, each trial must calculate the schedule’s finish time from the dependency network:
- A task starts only after its predecessors finish.
- Parallel tasks can run at the same time.
- A successor starts after its latest predecessor finishes.
- The project completion time is the finish time of the final task.
The critical path can change from trial to trial. A path that is usually critical may finish early in one trial, while another path becomes the longest. A simulation that always sums one fixed path cannot represent this shift.
Assumptions and failure modes
Monte Carlo simulation extends PERT; it does not remove PERT’s assumptions.
- The O, M, and P values must describe a consistent range. If the pessimistic value excludes a known risk, the simulation understates risk.
- Independent sampling assumes that task durations do not move together. Shared vendors, weather, staffing, or unstable requirements can create correlation.
- The beta-PERT distribution is a modeling choice, not a measurement of reality.
- A simulation cannot discover an omitted task or dependency.
- Ten thousand precise-looking results do not compensate for biased estimates.
- A schedule model should include explicit risk events when those events affect several tasks at once.
When two tasks depend on the same external event, sample that event once and apply its effect to both tasks. Otherwise, independent sampling can count the uncertainty incorrectly.
Exercise
Why can a Monte Carlo 85th percentile differ from the 85th percentile calculated with the normal approximation?
Show answer
Monte Carlo samples the selected task distributions directly, including their bounds and skew. The normal approximation uses only the combined mean and standard deviation, so it can assign different probabilities to extreme outcomes.