2025-10-06
Definition: Outcome
The possible results in a random phenomenon.
Definition: Sample Space
The sample space \(S\) is the set of all outcomes
Definition: Event
An event is a collection of some outcomes. An event can include multiple outcomes or no outcomes (a subset of the sample space).
When thinking about events, think about outcomes that you might be asking the probability of. For example, what is the probability that you get a heads or a tails in one flip? (Answer: 1)
A probability model for a random phenomenon includes a sample space, events, random variables, and a probability measure.
Simulation
Simulation involves using a probability model to artificially recreate a random phenomenon, many times, usually using a computer.
We simulate outcomes and values of random variables according to the model’s assumptions.
Seeing Theory, Chapter 1: Basic Probability, Chance Events
Define the probability space and related random variables and events, including assumptions.
Run the simulation to generate outcomes according to the assumptions.
Analyze the output using plots and summary statistics like relative frequencies and averages.
Investigate how results change when assumptions or parameters of the model are altered.
discrete RVs simmies
Example: Simulating Two Rolls of a Fair Four-Sided Die
Let \(X\) be the sum of two rolls of a fair four-sided die, and \(Y\) be the larger of the two rolls. How would we simulate \(X\) and \(Y\) separately?
We can also use R
to sample from the box or spinner
The sample()
function in R allows us to simulate equally likely draws
For example, we can simulate a coin flip
continuous RVs simmies
doing it in R
sample()
function is a powerful tool for simulating draws from a box model.# A box model for two rolls of a fair four-sided die
rolls <- sample(x = c(1, 2, 3, 4), size = 2, replace = TRUE)
# Simulate 10 repetitions, with each row representing a pair of rolls
reps <- 10
replicate(reps, sample(x = 1:4, size = 2, replace = TRUE))
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 4 1 1 4 2 4 4 1 3
[2,] 3 2 2 3 1 1 1 1 1 3
We can apply functions to the simulated outcomes to get the values of our random variables.
Let’s simulate X (sum) and Y (max).
reps <- 1000
simulations <- replicate(reps, sample(x = 1:4, size = 2, replace = TRUE))
# Calculate X (the sum) for each repetition
X_simulated <- apply(simulations, 2, sum)
# Calculate Y (the max) for each repetition
Y_simulated <- apply(simulations, 2, max)
# Display the first 10 values for X and Y
head(X_simulated, 10)
[1] 3 6 8 4 5 8 4 5 4 6
[1] 2 3 4 2 3 4 3 4 2 3
Lesson 3 Slides