Probability: Hot Hands

download.file("http://www.openintro.org/stat/data/kobe.RData", destfile = "kobe.RData")
load("kobe.RData")
head(kobe)
##    vs game quarter time                                             description
## 1 ORL    1       1 9:47                 Kobe Bryant makes 4-foot two point shot
## 2 ORL    1       1 9:07                               Kobe Bryant misses jumper
## 3 ORL    1       1 8:11                        Kobe Bryant misses 7-foot jumper
## 4 ORL    1       1 7:41 Kobe Bryant makes 16-foot jumper (Derek Fisher assists)
## 5 ORL    1       1 7:03                         Kobe Bryant makes driving layup
## 6 ORL    1       1 6:01                               Kobe Bryant misses jumper
##   basket
## 1      H
## 2      M
## 3      M
## 4      H
## 5      H
## 6      M
kobe$basket[1:9]
## [1] "H" "M" "M" "H" "H" "M" "M" "M" "M"

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?

Answer: A streak length of 1 means that there was 1 hit (made basket). A streak length of 0 means that there was no hit (no made baskets).

kobe_streak <- calc_streak(kobe$basket)
barplot(table(kobe_streak), main = "Barplot of Kobe's Streak Length", xlab = "Streak Length", ylab = "Frequency")

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?

Answer: Kobe’s typical streak length was 0. He had the greatest frequency of misses. He had the greatest frequency of 1 hit for streak length of hits. Kobe’s longest streak of baskets, with the lowest frequency, was 4.

Simulation of R

outcomes <- c("heads", "tails")
sample(outcomes, size = 1, replace = TRUE)
## [1] "heads"
sim_fair_coin <- sample(outcomes, size = 100, replace = TRUE)
sim_fair_coin
##   [1] "heads" "tails" "heads" "heads" "heads" "heads" "tails" "heads" "tails"
##  [10] "heads" "heads" "heads" "tails" "heads" "heads" "heads" "heads" "heads"
##  [19] "heads" "heads" "heads" "heads" "heads" "heads" "heads" "tails" "heads"
##  [28] "heads" "heads" "tails" "tails" "heads" "tails" "tails" "heads" "heads"
##  [37] "tails" "heads" "tails" "tails" "tails" "tails" "heads" "tails" "tails"
##  [46] "tails" "heads" "heads" "tails" "tails" "heads" "tails" "heads" "tails"
##  [55] "tails" "tails" "tails" "tails" "heads" "heads" "heads" "tails" "heads"
##  [64] "heads" "heads" "tails" "tails" "heads" "tails" "tails" "tails" "heads"
##  [73] "tails" "heads" "tails" "heads" "heads" "heads" "tails" "heads" "heads"
##  [82] "heads" "heads" "tails" "tails" "tails" "tails" "tails" "tails" "tails"
##  [91] "tails" "tails" "tails" "tails" "heads" "tails" "tails" "heads" "tails"
## [100] "tails"
table(sim_fair_coin)
## sim_fair_coin
## heads tails 
##    51    49
sim_unfair_coin <- sample(outcomes, size = 100, replace = TRUE, prob = c(0.2, 0.8))

Exercise 3

In your simulation of flipping the unfair coin 100 times, how many flips came up heads?

Answer: In my simulation of flipping the unfair coin 100 times, 13 flips came up heads.

table(sim_unfair_coin)
## sim_unfair_coin
## heads tails 
##    17    83

Simulating the Independent Shooter

outcomes <- c("H", "M")
sim_basket <- sample(outcomes, size = 1, replace = TRUE)

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.

Answer: The change that needs to be made is adding and argument called prob that provides a vector of two probability weights, 45% (hits) and 55% (misses). Simulation ran there were 68 hits and 65 misses.

