download.file("http://www.openintro.org/stat/data/kobe.RData", destfile = "kobe.RData")
load("kobe.RData")
head(kobe)
##    vs game quarter time
## 1 ORL    1       1 9:47
## 2 ORL    1       1 9:07
## 3 ORL    1       1 8:11
## 4 ORL    1       1 7:41
## 5 ORL    1       1 7:03
## 6 ORL    1       1 6:01
##                                               description basket
## 1                 Kobe Bryant makes 4-foot two point shot      H
## 2                               Kobe Bryant misses jumper      M
## 3                        Kobe Bryant misses 7-foot jumper      M
## 4 Kobe Bryant makes 16-foot jumper (Derek Fisher assists)      H
## 5                         Kobe Bryant makes driving layup      H
## 6                               Kobe Bryant misses jumper      M
summary(kobe)
##    vs           game       quarter       time    
##  ORL:133   Min.   :1.000   1  :36   0:00   :  3  
##            1st Qu.:1.000   1OT: 7   0:04   :  2  
##            Median :3.000   2  :25   11:00  :  2  
##            Mean   :2.902   3  :34   1:20   :  2  
##            3rd Qu.:4.000   4  :31   2:17   :  2  
##            Max.   :5.000            3:33   :  2  
##                                     (Other):120  
##                                    description     basket         
##  Bryant 3pt Shot: Missed                 :  5   Length:133        
##  Kobe Bryant misses layup                :  5   Class :character  
##  Kobe Bryant makes 11-foot two point shot:  4   Mode  :character  
##  Kobe Bryant makes 20-foot jumper        :  4                     
##  Kobe Bryant misses 19-foot jumper       :  4                     
##  Kobe Bryant misses 20-foot jumper       :  4                     
##  (Other)                                 :107
kobe_streak <- calc_streak(kobe$basket)
barplot(table(kobe_streak))

On your own

Comparing Kobe Bryant to the Independent Shooter Using calc_streak, compute the streak lengths of sim_basket.

(1) 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?

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

outcomes <- c("H", "M")
outcomes
## [1] "H" "M"
sim_basket <- sample(outcomes, size = 130, replace=T, prob = c(0.45, 0.55))
sim_basket
##   [1] "H" "H" "H" "H" "M" "H" "M" "H" "M" "H" "H" "H" "H" "M" "H" "H" "M"
##  [18] "H" "M" "M" "M" "H" "H" "M" "H" "H" "H" "M" "M" "H" "H" "H" "M" "M"
##  [35] "H" "H" "M" "M" "H" "M" "H" "H" "H" "H" "H" "M" "M" "H" "M" "H" "M"
##  [52] "M" "M" "H" "M" "H" "M" "M" "H" "H" "H" "M" "M" "M" "M" "H" "H" "H"
##  [69] "M" "M" "H" "H" "M" "H" "M" "M" "M" "H" "H" "H" "M" "H" "M" "H" "H"
##  [86] "H" "H" "H" "H" "M" "M" "M" "H" "H" "H" "M" "M" "H" "M" "H" "M" "H"
## [103] "H" "H" "M" "M" "M" "H" "H" "M" "H" "M" "H" "M" "M" "H" "H" "H" "H"
## [120] "H" "H" "M" "M" "H" "M" "M" "H" "H" "H" "M"
calc_streak(sim_basket)
##  [1] 4 1 1 4 2 1 0 0 2 3 0 3 0 2 0 1 5 0 1 1 0 0 1 1 0 3 0 0 0 3 0 2 1 0 0
## [36] 3 1 6 0 0 3 0 1 1 3 0 0 2 1 1 0 6 0 1 0 3 0
sim_streak <- calc_streak(sim_basket)
barplot(table(sim_streak))

  • The distribution is right-skewed. The typical streak length for this kind of shooter is 0 and 1, as they are the most common/typical values. The longest streak was 6 baskets.

(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.

  • There could be some changes in values of the sample, which is simulated randomley. But the final results may not have huge variation to the above first Experiment. If we set different values to the shooting percentage then we could see notisable variation

(2) 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.

  • Here now I am comparing two baskets kobe_streak and sim_streak
kobe_streak = calc_streak(kobe$basket)
sim_streak = calc_streak(sim_basket)
# Compute summaries:
summary(kobe_streak)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.0000  0.0000  0.0000  0.7632  1.0000  4.0000
summary(sim_streak)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   0.000   1.000   1.298   2.000   6.000
# Make bar plots:
kobe_table = table(kobe_streak)
sim_table = table(sim_streak)

barplot(kobe_table)

barplot(sim_table)

  • Since Kobe’s streak length distribution looks very similar to the Sim’s streak simulated steak length distribution, we can conclude that Kobe Bryant likely does not have a “hot hand”.