Probability

The Hot Hand

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.

Data

Your investigation will focus on the performance of one player: Kobe Bryant of the Los Angeles Lakers. His performance against the Orlando Magic in the 2009 NBA Finals earned him the title Most Valuable Player and many spectators commented on how he appeared to show a hot hand. The data file we’ll use is called kobe_basket.

glimpse(kobe_basket)
## 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

QUESTION: What does a streak length of 1 mean, i.e. how many hits and misses are in a streak of 1? ANSWER: A streak length of 1 means Kobe had one hits followed by one miss.

QUESTION: What about a streak length of 0? ANSWER: A streak length of 0 means Kobe had 0 hits.

kobe_streak <- calc_streak(kobe_basket$shot)

ggplot(data = kobe_streak, aes(x = length)) +
  geom_bar()

Excercise 2

QUESTION: Describe the distribution of Kobe’s streak lengths from the 2009 NBA finals. ANSWER: The distribution of Kobe’s streak lengths from the 2009 NBA finals is right skewed.

QUESTION: What was his typical streak length? ANSWER: Kobe’s typical streak length is 0.

QUESTION: How long was his longest streak of baskets? Make sure to include the accompanying plot in your answer. ANSWER: His longest streak of baskets is 4

#While we don’t have any data from a shooter we know to have independent shots, that sort of data is very easy to simulate in R. In a simulation, you set the ground rules of a random process and then the computer uses random numbers to generate an outcome that adheres to those rules. As a simple example, you can simulate flipping a fair coin with the following.
coin_outcomes <- c("heads", "tails")
sample(coin_outcomes, size = 1, replace = TRUE)
## [1] "heads"
#Save the resulting vector of heads and tails in a new object called sim_fair_coin.
sim_fair_coin <- sample(coin_outcomes, size = 100, replace = TRUE)

#To view the results of this simulation, type the name of the object and then use table to count up the number of heads and tails.
sim_fair_coin
##   [1] "tails" "tails" "tails" "tails" "heads" "heads" "tails" "tails" "tails"
##  [10] "tails" "heads" "tails" "heads" "tails" "tails" "tails" "tails" "heads"
##  [19] "tails" "heads" "tails" "tails" "tails" "heads" "heads" "heads" "heads"
##  [28] "tails" "tails" "heads" "heads" "heads" "heads" "heads" "heads" "tails"
##  [37] "heads" "heads" "tails" "heads" "heads" "tails" "heads" "heads" "tails"
##  [46] "heads" "heads" "heads" "tails" "tails" "tails" "tails" "heads" "tails"
##  [55] "tails" "heads" "tails" "heads" "heads" "tails" "tails" "heads" "tails"
##  [64] "tails" "heads" "tails" "tails" "heads" "heads" "tails" "tails" "tails"
##  [73] "tails" "tails" "tails" "tails" "heads" "tails" "heads" "tails" "heads"
##  [82] "tails" "heads" "heads" "heads" "tails" "tails" "heads" "heads" "heads"
##  [91] "heads" "heads" "heads" "tails" "heads" "tails" "heads" "tails" "heads"
## [100] "heads"
table(sim_fair_coin)
## sim_fair_coin
## heads tails 
##    49    51
#Since there are only two elements in coin_outcomes, the probability that we “flip” a coin and it lands heads is 0.5. Say we’re trying to simulate an unfair coin that we know only lands heads 20% of the time. We can adjust for this by adding an argument called prob, which provides a vector of two probability weights.
sim_unfair_coin <- sample(coin_outcomes, size = 100, replace = TRUE, 
prob = c(0.2, 0.8))

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.

set.seed(81282)                 

shot_outcomes <- c("Heads", "Tails")
sim_basket <- sample(shot_outcomes, size = 100, replace = TRUE)

table(sim_basket)
## sim_basket
## Heads Tails 
##    62    38

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.

