Skip to main content
United StatesComputer Science PrinciplesSyllabus dot point

How do simulations model real phenomena, and how are random values used to add variability?

Topic 3.15/3.16 Random Values and Simulations: simulations are simplified, abstract models of real phenomena that often use random values to represent variability, trading detail for speed, safety and repeatability.

A focused answer to AP CSP Topics 3.15 and 3.16, covering the RANDOM procedure and generating random values, what a simulation is, why simulations are abstractions, their advantages and limitations, and using randomness to model variability, with worked pseudocode.

Generated by Claude Opus 4.810 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this topic is asking
  2. Random values
  3. What a simulation is
  4. Why simulations are abstractions
  5. Advantages and limitations
  6. Using randomness to model variability
  7. Try this

What this topic is asking

The College Board (Topics 3.15 and 3.16) wants you to use random values and understand simulations. AP CSP pseudocode provides RANDOM(a, b), which returns a random integer in the inclusive range a to b, used to add variability. A simulation is a simplified, abstract model of a real phenomenon, often using randomness to represent uncertain events. You need the advantages (safety, cost, speed, repeatability) and limitations (simplification, assumptions) of simulations, and why a simulation is an abstraction.

Random values

roll ← RANDOM(1, 6)
DISPLAY(roll)

Each run may display any of 1 through 6.

What a simulation is

Why simulations are abstractions

A simulation cannot capture every detail of reality, and it should not try to. It is an abstraction: it keeps what matters for the question and leaves out the rest. A traffic simulation models cars and lights but not the color of each car. This simplification is what makes simulations tractable.

Advantages and limitations

Using randomness to model variability

Randomness makes a simulation realistic when outcomes are uncertain. Running many trials and averaging the results estimates real-world probabilities. This is why simulations and random values are taught together.

Try this

Q1. What range of values can RANDOM(3, 8) return? [1 point]

  • Cue. Any integer from 3 to 8 inclusive: 3, 4, 5, 6, 7 or 8.

Q2. Give one reason a scientist might use a simulation instead of a real experiment. [1 point]

  • Cue. It is safer, cheaper, faster, or can be repeated many times under controlled conditions without real-world risk (any one of these).

Exam-style practice questions

Practice questions written in the style of College Board exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

AP 2022 (style)1 marksMultiple choice. In AP CSP pseudocode, `RANDOM(1, 6)` is used to model rolling a die. Which statement is true? (A) It always returns 6. (B) It returns a random integer from 1 to 6, inclusive of both ends. (C) It returns a random decimal between 1 and 6. (D) It returns the average of 1 and 6.
Show worked answer →

The answer is (B).

RANDOM(a, b) returns a random integer from a to b, including both endpoints. So RANDOM(1, 6) returns one of 1, 2, 3, 4, 5 or 6, each modelling a die face. (A) is wrong: the result varies. (C) is wrong: it returns an integer, not a decimal. (D) is wrong: it is random, not an average.

Markers reward knowing RANDOM(a, b) returns a random integer in the inclusive range, which is how randomness models variability.

AP 2021 (style)3 marksFree response (short). Give one advantage and one limitation of using a simulation instead of conducting a real-world experiment, and explain why a simulation is considered an abstraction.
Show worked answer →

A 3-point question on simulations as abstractions.

Advantage (point 1): A simulation can be safer, cheaper or faster than a real experiment, and can be repeated many times under controlled conditions (for example testing a bridge design or a pandemic response without real-world risk).

Limitation (point 2): A simulation leaves out detail and relies on assumptions, so its results may not perfectly match reality and can be wrong if the model is flawed.

Abstraction (point 3): A simulation is a simplified model that includes the relevant features and omits others, which is exactly what abstraction means. A complete, valid answer covers all three.

Related dot points

Sources & how we know this