AP CSP
AP Computer Science Principles / All lessons / Big Idea 3: Algorithms and Programming
3Big Idea 3: Algorithms and Programming
AP CSP topic 3.16

Simulations

A simulation is a program that models a real-world process, like the spread of a disease or traffic at an intersection. Simulations let people test ideas that would be too expensive, slow, or dangerous to try for real. Every simulation simplifies reality by leaving out details, so its results depend on the assumptions built into it. Random values often stand in for unpredictable events.

Simulations vocabulary

  • Simulation: A program that imitates a real-world process to study or predict it.
  • Model: A simplified representation of something real.
  • Assumption: A simplification or guess built into a model that affects its results.
  • Bias: A tilt in results caused by what a model includes or leaves out.

AP-style practice questions

Try each one, then open the answer. To save your progress, take this quiz in the interactive course.

Skill: Computing Innovations

1. Which of the following is the best reason to use a simulation to study how a wildfire spreads?

  1. (A) It is cheaper and safer than setting real fires to test ideas
  2. (B) It always predicts the exact result
  3. (C) It needs no assumptions
  4. (D) It removes the need for real data
Show answer

(A) It is cheaper and safer than setting real fires to test ideas Simulations let people test situations that are dangerous or costly in real life.

Skill: Computing Innovations
A traffic simulation assumes every driver obeys the speed limit and no cars break down.

2. Which of the following is most likely true about this simulation's results?

  1. (A) They will exactly match real traffic
  2. (B) They may differ from reality because the model leaves out real behaviors
  3. (C) They will be wrong every time
  4. (D) They cannot be repeated
Show answer

(B) They may differ from reality because the model leaves out real behaviors Simplifying assumptions can make a model's results differ from what really happens.

Skill: Abstraction in Program Development

3. Why do many simulations use random numbers?

  1. (A) To make the program shorter
  2. (B) To model events that happen by chance, like weather or arrivals
  3. (C) To encrypt the results
  4. (D) To prevent errors
Show answer

(B) To model events that happen by chance, like weather or arrivals Random values represent unpredictable parts of the real world.

Skill: Computing Innovations

4. Researchers run a disease-spread simulation 1,000 times instead of once. Which of the following best explains why?

  1. (A) Each run uses random values, so many runs show the range of likely outcomes
  2. (B) The first 999 runs are always wrong
  3. (C) Running it more makes it more accurate than real data
  4. (D) Simulations must run 1,000 times to start
Show answer

(A) Each run uses random values, so many runs show the range of likely outcomes Repeating a simulation with random inputs shows typical and extreme results.

Open 3.16 in the interactive course