Unit 06 β€” Simulation

Monte Carlo simulation done by hand: turning probabilities into random-number ranges, then simulating production against a lorry, stock against demand, and customers through a single counter β€” the 10-mark Q2 of both papers.

SESSIONS: 4 TEXTBOOK: ANDERSON & SWEENEY β€” CH. 12, SEC. 12.2–12.3, PP. 548–550, 563–575 SCOPE: MONTE CARLO Β· RANDOM-NUMBER RANGES Β· PRODUCTION / INVENTORY Β· QUEUE SIMULATION Assignment: A9 β€” Simulation 2
β—† What the papers actually ask from this unit

Simulation was a full 10-mark Q2 in both papers β€” the biggest single question in either paper Final QP p. 2 Re-Exam QP p. 2. It is pure procedure: no theory, no formula to forget, just a table you fill in carefully. That makes it the safest 10 marks on the paper.

  • Final Q2 β€” simulate a single-counter queue for 12 customers, then read five values off your table. Solved β†’
  • Re-Exam Q2 β€” simulate daily production against a lorry of fixed capacity and average the waiting units and empty spaces. Solved β†’
  • Assignment 9 β€” two production problems, one bakery profit problem, one car-wash queue. Solved β†’

1. What Simulation Is β€” the Monte Carlo Method Core syllabus concept

1Understand the Concept

Some problems are too messy for a formula β€” daily production that varies, customers who arrive at random. Simulation imitates the real system on paper: it uses random numbers to generate a realistic sequence of events (Monday's production, the next customer's arrival) according to the known probabilities, then simply counts what happens. The Monte Carlo method is the random-number technique used to do that.

2The six steps β€” write them as your method line

  1. Define the problem and the variable that varies (production per day, demand, inter-arrival time…).
  2. Write its probability distribution β€” given in the question.
  3. Cumulate the probabilities.
  4. Assign random-number ranges 00–99 in proportion to the probabilities (concept 2).
  5. Read the random numbers in order and convert each one to a value using the ranges.
  6. Simulate the rule (ship, sell, serve) day by day or customer by customer, then total and average what the question asks.

3Advantages and limitations β€” the theory part, if asked

AdvantagesLimitations
Handles problems too complex for an analytical formulaGives an estimate, not an exact optimum
Lets managers test a policy ("bake 30 boxes") without risking moneyA short run (10–15 trials) can be misleading β€” more trials, better estimate
Easy to explain β€” it is a table of what happened each dayResults depend on the random numbers used; a different set gives different numbers
Sources
Course Session plan, Unit 6: Monte Carlo simulation, inventory system, queuing system Policy p. 8
Textbook Anderson & Sweeney Ch. 12 (named by the session plan; not supplied as a file)

2. Assigning Random-Number Ranges Core syllabus concept

1The rule used by your answer keys

Two-digit random numbers run from 00 to 99 β€” a hundred equally likely values. Give each outcome as many of them as its probability Γ— 100, in order, starting at 00:

range for an outcome = (previous cumulative Γ— 100) to (its cumulative Γ— 100) βˆ’ 1

This is exactly how the Re-Exam key allocates them: probability 0.04 β†’ 00–03, cumulative 0.13 β†’ 04–12, and so on Key p. 2.

2Worked Example β€” the inter-arrival times of Final Q2

Question

Inter-arrival time 1, 2, 3, 4, 5 minutes with probabilities 0.2, 0.3, 0.3, 0.1, 0.1. Assign random-number ranges.

Solution
  1. Step 1 β€” Cumulate, then allocate
    Inter-arrival (min)ProbabilityCumulativeRandom-number range
    10.20.200 – 19
    20.30.520 – 49
    30.30.850 – 79
    40.10.980 – 89
    50.1190 – 99
  2. Step 2 β€” Check the last range ends at 99

    0.2 + 0.3 + 0.3 + 0.1 + 0.1 = 1.0, and the last range finishes at 99 βœ“. If it does not, a probability has been copied wrongly.

β˜… Ranges in five seconds

Write the cumulative probabilities as two-digit numbers: 20, 50, 80, 90, 100. Each range ends one below its cumulative and starts at the previous cumulative: 00–19, 20–49, 50–79, 80–89, 90–99. A random number of exactly 20 therefore belongs to the second outcome.

⚠ Where range marks are lost
  • Starting at 01 instead of 00. Both conventions exist in textbooks, but your faculty's keys use 00–99. Mixing them shifts every boundary number into the wrong outcome.
  • Overlapping ranges such as 00–20 and 20–49. Every random number must map to exactly one outcome.
  • Not showing the table. The cumulative column and the ranges carry marks even if a later step goes wrong.
