Worked examples of Simulation to try before you open each solution, then practice
problems with answers.
Worked Examples
Example 1
easy
A weather app uses a computer simulation to predict tomorrow's weather. What is a simulation and why is it useful?
Show solution
Answer
A simulation models a real-world process using computation. It is useful for making predictions and testing scenarios without real-world cost or risk.
First step
1.
Step 1: A simulation is a computer model that imitates a real-world process or system using mathematical rules and data.
Full solution
2.
Step 2: The weather simulation uses current data (temperature, pressure, wind) and applies physics equations to predict future conditions.
3.
Step 3: Simulations are useful because they let us explore scenarios that would be too expensive, dangerous, or time-consuming to test in real life.
Simulations are used in weather forecasting, flight training, medical research, and engineering. They rely on abstraction — modelling the essential features while ignoring unnecessary detail.
Example 2
medium
A traffic simulation models cars on a road. Each car has a speed and position. Every second, each car moves forward by its speed, unless the car ahead is too close (then it slows down). What simplifications (abstractions) does this simulation make?
Example 3
easy
A dice-roll simulation outputs 1,3,5,2,6 across 5 trials. Estimated mean roll?
Example 4
medium
A weather model predicts 80% chance of rain. Out of 100 such forecasts, 60 turn out rainy. Is the model well-calibrated?
Example 5
hard
Two integration step sizes: h=0.1 gives error ∼0.01; what error do you expect at h=0.05 for a first-order method?
Example 6
challenge
A climate model is run with two different seeds, yielding diverging trajectories after 50 years. How do scientists extract a useful prediction?
Practice Problems
Try each one, then open the solution to compare your method.
Example 1
medium
You are designing a simulation to model the spread of a disease through a school. What variables would you include, and what would you simplify?
Example 2
hard
A dice-rolling simulation generates random numbers 1-6 to simulate rolling a die 1000 times. Why might the simulated results differ from the theoretical probability (1/6 each)? What would make them converge?
Example 3
easy
A simulation uses St+1=St+1 with S0=0. What is S3?
Example 4
easy
Does a simulation model every detail of reality, or a chosen subset of variables?
Example 5
easy
Why run a simulation instead of the real experiment?
Example 6
easy
A dice simulation should produce values in what range for a standard die?
Example 7
easy
If a simulation's assumptions are wrong, are its predictions reliable?
Example 8
easy
A growth model is St+1=2St with S0=1. What is S2?
Example 9
easy
Adding more and more variables to a simulation tends to make it ____.
Example 10
easy
A simulation steps once per timer event. What programming style does it rely on?
Example 11
medium
With St+1=St+2 and S0=5, find S4.
Example 12
medium
A coin-flip simulation runs 1000 trials and gets 600 heads. Estimated probability of heads?
Example 13
medium
A model rounds St+1=1.1St to 1 decimal each step, S0=1.0. Compute S2.
Example 14
medium
A population model St+1=St+10 starts at 50. After how many steps does it first exceed 100?
Example 15
medium
Two simulations start identically but one uses step size 1.0 and the other 0.5 (half steps, twice as many). Which generally tracks reality more closely?
Example 16
medium
A simulation predicts a bridge holds 10 tons, but the real bridge fails at 6. What should you do before trusting future predictions?
Example 17
medium
A queue simulation processes one customer per tick and a new customer arrives every other tick. Starting empty, how many wait in queue after 4 ticks?
Example 18
medium
A simulation St+1=St−3 models a draining tank starting at S0=20. What is S5?
Example 19
medium
A traffic-light simulation cycles green->yellow->red every tick. Starting on green, what color is it after 4 ticks?
Example 20
challenge
In St+1=St(1+r) with r=0.05 and S0=100, give a closed form for St and compute S3 to 2 decimals.
Example 21
challenge
A simulation has 0.1% error per step that compounds multiplicatively. After 1000 steps, roughly what factor of error accumulates? Use (1.001)1000≈e.
Example 22
challenge
Design choice: model a forest fire either cell-by-cell on a grid or with a single aggregate 'percent burned' variable. State one advantage of each and which suits predicting fire shape.
Example 23
easy
A simulation uses St+1=St+5 with S0=2. Find S4.
Example 24
easy
A simulation of a flipped coin generates a number 0 or 1. To estimate P(heads), what should you do with the outputs?
Example 25
easy
With St+1=St−1 and S0=10, at what step does St first equal 0?
Example 26
easy
A growth model St+1=3St has S0=1. Compute S3.
Example 27
easy
Which is an abstraction a traffic simulation might make: (a) cars are points, (b) every license plate is modeled?
Example 28
medium
With St+1=St+t and S0=0, find S4.
Example 29
medium
A coin simulation gives 480 heads in 1000 flips. Estimated P(heads)?
Example 30
medium
A predator-prey model needs to track populations and a contact rate. Name one variable to keep and one detail safe to drop.
Example 31
medium
A simulation St+1=St⋅0.9 with S0=100 models radioactive decay. Compute S2.
Example 32
medium
A simulation's predictions diverge from reality after step 100. What is most likely the cause: random noise or compounding model error?
Example 33
medium
A simulation runs 10000 trials per minute. How many trials in 6 minutes?
Example 34
medium
Simulation St+1=St+1 if St<5, else St+1=St−1. Starting at S0=4, find S3.
Example 35
medium
An SIR disease model tracks S, I, R counts. Which simplification trades realism for tractability: (a) homogeneous mixing, (b) tracking each individual home address?
Example 36
medium
Compounding model: St+1=St(1+0.1) with S0=100. Compute S2.
Example 37
medium
A queue simulation: arrivals occur every 2 ticks, service takes 3 ticks. After 12 ticks starting empty, how many customers entered service?
Example 38
hard
Recurrence St+1=2St−1, S0=2. Find S4.
Example 39
hard
A Monte Carlo estimator uses N samples and has error ∝1/N. To halve error, how many more samples are needed?
Example 40
hard
A flight simulator passes all known test scenarios but a real plane crashes when a flap fails. What was the model missing?
Example 41
challenge
A logistic model St+1=St+0.1St(1−St/100), S0=10. Compute S1 to 2 decimals.
What to focus on
Core idea:Simulations simplify reality by choosing which variables to model and which details to ignore.
Common stuck point:Simulations are only as good as their underlying assumptions—garbage in, garbage out.
Ask yourself:Does a program apply an update rule over and over, one time step at a time, to show how a system changes?
Concept recap
Using a computer program to model and experiment with a real-world system or process. Simulations represent key variables and their relationships mathematically, allowing you to test scenarios, make predictions, and explore outcomes without real-world cost or risk.
A simulation is a flight simulator for any system: a cockpit where nothing can really crash, so you can try a storm, an engine failure or a bad landing as often as you like. What you learn carries over only if the simulator's physics match the real plane closely enough.