Hot Hands

Kat Taylor

RIP Kobe

##Table for Kobe’s shots

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’s hit/miss senerio

kobe$basket[1:9]
## [1] "H" "M" "M" "H" "H" "M" "M" "M" "M"

#A streak of one means he has a hit one since the last miss or “miss, hit” ## kobe’s streaks

kobe_streak <- calc_streak(kobe$basket)
barplot(table(kobe_streak))

# kobe’s tipical streak length was unforchentaly 0, indicating he would often miss multiple baskets on a row. His lomgest streak length was 4.

##comparing kobe’s streak length

##flipping a coin:

outcomes <- c("heads", "tails")
sample(outcomes, size = 1, replace = TRUE)
## [1] "tails"

cont’d

sim_fair_coin <- sample(outcomes, size = 100, replace = TRUE)
sim_fair_coin
##   [1] "heads" "heads" "heads" "tails" "tails" "tails" "heads" "tails" "tails"
##  [10] "tails" "heads" "tails" "heads" "tails" "tails" "tails" "heads" "heads"
##  [19] "heads" "tails" "tails" "tails" "tails" "heads" "heads" "tails" "heads"
##  [28] "tails" "heads" "heads" "tails" "heads" "tails" "tails" "tails" "heads"
##  [37] "heads" "tails" "tails" "heads" "tails" "tails" "tails" "tails" "heads"
##  [46] "heads" "heads" "tails" "heads" "tails" "tails" "tails" "tails" "tails"
##  [55] "tails" "tails" "tails" "heads" "tails" "tails" "heads" "tails" "heads"
##  [64] "tails" "heads" "tails" "heads" "tails" "tails" "heads" "heads" "tails"
##  [73] "heads" "heads" "tails" "heads" "tails" "heads" "heads" "heads" "heads"
##  [82] "tails" "tails" "tails" "tails" "tails" "tails" "heads" "tails" "heads"
##  [91] "tails" "heads" "tails" "tails" "heads" "heads" "heads" "heads" "tails"
## [100] "heads"
table(sim_fair_coin)
## sim_fair_coin
## heads tails 
##    44    56

Unfair coin

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

when the unfair coin was used the ratio of heads to tails showed up at about the ratio i had programmed it too. Essentially creating a dispoprtionate number of heads and tails to choose from.

to lean moreabout functions type ?sample

?sample
## starting httpd help server ... done

independednt shooter

outcomes <- c("H", "M")
sim_baskets <- sample(outcomes, size = 133, replace = TRUE)
table(sim_baskets)
## sim_baskets
##  H  M 
## 80 53

to match kobe’s it cannot be 50/50 it has to be .45/.65

kobe’s numbers

outcomes <- c("H", "M")
kobe$basket <- sample(outcomes, size = 133, replace = TRUE, prob = c(0.45, 0.65))
table(kobe$basket)
## 
##  H  M 
## 58 75

##compare indeprendent shooter to kobe

kobe$basket
##   [1] "H" "M" "H" "H" "H" "H" "M" "M" "H" "H" "M" "M" "H" "M" "M" "H" "M" "M"
##  [19] "H" "H" "M" "H" "M" "H" "M" "H" "M" "M" "M" "H" "M" "H" "M" "M" "H" "M"
##  [37] "H" "M" "M" "H" "M" "H" "M" "H" "M" "H" "M" "H" "H" "M" "H" "H" "M" "M"
##  [55] "M" "H" "M" "M" "H" "M" "H" "H" "H" "M" "H" "M" "M" "M" "H" "M" "H" "H"
##  [73] "H" "M" "M" "H" "M" "H" "H" "M" "M" "H" "M" "M" "H" "M" "H" "M" "M" "H"
##  [91] "M" "M" "M" "H" "M" "M" "M" "H" "M" "M" "H" "M" "H" "M" "H" "M" "M" "M"
## [109] "M" "M" "M" "M" "H" "H" "M" "M" "H" "M" "H" "M" "H" "M" "H" "M" "H" "H"
## [127] "M" "M" "H" "M" "M" "M" "H"
sim_baskets
##   [1] "M" "H" "H" "M" "H" "H" "H" "H" "H" "H" "H" "H" "M" "H" "M" "M" "H" "H"
##  [19] "H" "M" "H" "M" "M" "M" "M" "H" "M" "M" "H" "H" "H" "H" "M" "M" "M" "H"
##  [37] "H" "H" "H" "H" "M" "H" "H" "H" "M" "M" "H" "H" "H" "H" "M" "M" "H" "M"
##  [55] "M" "H" "H" "H" "M" "H" "H" "H" "M" "M" "H" "M" "M" "M" "M" "H" "M" "M"
##  [73] "M" "H" "H" "H" "H" "H" "H" "M" "M" "H" "H" "H" "M" "M" "H" "H" "H" "M"
##  [91] "H" "M" "M" "H" "H" "M" "M" "H" "H" "H" "M" "M" "M" "H" "H" "M" "H" "H"
## [109] "H" "M" "H" "H" "H" "H" "M" "H" "H" "H" "H" "M" "H" "H" "H" "H" "M" "M"
## [127] "M" "M" "H" "H" "M" "H" "H"

on your own

##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?

kobe

kobe_streak1 <- calc_streak(kobe$basket)
barplot(table(kobe_streak1))

independent shooter

nom_streak <- calc_streak(sim_baskets)
barplot(table(nom_streak))

the noral player tends to habe slightly shorter streaks on average.

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

of course because of random distrabution I wold not expect the results to be exactly the same, however I would expect regenrated responces to be very simualr s long as the probablity of eachoption satay the samwe and it remaains a fairly large sample size.

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

the origninal kobe distabution looks simualr to the independent, however the generated kobe tends to have longer streaks then the independent.