sim_basket <- sample(outcomes, size = 133, replace = TRUE, prob = c(0.55, 0.45))
kobe$basket
##   [1] "H" "M" "M" "H" "H" "M" "M" "M" "M" "H" "H" "H" "M" "H" "H" "M" "M" "H"
##  [19] "H" "H" "M" "M" "H" "M" "H" "H" "H" "M" "M" "M" "M" "M" "M" "H" "M" "H"
##  [37] "M" "M" "H" "H" "H" "H" "M" "H" "M" "M" "H" "M" "M" "H" "M" "M" "H" "M"
##  [55] "H" "H" "M" "M" "H" "M" "H" "H" "M" "H" "M" "M" "M" "H" "M" "M" "M" "M"
##  [73] "H" "M" "H" "M" "M" "H" "M" "M" "H" "H" "M" "M" "M" "M" "H" "H" "H" "M"
##  [91] "M" "H" "M" "M" "H" "M" "H" "H" "M" "H" "M" "M" "H" "M" "M" "M" "H" "M"
## [109] "H" "H" "H" "M" "H" "H" "H" "M" "H" "M" "H" "M" "M" "M" "M" "M" "M" "H"
## [127] "M" "H" "M" "M" "M" "M" "H"
table(kobe$basket)
## 
##  H  M 
## 58 75
sim_basket
##   [1] "M" "H" "H" "M" "M" "M" "H" "H" "M" "H" "H" "M" "H" "H" "M" "M" "H" "M"
##  [19] "H" "H" "M" "H" "M" "H" "H" "H" "H" "H" "H" "H" "M" "H" "M" "M" "M" "H"
##  [37] "M" "H" "H" "M" "H" "H" "H" "H" "H" "M" "M" "H" "M" "H" "M" "M" "M" "H"
##  [55] "M" "H" "H" "M" "M" "H" "H" "H" "M" "H" "M" "H" "H" "M" "M" "H" "M" "M"
##  [73] "H" "M" "M" "M" "M" "M" "H" "M" "M" "H" "H" "H" "H" "H" "M" "M" "H" "M"
##  [91] "H" "M" "H" "H" "H" "H" "M" "M" "H" "M" "H" "H" "H" "H" "H" "M" "H" "H"
## [109] "M" "H" "H" "H" "H" "H" "M" "M" "M" "H" "H" "H" "H" "H" "H" "M" "M" "H"
## [127] "H" "M" "H" "H" "M" "H" "M"
table(sim_basket)
## sim_basket
##  H  M 
## 77 56

On Your Own

Using calc_streak, compute the streak lengths of sim_basket.

sim_basket_streak <- calc_streak(sim_basket)
barplot(table(sim_basket_streak), main = "Streak Lengths of Independent Shooter", xlab = "Streak Length, Number of Hits", ylab = "Frequency")

1. Describe the distribution of streak lengths. What s 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?

Answer: The streak lengths range from min. 0 to max. 9 with a mean of 1.030303 and a median of 1. The typical streak length is 0. The player’s longest streak of baskets in 133 shots is 9.

mean(sim_basket_streak)
## [1] 1.350877
median(sim_basket_streak)
## [1] 1
summary(sim_basket_streak)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   0.000   1.000   1.351   2.000   7.000
sim_basket_streak <- sample(outcomes, size = 133, replace = TRUE, prob = c(0.55, 0.45))
summary(sim_basket_streak)
##    Length     Class      Mode 
##       133 character character
barplot(table(sim_basket_streak))

2. 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: I would expect the streak distribution to be somewhat similar to the distribution above with minor variations. The overall probability will be the same because it is controlled with the prob function, but the exact order of distribution will vary.

3. 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 had a max of 4 hits in a streak whereas the independent shooter had 5. Both were similar in that there was a consistent decrease in number of lengths from 0 to the max number in each data set.

Answer: No we do not have evidence that the hot hand model fits kobe’s shooting patterns. The distribution is similar to a random distribution you find in a typical coin toss or Bernoulli trial style experiment.

Answer: There is not enough of a cluster pattern to allow for the hot hands theory to be supported.