Basketball players who make several baskets in succession are
described as having a hot hand. Fans and players have long believed in
the hot hand phenomenon, which refutes the assumption that each shot is
independent of the next. However, a 1985 paper by Gilovich, Vallone, and
Tversky collected evidence that contradicted this belief and showed that
successive shots are independent events. This paper started a great
controversy that continues to this day, as you can see by Googling hot
hand basketball.
We do not expect to resolve this controversy today. However, in this
lab we’ll apply one approach to answering questions like this. The goals
for this lab are to (1) think about the effects of independent and
dependent events, (2) learn how to simulate shooting streaks in R, and
(3) to compare a simulation to actual data in order to determine if the
hot hand phenomenon appears to be real.
Getting started
library(tidyverse)
library(openintro)
## 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"…
Exercise 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?
kobe_streak <- calc_streak(kobe_basket$shot)
ggplot(data = kobe_streak, aes(x = length)) +
geom_bar()

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.
## length
## Min. :0.0000
## 1st Qu.:0.0000
## Median :0.0000
## Mean :0.7632
## 3rd Qu.:1.0000
## Max. :4.0000
barplot(table(kobe_streak))

Exercise 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.
set.seed(112490)
results <- c("heads", "tails")
simulation_unfair_coin <- sample(results, size = 100, replace = TRUE, prob = c(0.3, 0.7))
table(simulation_unfair_coin)
## simulation_unfair_coin
## heads tails
## 28 72
Exercise 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.
set.seed(091320)
possible_outcomes <- c("H", "M")
sim_basket <- sample(possible_outcomes, size = 133, replace = TRUE,
prob = c(0.45, 0.55))
table(sim_basket)
## sim_basket
## H M
## 53 80
Exercise 5
Using calc_streak, compute the streak lengths of sim_basket, and save
the results in a data frame called sim_streak.
sim_streak <- calc_streak(sim_basket)
table(sim_streak)
## length
## 0 1 2 3 4
## 51 16 7 5 2
barplot(table(sim_streak))

Exercise 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.
set.seed(09152020)
possible_outcomes_1<-c("H", "M")
sim_basket<-sample(possible_outcomes_1, size=133, replace=TRUE, prob=c(0.45, 0.55))
sim_streak<-calc_streak(sim_basket)
barplot(table(sim_streak))

We’ve once again set the seed to 09152020 and generated possible
outcomes of H for hit and M for miss. The number of shots is set to 133,
and we’ve adjusted the probability to reflect a shooter with a 45%
success rate. The player’s average streak length is 0, while their
longest streak over 133 shots is 3. From the graph, we can observe that
the distribution is unimodal and skewed to the right.
## length
## 0 1 2 3
## 37 20 11 6
## [1] 3
## [1] 0
## length
## Min. :0.0000
## 1st Qu.:0.0000
## Median :0.5000
## Mean :0.8108
## 3rd Qu.:1.0000
## Max. :3.0000
Exercise 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.
I believe that if we run the independent shooter simulation again,
since the probability is set to reflect a 45% shooting success rate, the
results should be similar. This is a key point, as the most common
streak would still likely be 0.
Exercise 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.
barplot(table(kobe_streak))

barplot(table(sim_streak))

The streak length distributions for both the simulation and Kobe
Bryant’s shooting data are largely comparable. I don’t believe there is
enough evidence to support the “hot hand” theory in Kobe’s case. Both
data sets show right-skewed plots. However, one key difference is that
Kobe had a longest streak of 4, while the simulated player had a longest
streak of 3, which could be due to chance. In both cases, the most
common streak length was 0, suggesting, as previously mentioned, that
Kobe’s shots seem to be independent of each other.
LS0tDQp0aXRsZTogIkxhYiAzOiBQcm9iYWJpbGl0eSINCmF1dGhvcjogIkxhdXJhIFAiDQpkYXRlOiAiYHIgU3lzLkRhdGUoKWAiDQpvdXRwdXQ6IG9wZW5pbnRybzo6bGFiX3JlcG9ydA0KLS0tDQoNCkJhc2tldGJhbGwgcGxheWVycyB3aG8gbWFrZSBzZXZlcmFsIGJhc2tldHMgaW4gc3VjY2Vzc2lvbiBhcmUgZGVzY3JpYmVkIGFzIGhhdmluZyBhIGhvdCBoYW5kLiBGYW5zIGFuZCBwbGF5ZXJzIGhhdmUgbG9uZyBiZWxpZXZlZCBpbiB0aGUgaG90IGhhbmQgcGhlbm9tZW5vbiwgd2hpY2ggcmVmdXRlcyB0aGUgYXNzdW1wdGlvbiB0aGF0IGVhY2ggc2hvdCBpcyBpbmRlcGVuZGVudCBvZiB0aGUgbmV4dC4gSG93ZXZlciwgYSAxOTg1IHBhcGVyIGJ5IEdpbG92aWNoLCBWYWxsb25lLCBhbmQgVHZlcnNreSBjb2xsZWN0ZWQgZXZpZGVuY2UgdGhhdCBjb250cmFkaWN0ZWQgdGhpcyBiZWxpZWYgYW5kIHNob3dlZCB0aGF0IHN1Y2Nlc3NpdmUgc2hvdHMgYXJlIGluZGVwZW5kZW50IGV2ZW50cy4gVGhpcyBwYXBlciBzdGFydGVkIGEgZ3JlYXQgY29udHJvdmVyc3kgdGhh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