Monte Carlo simulation
When you need simulation, and how to read P90.
The expected value tells you the average, but it does not tell you how much it varies. Nobody commits to an SLA with an average — half the cases would be late.
How the simulation runs
Each run is one simulated case travelling through the whole process:
- At an exclusive gateway: draw a random number, pick the branch according to the declared probabilities.
- At a parallel gateway: run every branch, add up the costs, take the max of the simulated branch times.
- Landing on a rework branch: go back and run again, exactly as in reality.
- Record the total time and total cost of that run.
2.000 runs by default, adjustable on the Units tab of the editor.
join = joins.get(current)
successors = adjacency.get(current, [])
if join and len(successors) > 1: # khối song song
branch_times = []
for successor in successors:
branch_time, branch_cost = run_segment(successor, join, budget, seen)
branch_times.append(branch_time)
cost_total += branch_cost # chi phí: cộng mọi nhánh
time_total += max(branch_times) # thời gian: chỉ nhánh chậm nhất
current = join
else:
current = choose(current) # rẽ nhánh theo xác suất
Reading the results
| Metric | Meaning | Used for |
|---|---|---|
| Mean | The expected value according to the simulation | Cross-checking against the analytical number |
| P50 (median) | Half the cases finish before this mark | Describing “how long it usually takes” |
| P90 | 90% of cases finish before this mark | Committing to an SLA |
| P95 | 95% of cases finish before this mark | A tight commitment, a large contract |
A process where 12% of cases are rejected early (15 minutes) and 88% go the whole way (around 420 minutes).
- Mean: 372 minutes
- P50: 420 minutes
- P90: 455 minutes
Committing to “an average of 372 minutes” sounds reasonable, but nearly 90% of cases will exceed that mark — because most cases take the long route, while the few rejected early have pulled the mean down. The right number to commit to is P90.
The distribution chart
The bars in the Simulation tab show the shape of the distribution. Two separated clusters are a sign that the process has an exclusive branch with very different durations — the mean falls between the two clusters and describes no case correctly. In that case you should split the two flows into two separate SLAs.
Repeatability
When to trust the simulation over the analysis
When the process has a parallel block where each branch itself contains a random branch point. In that case E[max] is larger than max E[·], and the simulation reflects reality correctly: one unlucky branch is enough to make the whole block wait. The metric cards at the top of the page display both numbers so you can see the gap for yourself.