Get startedGet started for free

Simulating the Independent Shooter

Simulating a basketball player who has independent shots uses the same mechanism that we used to simulate a coin flip. To simulate a single shot from an independent shooter with a shooting percentage of 50% we type, outcomes <- c("H", "M") sim_basket <- sample(outcomes, size = 1, replace = TRUE)

To make a valid comparison between Kobe and our simulated independent shooter, we need to align both their shooting percentages and their numbers of attempted shots.

This exercise is part of the course

Data Analysis and Statistical Inference

View Course

Exercise instructions

  • Run a simulation to sample 133 shots (the number of shots of Kobe in this data set) with a shooting percentage of 45%. Assign the output of this simulation to a new object called sim_basket.
  • Inspect your simulation with table().

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Run the simulation and assign the result to sim_basket.
outcomes <- c("H", "M")
sim_basket <- 

# Inspect your simulation
Edit and Run Code