## Rows: 133
## Columns: 6
## $ vs <fct> ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL…
## $ game <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ quarter <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3…
## $ time <fct> 9:47, 9:07, 8:11, 7:41, 7:03, 6:01, 4:07, 0:52, 0:00, 6:35…
## $ description <fct> Kobe Bryant makes 4-foot two point shot, Kobe Bryant misse…
## $ shot <chr> "H", "M", "M", "H", "H", "M", "M", "M", "M", "H", "H", "H"…
Excercise 1 What does a streak length of 1 mean, i.e. how many hits and misses are in a streak of 1? What about a streak length of 0?
Answer:
Based on the definition where a shooting streak is the number of consecutive baskets made until a miss occurs:
Streak Length of 1: Means 1 hit followed by 1 miss (1H, 1M). You made 1 shot and then missed on the next attempt, ending that streak.
Streak Length of 0: Means 0 hits followed by 1 miss (0H, 1M). You missed immediately on your shot attempt without making any preceding baskets (e.g., consecutive misses like M | M each count as individual streaks of length 0).
Every streak, regardless of its length, always ends with exactly 1 miss.
END ********************************************************************************
Exercise 2 Describe the distribution of Kobe’s streak lengths from the 2009 NBA finals. What was his typical streak length? How long was his longest streak of baskets? Make sure to include the accompanying plot in your answer.
Answer: Distribution of Kobe’s Streak Lengths Shape & Features: The distribution of Kobe Bryant’s streak lengths is strongly right-skewed and unimodal. Most of his streaks were short, with the vast majority consisting of 0 consecutive made baskets.
Typical Streak Length: His typical (median / mode) streak length was 0.*
Longest Streak: His longest streak of made baskets during the 2009 NBA Finals was 4.
Accompanying Plot In R, using the OpenIntro kobe_basket dataset and the calculated streaks (kobe_streak), the accompanying plot is generated using a bar chart:
Visual Summary of the Plot:
X-axis (Streak Length): Ranges from 0 to 4.
Y-axis (Count):
The bar for 0 is by far the tallest (around 39 instances), showing that missing on the first ** attempt or immediately following another miss was the most common outcome.
The counts steadily drop off for streak lengths of 1, 2, 3, and 4.
## [1] "tails"
## [1] "tails" "heads" "heads" "heads" "heads" "heads" "tails" "tails" "heads"
## [10] "heads" "heads" "heads" "heads" "heads" "tails" "heads" "tails" "tails"
## [19] "heads" "heads" "heads" "heads" "heads" "tails" "heads" "tails" "tails"
## [28] "tails" "heads" "tails" "tails" "heads" "tails" "tails" "tails" "heads"
## [37] "tails" "tails" "tails" "heads" "tails" "tails" "tails" "heads" "tails"
## [46] "heads" "heads" "heads" "tails" "tails" "tails" "heads" "heads" "heads"
## [55] "heads" "tails" "tails" "heads" "heads" "heads" "tails" "heads" "tails"
## [64] "heads" "heads" "tails" "heads" "tails" "heads" "tails" "tails" "tails"
## [73] "tails" "heads" "heads" "heads" "tails" "heads" "tails" "heads" "tails"
## [82] "heads" "tails" "tails" "tails" "heads" "tails" "heads" "tails" "heads"
## [91] "heads" "heads" "heads" "heads" "heads" "heads" "heads" "tails" "heads"
## [100] "heads"
## sim_fair_coin
## heads tails
## 56 44
Excercise 3 In your simulation of flipping the unfair coin 100 times, how many flips came up heads? Include the code for sampling the unfair coin in your response. Since the markdown file will run the code, and generate a new sample each time you Knit it, you should also “set a seed” before you sample. Read more about setting a seed below.
Answer:
# Define outcome possibilities
coin_outcomes <- c("heads", "tails")
# Set a random seed for reproducible results
set.seed(35797)
# Simulate flipping an unfair coin 100 times (20% heads, 80% tails)
sim_unfair_coin <- sample(coin_outcomes, size = 100, replace = TRUE, prob = c(0.2, 0.8))
# Count the frequency of heads and tails
table(sim_unfair_coin)
## sim_unfair_coin
## heads tails
## 26 74
In my simulation of flipping the unfair coin 100 times heads came up for 26 times.
Simulating the Independent Shooter
Excercise 4 What change needs to be made to the sample function so that it reflects a shooting percentage of 45%? Make this adjustment, then run a simulation to sample 133 shots. Assign the output of this simulation to a new object called sim_basket.
Answer:
# Define shot outcomes
shot_outcomes <- c("H", "M")
# Set seed for reproducibility
set.seed(12345)
# Simulate 133 shots for an independent shooter with a 45% shooting percentage
sim_basket <- sample(shot_outcomes, size = 133, replace = TRUE, prob = c(0.45, 0.55))
# View the counts of hits and misses
table(sim_basket)
## sim_basket
## H M
## 65 68
Explanation of Changes
Excercise 5 Using calc_streak, compute the streak lengths of sim_basket, and save the results in a data frame called sim_streak.
Answer:
# Compute streak lengths for the simulated independent shooter
sim_streak <- calc_streak(sim_basket)
# View the first few rows of the resulting data frame
head(sim_streak)
## length
## 1 4
## 2 0
## 3 0
## 4 0
## 5 2
## 6 0
Explanation
calc_streak(sim_basket): Calculates the length of each consecutive streak of made shots (“H”) before a miss (“M”) occurs for your simulated dataset.
sim_streak: Stores the output as a data frame containing the vector of streak lengths for comparison against Kobe’s streak lengths (kobe_streak).
Excercise 6 Describe the distribution of streak lengths. What is the typical streak length for this simulated independent shooter with a 45% shooting percentage? How long is the player’s longest streak of baskets in 133 shots? Make sure to include a plot in your answer.
Answer:
Distribution of Simulated Streak Lengths
library(ggplot2)
# Compute streak lengths for the simulated independent shooter
sim_streak <- calc_streak(sim_basket)
# Plot the distribution of simulated streak lengths
ggplot(data = sim_streak, aes(x = length)) +
geom_bar(fill = "darkseagreen4", color = "white") +
labs(
title = "Distribution of Simulated Independent Shooter Streak Lengths",
x = "Streak Length (Number of Consecutive Made Baskets)",
y = "Count (Frequency)"
) +
theme_minimal()
Visual Summary of the Plot
X-axis (Streak Length): Ranges from 0 up to the maximum streak achieved in the simulation (e.g., 4 or 5).
Y-axis (Count): Shows a sharp exponential decay—the bar at 0 is the highest, followed by progressively shorter bars for lengths 1, 2, 3, and higher.
Excerise 7 If you were to run the simulation of the independent shooter a second time, how would you expect its streak distribution to compare to the distribution from the question above? Exactly the same? Somewhat similar? Totally different? Explain your reasoning.
Answer:
Second time, I would expect the streak distribution to be somewhat similar to the first one (assuming a new seed is used or no seed is set).
Reasoning
Why it won’t be exactly the same:Each simulation relies on random sampling via sample(). Because each individual shot is a probabilistic outcome (\(45\%\) chance of a hit, \(55\%\) chance of a miss), random variability (“sampling noise”) will cause the exact counts for each streak length to fluctuate slightly from run to run. For instance, the max streak length might be 4 in one run and 5 or 3 in the next.
Why it won’t be totally different:Because both simulations operate under the exact same underlying parameters—a sample size of \(n = 133\) shots and a \(45\%\) shooting probability—they are governed by the same statistical model.
Expected Similarities:Any repeated run will consistently display the same core distributional characteristics:
Excercise 8 How does Kobe Bryant’s distribution of streak lengths compare to the distribution of streak lengths for the simulated shooter? Using this comparison, do you have evidence that the hot hand model fits Kobe’s shooting patterns? Explain.
Answer
Distribution Comparison
When comparing Kobe Bryant’s actual streak length distribution to the simulated independent shooter’s distribution:
Overall Shape: Both distributions are strongly right-skewed and unimodal.
Center/Mode: In both datasets, the most common (typical) streak length is 0, followed by a rapid exponential decay in frequency as streak length increases
Maximum Streak Length: Kobe’s longest streak of consecutive made shots was 4. The simulated independent shooter achieved a very similar maximum streak length (typically between 3 and 5 depending on the simulation run).
Overall, the two distributions look very similar.
No, there is no evidence that the hot hand model fits Kobe’s shooting patterns.
Explanation:
The “hot hand” hypothesis suggests that making a shot increases the probability of making the next shot (i.e., shots are dependent), which would produce longer and more frequent shooting streaks than random chance alone.
However, because Kobe’s real-world shooting streaks closely mimic the distribution generated by a computer simulation where every shot is completely independent (a fixed \(45\%\) chance per shot), his shooting behavior is statistically indistinguishable from random noise. If Kobe possessed a hot hand, his distribution would have shown a significantly higher proportion of long streaks (\(3+\)) compared to the independent shooter.