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.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
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
- Topic 3.12-3.14 Procedures and Libraries: procedures are named, reusable blocks with parameters and return values, and libraries and APIs package procedures so programmers reuse code through abstraction.
A focused answer to AP CSP Topics 3.12 to 3.14, covering defining and calling procedures, parameters and return values, procedural abstraction, modularity, libraries and APIs, and how reusing procedures manages complexity, with worked pseudocode.
- Topic 3.9 Developing Algorithms: an algorithm is a finite set of instructions that accomplishes a task, built by combining sequencing, selection and iteration, and different algorithms can solve the same problem.
A focused answer to AP CSP Topic 3.9, covering what an algorithm is, the three building blocks (sequencing, selection, iteration), expressing algorithms in pseudocode and language, that different algorithms can solve the same problem, and standard list algorithms.
- Topic 3.11/3.17/3.18 Binary Search and Efficiency: binary search finds a value in a sorted list far faster than linear search, and algorithms are compared by efficiency, with some problems being unsolvable or only approximable.
A focused answer to AP CSP Topics 3.11, 3.17 and 3.18, covering linear versus binary search, why binary search needs a sorted list, reasonable versus unreasonable running time, polynomial versus exponential growth, heuristics, and undecidable problems.
- Topic 3.2 Data Abstraction: data abstraction manages complexity by giving a collection of data a single name, most commonly using a list to represent many values as one variable.
A focused answer to AP CSP Topic 3.2, covering what data abstraction is, how a list represents many values under one name, the benefits for managing and modifying programs, the link to procedural abstraction, and why abstraction manages complexity.
- Topic 5.1 Beneficial and Harmful Effects: computing innovations have both beneficial and harmful effects on society, economy and culture, and effects may be intended or unintended.
A focused answer to AP CSP Topic 5.1, covering how a single computing innovation can have both beneficial and harmful effects, intended versus unintended consequences, effects on individuals and society, and how to analyze an innovation's impact for the exam.
Sources & how we know this
- AP Computer Science Principles Course and Exam Description — College Board (2025)