shot_outcomes <- c("HIT", "MISS")
sim_basket <- sample(shot_outcomes, size = 133, replace = TRUE,prob=c(0.45,0.55))
table(sim_basket)
## sim_basket
##  HIT MISS 
##   61   72
sim_basket
##   [1] "MISS" "MISS" "MISS" "MISS" "HIT"  "HIT"  "MISS" "HIT"  "HIT"  "MISS"
##  [11] "HIT"  "MISS" "MISS" "HIT"  "MISS" "MISS" "MISS" "HIT"  "MISS" "HIT" 
##  [21] "HIT"  "MISS" "HIT"  "MISS" "HIT"  "MISS" "HIT"  "HIT"  "HIT"  "MISS"
##  [31] "MISS" "MISS" "MISS" "HIT"  "MISS" "MISS" "HIT"  "MISS" "MISS" "HIT" 
##  [41] "MISS" "MISS" "HIT"  "MISS" "MISS" "HIT"  "MISS" "MISS" "HIT"  "MISS"
##  [51] "MISS" "MISS" "HIT"  "HIT"  "HIT"  "MISS" "MISS" "HIT"  "MISS" "MISS"
##  [61] "HIT"  "HIT"  "HIT"  "MISS" "MISS" "HIT"  "HIT"  "HIT"  "MISS" "HIT" 
##  [71] "MISS" "MISS" "MISS" "MISS" "MISS" "HIT"  "MISS" "HIT"  "MISS" "HIT" 
##  [81] "HIT"  "HIT"  "HIT"  "HIT"  "HIT"  "MISS" "MISS" "MISS" "HIT"  "HIT" 
##  [91] "MISS" "MISS" "HIT"  "MISS" "HIT"  "MISS" "HIT"  "HIT"  "MISS" "HIT" 
## [101] "HIT"  "HIT"  "HIT"  "HIT"  "MISS" "MISS" "MISS" "MISS" "HIT"  "HIT" 
## [111] "MISS" "MISS" "MISS" "MISS" "MISS" "MISS" "MISS" "HIT"  "HIT"  "MISS"
## [121] "MISS" "HIT"  "HIT"  "HIT"  "MISS" "MISS" "HIT"  "HIT"  "MISS" "MISS"
## [131] "MISS" "HIT"  "HIT"

Excercise 5

Using calc_streak, compute the streak lengths of sim_basket, and save the results in a data frame called sim_streak.

set.seed(81282)

shot_outcomes <- c("H", "M")
sim_basket <- sample(shot_outcomes, size = 133, replace = TRUE,prob=c(0.45,0.55))

sim_streak <- calc_streak(sim_basket)
sim_streak
##    length
## 1       5
## 2       0
## 3       1
## 4       0
## 5       1
## 6       0
## 7       0
## 8       1
## 9       0
## 10      3
## 11      0
## 12      2
## 13      1
## 14      1
## 15      1
## 16      1
## 17      3
## 18      1
## 19      1
## 20      0
## 21      0
## 22      1
## 23      0
## 24      0
## 25      0
## 26      0
## 27      0
## 28      2
## 29      0
## 30      1
## 31      2
## 32      0
## 33      0
## 34      0
## 35      2
## 36      0
## 37      0
## 38      3
## 39      1
## 40      1
## 41      0
## 42      1
## 43      0
## 44      1
## 45      0
## 46      0
## 47      2
## 48      0
## 49      0
## 50      0
## 51      6
## 52      4
## 53      0
## 54      0
## 55      0
## 56      2
## 57      2
## 58      1
## 59      0
## 60      1
## 61      0
## 62      0
## 63      1
## 64      2
## 65      1
## 66      1
## 67      3
## 68      0
## 69      0
## 70      0
## 71      0
table(sim_basket)
## sim_basket
##  H  M 
## 63 70
table(sim_streak)
## length
##  0  1  2  3  4  5  6 
## 36 20  8  4  1  1  1

Excercise 6

Describe the distribution of streak lengths. ANSWER: The distribution of the streak length is right skewed.

What is the typical streak length for this simulated independent shooter with a 45% shooting percentage? ANSWER: The typical streak lenght is 0.

How long is the player’s longest streak of baskets in 133 shots? Make sure to include a plot in your answer. ANSWER: The player’s longest streak of baskets in 133 shots is 6.

ggplot(data = sim_streak, aes(x = length)) +
  geom_bar( fill="purple", col="purple")+
  labs(title = "DISTRIBUTION OF STREAK LENGTHS", x= "LENGTH", y = "COUNT", ylim=c(0,40), breaks = 5)

Excercise 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: If I were to run the simulation of the independent shooter a second time, I would expect the results to be exactly the same becuase the seed value was set to 81282. If the set values was not set the results would be somewhat similar.

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: Kobe Bryant’s distribution of streak lengths compared to the distribution of streak lengths for the simulated shooter are similiar. Both bar graphs have similiar streak lengths and are right skewed.

In my opinion the hot hand model does not fit Kobe’s shooting patterns because Kobe’s shooting record have fewer streaks.