Sources
Exam Final Q2 distribution QP p. 2 Β· Re-Exam key's range table Key p. 2

3. Production and Dispatch β€” the Lorry Problem Asked in the 2025-26 papers

1Understand the Concept

Daily output varies, but the vehicle that takes it away has a fixed capacity. Some days output is more than the vehicle holds and units are left waiting; other days it is less and the vehicle leaves with empty spaces. Simulation estimates both averages.

2The rule for each day β€” with the backlog carried forward

Available today = units left waiting from yesterday + today's production Shipped = min( capacity , available ) Left waiting = available βˆ’ shipped Empty spaces = capacity βˆ’ shipped Average waiting = Ξ£ left waiting Γ· number of days Average empty = Ξ£ empty spaces Γ· number of days

Units that miss today's lorry are still there tomorrow, so they join tomorrow's load. Assignment 9 says so in words, and the Re-Exam key treats day 2 that way (two scooters waiting after two days of 153) Key p. 2.

3Worked Example β€” Re-Exam Q2, the scooter lorry

Question β€” Re-Exam Q2, 10 marks QP p. 2

Daily production 146–154 scooters with probabilities 0.04, 0.09, 0.12, 0.14, 0.11, 0.10, 0.20, 0.12, 0.08. A lorry takes 152 at a time. Using the random numbers 80, 81, 76, 75, 64, 43, 18, 26, 10, 12, 65, 68, 69, 61, 57, find the average number of scooters waiting per day and the average number of empty spaces on the lorry.

Solution
  1. Step 1 β€” Random-number ranges
    Production / dayProbabilityCumulativeRandom-number range
    1460.040.0400 – 03
    1470.090.1304 – 12
    1480.120.2513 – 24
    1490.140.3925 – 38
    1500.110.539 – 49
    1510.10.650 – 59
    1520.20.860 – 79
    1530.120.9280 – 91
    1540.08192 – 99
  2. Step 2 β€” Simulate 15 days
    DayRNProductionWaiting from yesterdayAvailableShippedLeft waitingEmpty spaces
    180153015315210
    281153115415220
    376152215415220
    475152215415220
    564152215415220
    643150215215200
    718148014814804
    826149014914903
    910147014714705
    1012147014714705
    1165152015215200
    1268152015215200
    1369152015215200
    1461152015215200
    1557151015115101

    Day 2: 1 scooter waiting from day 1 + 153 made = 154 available; 152 go, 2 wait. Days 3–5 make exactly 152, so the 2 are still waiting. Day 6 makes 150: the 2 waiting fill the lorry to 152 exactly.

  3. Step 3 β€” Averages Average scooters waiting = 9 Γ· 15 = 0.6 per day Average empty spaces = 18 Γ· 15 = 1.2 per day
⚠ The official key slips on days 3–5

The key shows 2 scooters waiting after day 2 β€” so it is carrying the backlog forward β€” and 0 empty spaces on day 6 for the same reason. But it then shows 0 waiting on days 3, 4 and 5, although those days produce exactly 152 and nothing clears the 2 already waiting. Its total of 3 waiting (average 3/15) should be 9 (average 0.6); its empty-space total of 18 is right Key p. 2. If an examiner asks you to treat each day separately instead, say so and simply drop the "waiting from yesterday" column.

Sources
Exam Re-Exam Q2 QP p. 2 Β· key p. 2
Assignment Assignment 9 Q1–Q2 β€” solar panels and pharmaceutical crates p. 1 Β· solved β†’

4. Inventory and Profit Simulation Core syllabus concept

1Understand the Concept

Here demand is the random variable and the decision is a fixed stocking policy ("bake 30 every morning"). Each simulated day you compare demand with stock: sell the smaller of the two, salvage what is left over, and count any shortage as lost sales (and lost goodwill if a cost is given).

2The daily profit equation

Sold = min( demand , stock ) Unsold = stock βˆ’ sold (sold at salvage value) Shortage = max( 0 , demand βˆ’ stock ) (lost sales; Γ— goodwill cost if given) Profit = price Γ— sold + salvage Γ— unsold βˆ’ cost Γ— stock βˆ’ goodwill Γ— shortage

3Worked Example

Question

A vendor buys 30 newspapers a day at β‚Ή5 and sells them at β‚Ή8; unsold copies fetch β‚Ή1 as scrap. Demand is 20, 30 or 40 with probabilities 0.2, 0.5, 0.3. Simulate 5 days with random numbers 45, 12, 81, 67, 33 and find the average daily profit.

