A trial is one execution of a simulated experiment. It samples values for the model variables and produces one possible system outcome, preserving variability that deterministic calculations conceal. section 9.2
Monte Carlo trials follow a repeatable workflow:
- Sample random values according to the defined probability distribution. section 9.2
- Map each sampled value to an outcome using cumulative-probability intervals. section 9.2
- Aggregate trial outcomes to estimate distributions, averages, variability, and risk. section 9.2
- Increase the trial count when greater stability and statistical reliability are needed, while recognizing diminishing returns. section 9.4
Absenteeism staffing
A call-center trial maps one random digit to a Poisson-distributed absentee count. A digit of 73 maps to k = 3, suggesting three additional associates for that scenario. Across 10 trials, the mean staffing requirement is 2.4. section 9.3.5
>>> np.random.seed(1) #1
>>> num_trials = 500 #2
>>> normalized_probabilities = \
>>> probabilities / probabilities.sum() #3
>>> simulated_values = np.random.choice(k_values, #4
>>> size = num_trials, #5
>>> p = normalized_probabilities) #6
>>> unique, counts = \
>>> np.unique(simulated_values, #7
>>> return_counts = True) #8
>>> simulated_counts = \
>>> dict(zip(unique, counts)) #9
>>> simulated_percentages = \
>>> {k: (v / num_trials) * 100 for k, \
>>> v in simulated_counts.items()} #10
Inspect the NumPy implementation for reproducible random sampling, probability normalization, trial counts, and outcome frequencies. section 9.4
