AP CSP Topic 3.16 Guided Notes - Simulations
Big Idea 3: Algorithms and Programming · Topic 3.16 · Guided Notes (Student)
Simulations — Guided Notes
Fill these in during class or catch up here if you were absent. Print this page or work on paper — then check yourself with the CFUs on the Topic 3.16 page.
Print these notesAll CSP topics
Day 1: Turning the World into Numbers
Today’s objectives
- Explain that a simulation is an abstraction of a more complex phenomenon built for a specific purpose, developed by removing detail and simplifying (LO AAP-3.F)
- Use a random number generator to model real-world variability, and run many trials to draw inferences about how a phenomenon behaves (LO AAP-3.F)
Bell ringer
A city planner needs to know: 'Out of the next 100 days, roughly how many will it rain, so we can schedule road work?' The only way to truly find out is to WAIT for 100 real days — and even then you'd get just one run of history, which might be unusually wet or dry.
Write 2–4 sentences: Waiting is impossible, so propose a faster way to get an answer. What is the FEWEST information about rain you'd need to build a tiny 'pretend weather' you could run over and over in seconds? What real details would you throw away?
01. What a Simulation Is (and Isn't)
Key Vocabulary (LO AAP-3.F)
| Term | Definition (write it) |
|---|---|
| Simulation | |
| Abstraction (simplifying) | |
| Changing state | |
| Drawing inferences | |
| Random number generator |
A Simulation Is an Abstraction for a Purpose
- A simulation is an abstraction of a more complex phenomenon that is built .
- The process of developing a simulation involves .
- How much detail to keep is decided by .
The Real Sky vs. the Model of It
The real phenomenon
The simulation of it
- Reducing all of real weather to a single 'chance of rain' number is an example of .
- A model that tried to include every real detail would be useless because .
AP TIP: A simulation that kept 'every detail' would just be the real world again — and be equally impossible to run. Simplifying is the whole point.
One Random Roll = One Simulated Day
The whole sky is reduced to one number; RANDOM decides today's weather. Run it again and the printed outcome may change.
AP Pseudocode (what the exam tests)
chanceOfRain ← 40
roll ← RANDOM(1, 100)
IF(roll ≤ chanceOfRain)
{
sky ← "rain"
}
ELSE
{
sky ← "shine"
}
DISPLAY(sky)
Python (the runnable version)
import random
chanceOfRain = 40
roll = random.randint(1, 100)
if roll <= chanceOfRain:
sky = "rain"
else:
sky = "shine"
print(sky)
Output
rain
Run and edit this yourself in the coding exercises for this topic.
Stop and think
- In two sentences, explain why developing a simulation of weather means REMOVING detail. Use the word 'purpose.'
- A classmate says, 'My rain simulation would be more accurate if I added temperature, wind, and humidity to it.' Give one reason more detail can make a simulation WORSE for its purpose, and one reason it might help.
- Name a real phenomenon you could not study directly, and state the single most important detail you would KEEP and one you would delete to build a simulation of it.
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.16 page.
02. Randomness Models the Real World
RANDOM Turns One Model into Real-World Variety
- A random number generator is used to simulate .
- Because each run uses different random values, the simulation reflects .
- A single trial is noise, but many trials let you .
A Thousand Days, One Inference
The same one-number model, run 1000 times. The fraction lands near 0.40 but differs every run — the inference is stable even though each trial varies.
AP Pseudocode (what the exam tests)
rainy ← 0
REPEAT 1000 TIMES
{
IF(RANDOM(1, 100) ≤ 40)
{
rainy ← rainy + 1
}
}
DISPLAY(rainy / 1000)
Python (the runnable version)
import random
rainy = 0
for i in range(1000):
if random.randint(1, 100) <= 40:
rainy = rainy + 1
print(rainy / 1000)
Output
0.397
Run and edit this yourself in the coding exercises for this topic.
Trace One Simulated Week
Given each day's RANDOM(1, 100) roll, decide rain (roll ≤ 40) or shine, and keep a running count of rainy days. Fill the blanks yourself.
Complete the empty cells.
| Day | Roll — RANDOM(1, 100) | Rain? (roll ≤ 40) | Rainy days so far |
|---|---|---|---|
| Mon | 12 | rain | 1 |
| Tue | 77 | shine | 1 |
| Wed | 39 | 2 | |
| Thu | 40 | rain | |
| Fri | 88 | shine | 3 |
| Sat | 5 | 4 | |
| Sun | 61 | shine | 4 |
Watch out — “A Good Simulation Includes Every Detail”
Myth: The more real-world detail a simulation includes, the better and more trustworthy it is — a great simulation models everything.
Explain why this is wrong:
Stop and think
- In one sentence, explain what RANDOM is standing in for when it decides each simulated day's weather. Use the word 'variability.'
- The 7-day trace rained about 57% of the time even though the model uses a 40% chance. Explain why, and predict what happens to that percentage as you simulate 10,000 days instead of 7.
- A student runs the 1000-day model twice and gets 0.397 then 0.412, and concludes the program is broken. Explain, using 'changing state,' why two different results are exactly what should happen.
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.16 page.
Today in one box
- A simulation is an abstraction of a more complex phenomenon, built for a specific purpose — not a copy of reality
- Developing a simulation means REMOVING detail and simplifying; a model that kept everything would be unrunnable
- A random number generator simulates the variability of the real world, so each run steps through a different changing state
- One trial is noise; running MANY trials lets you draw a stable inference about the phenomenon
Before next class: Before tomorrow: a flight simulator used to train pilots never simulates a bird flying into the engine. Name one thing that makes that a smart simplification — and one real danger it creates for a pilot trained only on the simulator.
Day 2: Judging the Model Against the World
Today’s objectives
- Identify when a simulation is the appropriate tool because a real experiment is impractical, and explain how reruns formulate and refine hypotheses (LO AAP-3.F)
- Compare a simulation with its real-world context by finding the bias created by the real elements its designers included or excluded (LO AAP-3.F)
Bell ringer
Yesterday's teaser: a flight simulator used to train pilots never simulates a bird flying into an engine. Trainee pilots log hundreds of hours on it and are certified partly on their simulator performance.
Write 2–4 sentences: Give one strong reason it is SMART for the simulator to leave bird strikes out. Then name one real danger created for a pilot trained only on it. Finish: who decided the bird strike wasn't worth including, and how would that choice bias what pilots are ready for?
01. When Simulations Beat Reality
Simulate When Reality Is Impractical
- Simulations are most useful when real-world events are .
- The CED's six triggers for 'impractical' are .
- If a real experiment is already cheap, fast, and safe, a simulation may be .
Too Big, Too Slow, Too Dangerous
Each row is one of the CED's reasons a real experiment is impractical. Match the example and what the simulation makes possible; fill the blanks yourself.
Complete the empty cells.
| Why the real experiment is impractical | A real example | What the simulation makes possible |
|---|---|---|
| Too big | The gravitational dance of a whole galaxy | Watch millions of stars move on one screen |
| Too small | How a drug molecule binds to a virus | |
| Too fast | The instant of a car crash | Slow the impact to inspect each millisecond |
| Too slow | Climate shifting over 200 years | |
| Too expensive | Crash-testing thousands of real cars | Total thousands of virtual cars for free |
| Too dangerous | Train operators at zero real risk |
Every Rerun Is a Cheap Experiment
- Simulations facilitate the of hypotheses.
- Changing one value and re-running the model is a way to .
- Cheap, repeatable runs let a researcher before committing real resources.
Change One Number, Ask a New Question
The same weather model wrapped in a procedure. Raising the chance argument from 40 to 60 is a hypothesis test — run for free.
AP Pseudocode (what the exam tests)
PROCEDURE rainyDays(chance, days)
{
rainy ← 0
REPEAT days TIMES
{
IF(RANDOM(1, 100) ≤ chance)
{
rainy ← rainy + 1
}
}
RETURN(rainy)
}
DISPLAY(rainyDays(40, 1000))
DISPLAY(rainyDays(60, 1000))
Python (the runnable version)
import random
def rainyDays(chance, days):
rainy = 0
for i in range(days):
if random.randint(1, 100) <= chance:
rainy = rainy + 1
return rainy
print(rainyDays(40, 1000))
print(rainyDays(60, 1000))
Output
398 601
Run and edit this yourself in the coding exercises for this topic.
Stop and think
- For each situation, decide whether a simulation is the right tool and name the reason: (a) predicting how a new skyscraper sways in a 100-year windstorm, (b) finding out whether a coin in your pocket is fair.
- A team wants to know if widening a highway lane would cut rush-hour jams. Explain how a traffic simulation lets them formulate and refine this hypothesis without closing the real road.
- In one sentence, state the trigger the exam is looking for when it asks whether a simulation is appropriate — and why 'a computer could do it faster' is NOT that trigger.
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.16 page.
02. Bias: What You Leave Out
Simulations Can Contain Bias
- A simulation can contain bias derived from .
- Simplifying and bias are two faces of the same act because .
- Running a model on a computer does not remove bias because .
Included vs. Excluded Elements
Included (what the model uses)
Excluded (silently left out)
- When comparing a simulation to the real world, the bias is usually hiding in .
- The excluded elements are especially dangerous because the model .
AP TIP: The bias almost never lives in what a model shows you — it lives in what the model never had a chance to consider.
Audit the Simulation for Bias
For each simulation, name a real element it leaves out and how that omission biases the result. Fill the blanks yourself.
Complete the empty cells.
| The simulation | A real element it leaves out | How leaving it out biases the result |
|---|---|---|
| A rain app trained only on last year's data | It keeps predicting rain that no longer comes | |
| A traffic model built from weekday rush hours only | Weekend and holiday travel patterns | It mistimes signals whenever it is not a weekday |
| A game-balance test run only by expert players | How first-time beginners actually play | |
| A wait-time model assuming equal machines per precinct | It hides the long lines in under-served neighborhoods |
Watch out — “A Computer Made It, So the Numbers Are Objective”
Myth: Because a computer and random numbers produced the simulation's results, the output is neutral, objective fact and cannot be biased.
Explain why this is wrong:
Stop and think
- A fitness app estimates 'calories burned' from a model built only on data from young male athletes. Name one excluded group and predict which way the estimates are biased for people outside the training data.
- Return to the flight simulator with no bird strikes. Compare it to the real world: state the excluded element and the specific bias it creates in what pilots are prepared for.
- A classmate says, 'This simulation can't be biased — it uses RANDOM, so every outcome is equally fair.' In two sentences, explain the flaw using the word 'excluded.'
Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.16 page.
Common AP Traps
Three ways Topic 3.16 loses points on the exam — one minute now, real points in May.
Developing a simulation means SIMPLIFYING, not copying — in your own words:
Bias comes from included/excluded elements, not from RANDOM — in your own words:
'Impractical' is the trigger to simulate — in your own words:
Simulations, in One Slide
- A simulation is an abstraction of a more complex phenomenon, built for a purpose by REMOVING detail and simplifying — not a copy of reality.
- RANDOM models the real world's variability, so many trials move through a changing state and yield a stable inference.
- Simulations are the right tool when real experiments are impractical — too big, small, fast, slow, expensive, or dangerous — and reruns refine hypotheses.
- A simulation can contain bias from the real elements its designers included or EXCLUDED; a computer running it does not make it objective.
Exit check — I can…
- ☐ explain how a simulation represents a real phenomenon by abstracting away detail and simplifying for a purpose (LO AAP-3.F)
- ☐ use RANDOM to model real-world variability and run many trials to draw an inference (LO AAP-3.F)
- ☐ decide when a simulation is the right tool because a real experiment is impractical, and how reruns refine hypotheses (LO AAP-3.F)
- ☐ compare a simulation to the real world and locate the bias created by the elements it included or excluded (LO AAP-3.F)
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]