Solution
  1. Step 1 β€” Ranges
    DemandProbabilityCumulativeRandom-number range
    200.20.200 – 19
    300.50.720 – 69
    400.3170 – 99
  2. Step 2 β€” Simulate
    DayRNDemandSoldUnsoldShortProfit (β‚Ή)
    1453030008Γ—30 + 1Γ—0 βˆ’ 150 = 90
    21220201008Γ—20 + 1Γ—10 βˆ’ 150 = 20
    38140300108Γ—30 + 1Γ—0 βˆ’ 150 = 90
    4673030008Γ—30 + 1Γ—0 βˆ’ 150 = 90
    5333030008Γ—30 + 1Γ—0 βˆ’ 150 = 90
  3. Step 3 β€” Average Total profit = β‚Ή380; average = 380 Γ· 5 = β‚Ή76 per day

    Day 3 is the interesting one: demand was 40 but only 30 were bought, so 10 sales were lost. A question may ask for that lost revenue separately (10 Γ— β‚Ή8 = β‚Ή80).

Sources
Assignment Assignment 9 Q3 β€” the bakery, with salvage and goodwill cost p. 1 Β· solved β†’
Course Session plan: simulation of an inventory system Policy p. 8

5. Simulating a Queue Asked in the 2025-26 papers

1Understand the Concept

When arrivals and service times follow given discrete distributions (not Poisson/exponential), you cannot use the Unit 5 formulas β€” so you simulate. Two random-number streams drive it: one for the gap between arrivals, one for the length of each service.

2The columns of the table, in order

Arrival time = previous arrival time + inter-arrival time Service starts = later of ( arrival time , previous service end ) Waiting = service starts βˆ’ arrival time Service ends = service starts + service time Time in system = service ends βˆ’ arrival time ( = waiting + service ) Server idle = arrival time βˆ’ previous service end, if positive
β˜… The one line that decides everything

Service starts = MAX(arrival time, previous service end). If the customer arrives after the server is free, there is no wait and the server was idle in between; if before, the customer waits. Get this column right and every other column follows by addition.

3Worked Example β€” Final Exam Q2 (10 marks)

Question β€” Final Exam Q2 QP p. 2

Inter-arrival times 1–5 min (probabilities 0.2, 0.3, 0.3, 0.1, 0.1); service times 1, 3, 5 min (0.2, 0.5, 0.3). The first customer arrives at time 0. Arrival random numbers (customers 2–12): 61, 55, 01, 33, 19, 25, 79, 93, 18, 49, 92. Service random numbers (customers 1–12): 28, 01, 61, 85, 67, 53, 62, 79, 66, 63, 33, 77. Find (1) service start of customer 11, (2) waiting time of customer 5, (3) arrival time of customer 4, (4) time in system of customer 9, (5) service end of customer 7.

Solution
  1. Step 1 β€” Ranges for both distributions
    Inter-arrival (min)ProbabilityCumulativeRandom-number range
    10.20.200 – 19
    20.30.520 – 49
    30.30.850 – 79
    40.10.980 – 89
    50.1190 – 99
    Service time (min)ProbabilityCumulativeRandom-number range
    10.20.200 – 19
    30.50.720 – 69
    50.3170 – 99
  2. Step 2 β€” The simulation table
    CustRN (arrival)Inter-arrivalArrival timeRN (service)Service timeService startsWaitingService endsTime in systemServer idle
    1β€”0028300330
    2613301130410
    3553661360932
    40117855921470
    533296731451780
    61911053317720100
    72521262320823110
    87931579523828130
    99352066328831110
    1018121633311034130
    1149223333341137140
    129252877537942140
  3. Step 3 β€” Read off the five answers (1) Customer 11 service starts at minute 34 (2) Customer 5 waits 5 minutes (3) Customer 4 arrives at minute 7 (4) Customer 9 spends 11 minutes in the system (5) Customer 7 service ends at minute 23

    βœ“ All five match the official key Key p. 2. Totals worth quoting if asked: average wait 5.67 min, average time in system 9 min, server idle 2 min.

⚠ Queue simulation β€” the classic slips
  • Using the first arrival random number for customer 1 when the question says customer 1 arrives at time 0. In Final Q2 the arrival stream starts at customer 2.
  • Adding the service time to the arrival time instead of to the service start time.
  • Reading off the wrong column. "Time spent in the system" is end βˆ’ arrival; "waiting time in queue" is start βˆ’ arrival.
Sources
Exam Final Q2 QP p. 2 Β· key p. 2
Assignment Assignment 9 Q4 β€” car wash, 6 customers p. 2 Β· solved β†’
Course Session plan: simulation of a queuing system Policy p. 8