1. Learn from a model of the system
Simulation imitates the behaviour of a system under specified rules. It can represent uncertain demand, queues, equipment failures or portfolio outcomes and compare the consequences of alternative decisions. A bank might simulate cash demand to study reserve levels or simulate customer arrivals to compare staffing plans. The output is conditional on the model and its inputs. Running a computer model does not make its assumptions true or guarantee that simulated outcomes will match future experience.
Simulation is especially useful when interactions, timing or uncertainty make a direct calculation difficult. It can answer what happens under a candidate policy, but it does not automatically find the best policy unless combined with a search or optimisation procedure. In contrast, a simple probability model may permit exact expected values without simulation. Use that exact result as a benchmark when available. This chapter begins with a small cash-demand model that can be solved both ways. The comparison makes random sampling error visible and prevents the common mistake of treating one simulated average as the true expected outcome. All amounts and costs are illustrative classroom assumptions.
2. Define the objective and boundary
Begin with the decision to be supported. “Understand cash demand” is broad, while “compare opening reserves of twenty and thirty lakh for daily shortage and holding cost” is testable. Define the time horizon, unit of time, performance measures and policies. Decide what the model includes and excludes. Does cash replenish during the day, can emergency transfers arrive, and is demand lost or deferred when cash runs out? Different answers create different systems even with the same demand distribution.
Identify inputs, state variables, rules and outputs. Daily demand is an uncertain input. Opening cash is a decision input. Remaining cash after withdrawals is a state. The rule that unmet demand becomes shortage determines an output. For a one-day model with no replenishment, shortage is max(demand−reserve, 0), while unused cash is max(reserve−demand, 0). These quantities cannot both be positive on the same day. That logical property is a useful verification check. A multi-day model may carry balances forward and replenish according to a policy, creating dependence between days. State the boundary before drawing random numbers so the simulation answers the intended operational question.
3. Deterministic, stochastic and time-based models
A deterministic simulation gives the same outcome for fixed inputs and rules without random draws. A stochastic simulation includes random quantities. A static Monte Carlo model samples outcomes without explicitly tracking a detailed timeline. A dynamic model evolves through time. Discrete-event simulation updates the system at events such as arrivals and service completions. These distinctions help choose the representation and avoid unnecessary complexity.
A one-day cash-demand exercise can be a static stochastic model. A branch queue with customers arriving and leaving throughout the day is naturally dynamic. In a discrete-event queue, the clock jumps to the next event rather than checking every second. A fixed-time-step model instead updates at regular intervals and may approximate events within each interval. The choice affects both accuracy and effort. A simple model is preferable when it captures the decision-relevant behaviour, but oversimplification can remove the very mechanism being studied. For example, average daily demand alone cannot reveal intraday stockouts if replenishment timing matters. Model detail should follow the decision rather than the availability of elaborate software.
4. Construct an input distribution
Suppose daily cash demand is ten, twenty or thirty lakh with probabilities 0.20, 0.50 and 0.30. These probabilities are nonnegative and sum to one. The cumulative probabilities are 0.20, 0.70 and 1.00. A uniform draw U between zero and one maps to ten lakh when U < 0.20, twenty lakh when 0.20 ≤ U < 0.70, and thirty lakh when 0.70 ≤ U < 1.00. The intervals do not overlap and cover the entire draw range.
For a two-digit random-number table using integers 00 through 99, allocate 00 to 19 to ten lakh, 20 to 69 to twenty lakh and 70 to 99 to thirty lakh. These contain twenty, fifty and thirty integers respectively. Check both endpoints. Assigning 00 to 20 to the first category gives twenty-one values and changes its probability. Arbitrary probabilities may not fit exactly into one hundred equally likely integers, in which case a finer random scale or direct uniform mapping is preferable. The input distribution may be estimated from data or specified as a scenario. Either way, record the source and assumptions. A simulation cannot correct a demand distribution that systematically omits important peak days.
5. Pseudorandom numbers and reproducibility
Computer simulations normally use pseudorandom numbers generated by deterministic algorithms. A seed initialises the generator and permits the sequence to be reproduced. Reproducibility is useful for debugging, review and fair policy comparisons. A seed does not make a small sample representative, and repeatedly using the same seed does not create independent replications. Different streams or carefully managed generator states are needed when independent runs are required.
For an educational exercise, a transparent seeded generator is sufficient to illustrate mapping and sampling variation. It should not be presented as suitable for cryptographic security or operational risk systems without validation. Separate the source of uniform draws from the mapping to business outcomes. This makes boundary tests easy: a draw just below 0.20 should produce ten, exactly 0.20 should produce twenty, and exactly 0.70 should produce thirty. Validate inputs before running. Negative probabilities, totals different from one and invalid reserve amounts should generate clear errors. Silent normalisation can conceal a data-entry mistake unless it is an explicit feature explained to the user. Repeatable calculation is one component of trust, alongside a defensible model and correctly interpreted output.
6. A five-day worked run
Use random integers 08, 23, 71, 46 and 95. The mapping gives demands ten, twenty, thirty, twenty and thirty lakh. Total demand is 110 lakh and the sample mean is twenty-two lakh. With an opening reserve of twenty lakh each day and no replenishment, shortages are zero, zero, ten, zero and ten. Total shortage is twenty lakh, average shortage across all five days is four lakh, and two of five days have a shortage, giving an observed shortage frequency of forty percent.
Unused cash is ten, zero, zero, zero and zero lakh, so the average unused amount is two lakh. Average shortage conditional on a shortage day is ten lakh, different from the four-lakh average across all days. Identify the denominator whenever reporting an average or rate. The five-day run is intentionally short so every row can be checked manually. It is not a reliable operational estimate. A different sequence can produce a different sample mean and shortage frequency. Preserve the draw list, mapped demands and resulting outputs so another learner can trace the calculation from random input to final summary. This audit trail is the simplest form of simulation verification.
7. Compare with exact expected values
The exact expected demand in the stated distribution is 10 × 0.20 + 20 × 0.50 + 30 × 0.30 = 21 lakh. With reserve twenty, shortage occurs only in the thirty-lakh state, so its probability is 0.30. Expected shortage is 10 × 0.30 = 3 lakh. Expected unused cash is 10 × 0.20 = 2 lakh. These are properties of the model, not estimates from the five selected draws.
The simulated mean demand of twenty-two differs from the exact mean twenty-one because of Monte Carlo sampling variation. The five-day shortage frequency of forty percent differs from thirty percent for the same reason. Increasing the number of independent draws generally improves precision, but it does not guarantee monotonic improvement after every additional draw. A larger run can temporarily move farther from the exact value. The law of large numbers describes convergence under suitable conditions, not a promise about each intermediate sample. When an exact benchmark exists, use it to test the implementation. A persistent discrepancy across very large runs may reveal incorrect interval boundaries, probabilities or output formulas rather than ordinary random variation.
8. Compare reserve policies and costs
Suppose the daily holding cost is one illustrative cost unit per lakh of unused cash and the shortage cost is four units per lakh unmet. For reserve twenty, exact expected cost is 1 × 2 + 4 × 3 = 14 units. For reserve thirty, shortage is zero and expected unused cash is thirty minus expected demand twenty-one, or nine lakh, giving cost nine units. Under these particular costs and demand states, reserve thirty has the lower expected cost of the two policies.
If the shortage cost falls to two units per lakh, reserve twenty has expected cost eight, below the nine for reserve thirty. The preferred policy therefore depends on the objective and assumptions. A low expected cost does not necessarily meet a service-level requirement. Management may impose a maximum shortage probability or consider emergency liquidity arrangements not represented here. Compare policies using common demand draws so differences reflect policy effects under matching scenarios. For the five-day sequence, reserve twenty has average cost eighteen and reserve thirty average cost eight under the original four-unit shortage penalty. Those simulated figures differ from exact expectations. Report the run size and uncertainty rather than disguising the simulation estimate as a known value.
9. Monte Carlo precision
For independent simulated outcomes with finite variance, the standard error of their sample mean is estimated by sample SD divided by the square root of the number of replications. Quadrupling replications approximately halves this standard error. For an estimated event probability p̂ from independent runs, a common large-sample standard error is √[p̂(1−p̂)/n]. The approximation needs care for rare events and small counts. More replications reduce Monte Carlo error under the model but do not reduce model bias or uncertainty in estimated input probabilities.
If a shortage probability is about 0.30 and n = 10,000 independent days are simulated, the approximate standard error is √(0.21/10000), about 0.00458. A rough 95% normal margin is about 0.009, or nine tenths of a percentage point. This describes simulation precision conditional on the chosen input model. If the true demand distribution is poorly known, total decision uncertainty may be much larger. In dynamic models, successive daily outputs can be correlated, so treating every day as an independent replication may understate standard error. Independent replications, batch methods or other appropriate simulation-output techniques are needed. Match the uncertainty calculation to how the output was generated.
10. A simple queue simulation
For a single-server first-come-first-served queue, each customer's service starts at the later of arrival time and the previous customer's finish time. Waiting time is service start minus arrival. Finish time is service start plus service duration. The server is idle before a customer when arrival occurs after the previous finish. These recurrence rules turn a list of arrivals and service durations into a complete event history without guessing average waiting time directly.
Consider arrivals at minutes zero, two and five, with service durations three, four and two. Customer One starts at zero and finishes at three, waiting zero. Customer Two arrives at two, starts at three and finishes at seven, waiting one. Customer Three arrives at five, starts at seven and finishes at nine, waiting two. Average waiting time is one minute. Total service time is nine minutes and the server is continuously busy from zero to nine in this small example. If a fourth customer arrives at twelve, there are three idle minutes before service begins. State the observation window when calculating utilisation. Dividing busy time by a window that excludes idle periods can exaggerate utilisation and distort comparison between staffing plans.
11. Initial conditions and run length
A dynamic simulation starts in some state. An empty queue at the beginning may be realistic for a branch opening each day, or it may be an artificial condition when studying a continuously operating service. Initial conditions can influence early outputs. A warm-up period removes an initial segment when estimating steady-state behaviour, but it should be justified rather than chosen merely to improve results. For a terminating daily simulation, the opening state may be part of the actual system and should remain in the analysis.
Define when the run ends. Does the queue stop accepting arrivals at closing time but continue serving those already present? Are unfinished customers carried into the next day or counted as unmet service? These choices affect waits, overtime and service completion. Run length and number of independent replications answer different needs. A long run can reveal stable behaviour, while multiple replications help assess variability across repeated days or scenarios. Rare events may require very large samples or specialised techniques. A run with no observed severe loss does not prove zero probability. Report the number of opportunities for the event and consider whether the simulation design is capable of detecting it with useful precision.
12. Verification and validation
Verification asks whether the implementation follows the specified model. Validation asks whether the model is suitable for its real-world purpose. A simulation can be perfectly coded and still omit a crucial replenishment mechanism. Conversely, a sound conceptual model can be implemented with a boundary error that assigns the wrong demand probabilities. Both checks are necessary and should be documented separately.
Verification includes hand calculations for small runs, boundary tests, conservation checks and comparison with exact results. In the cash model, shortage and unused cash should never both be positive, and their difference should reconcile demand and reserve. In a queue, service cannot finish before it starts, and a single server cannot serve two customers simultaneously under the stated rules. Validation compares model behaviour with relevant observations and expert knowledge. Does the simulated distribution reproduce broad demand patterns, peak periods and dependence? Hold back some historical data for comparison where feasible. A good average match alone may conceal poor tail behaviour. Record limitations and the range of decisions for which the model has been assessed, rather than claiming that one validation exercise proves universal reliability.
13. Sensitivity, scenarios and variance reduction
Sensitivity analysis varies uncertain inputs or assumptions to see whether the policy conclusion changes. In the cash example, alter the high-demand probability, shortage cost or replenishment availability. If a small plausible change reverses the preferred reserve, the decision is fragile and deserves further evidence. Scenario analysis can represent qualitatively different conditions, such as an outage day or a festival peak, without pretending that their probabilities are known precisely.
Common random numbers compare policies under identical random input sequences. Analysing paired cost differences can reduce noise when the policy outputs are positively related under matching scenarios. It does not eliminate Monte Carlo error and should not be confused with independent replications. Other variance-reduction techniques exist, but the first priority is a correct, transparent model. Keep exploratory scenario selection separate from claims about a pre-specified policy test. Repeatedly searching many random runs for a favourable result can mislead. Save seeds and configuration values with outputs. Reproducibility should allow a reviewer to recreate both favourable and unfavourable cases, not just the chosen presentation. Simulation is most useful when it exposes the conditions under which a decision works or fails.
14. Communicate a decision-ready result
A useful simulation report states the decision, model boundary, inputs, policies, run design, output measures and uncertainty. It separates exact calculations from simulated estimates and distinguishes Monte Carlo error from model limitations. For the classroom cash case, report that reserve thirty has lower exact expected cost under the specified probabilities and four-unit shortage penalty, while reserve twenty becomes preferable under the lower two-unit penalty. This communicates the dependency that matters instead of declaring one reserve universally optimal.
Use the interactive laboratory to compare reserve levels with the same seed, then change the seed to see sampling variation. Increase the run count and observe how estimates tend to stabilise around the exact benchmark. Finally, change a cost assumption and explain whether the preferred policy changes. A larger run cannot resolve disagreement about the correct cost or demand model. That requires business evidence. Before accepting any simulation answer, check probability totals, mapping boundaries, units, output denominators and the number of replications. The purpose is to learn about consequences under explicit assumptions and improve a decision, not to produce a large collection of random numbers with an impressive-looking average.
Guided exercise: audit a mapping error
A learner maps random integers 00 to 20 to low demand, 21 to 69 to medium demand and 70 to 99 to high demand. Counting the possible integers reveals probabilities 0.21, 0.49 and 0.30. These differ from the intended 0.20, 0.50 and 0.30. A very long simulation will converge toward the wrong model's expected demand, which is 10×0.21 + 20×0.49 + 30×0.30 = 20.9 lakh. Increasing the run length makes that incorrect model estimate more stable rather than correcting the boundary mistake.
Repair the intervals before comparing output with the twenty-one-lakh benchmark. Test every integer from zero through ninety-nine once and count the resulting categories. This deterministic test verifies the mapping exactly and is more informative for this defect than repeatedly drawing random samples. Then test the shortage formula with demand ten and reserve twenty. The result must be zero, while unused cash must be ten. A formula that reports negative shortage needs the maximum-with-zero rule. These small tests isolate logic errors before the full simulation runs. After verification, use random replications to examine sampling precision. The distinction between testing rules and estimating uncertain outcomes prevents a large simulation from becoming an expensive way to hide a simple implementation error.
Seeded cash-demand simulation
Demand is 10/20/30 lakh with probabilities 0.20/0.50/0.30. Reserve resets each day. Up to 100,000 runs. Educational pseudorandom generator, not for cryptographic use.
Practice and review
25 questions. One answer per question, no negative marking. Explanations remain readable without JavaScript.
Local browser storage only; no account synchronisation.
Ready: 25 questions.
References and scope
- IIBF CAIIB Rules & Syllabus 2026, PDF page 5: Official Module A scope; A01 to A09 are Clerk2Officer editorial identifiers.
Original exposition, cases and questions. Formula conventions are stated in the lesson. Automated checks support arithmetic and functionality; they are not independent academic certification.