When to Enumerate and When to Simulate

Enumeration can give an exact finite probability. Simulation estimates the result by repeating samples from a defined model.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Compare a small experiment
  2. Validate a simulator on the small case
  3. Use an exact answer to calibrate a simulation
  4. Describe what sampling uncertainty means

Compare a small experiment

For two fair dice, enumerating ordered pairs gives six of thirty-six with sum seven. A simulation reports the fraction of sampled pairs with sum seven, which fluctuates with finite sample size. Cartesian products give the exact outcome space.

Validate a simulator on the small case

Compare the estimate with the known result over repeated trials. Identify random sources and retained model assumptions so failures can be replayed. See recording random test choices.[1]

Use an exact answer to calibrate a simulation

Three independent fair tosses yield eight equally likely ordered outcomes. Exactly two heads occur on HHT, HTH and THH, so their probability is three eighths. An independent simulation can estimate the same probability by recording whether each triple belongs to that event. See binomial counts.

Exact estimate by enumeration: 3
8 = .375
Example simulation: 381 successes in 1000 trials → .381
Difference from exact answer: .006

Describe what sampling uncertainty means

Different independent runs can give differing estimates. Increasing sample size generally reduces the variability of the estimated proportion. If an exact small case disagrees persistently, inspect trial independence, outcome generation and the event check. Save a seed for replay.

References

  1. Eric Lehman, F. Thomson Leighton and Albert R. Meyer, Mathematics for Computer Science ↩