Import Data kobe
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
Q.1 Describe the distribution of streak lengths for the independent shooter. 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[,6]
## [1] "H" "M" "M" "H" "H" "M" "M" "M" "M" "H" "H" "H" "M" "H" "H" "M" "M"
## [18] "H" "H" "H" "M" "M" "H" "M" "H" "H" "H" "M" "M" "M" "M" "M" "M" "H"
## [35] "M" "H" "M" "M" "H" "H" "H" "H" "M" "H" "M" "M" "H" "M" "M" "H" "M"
## [52] "M" "H" "M" "H" "H" "M" "M" "H" "M" "H" "H" "M" "H" "M" "M" "M" "H"
## [69] "M" "M" "M" "M" "H" "M" "H" "M" "M" "H" "M" "M" "H" "H" "M" "M" "M"
## [86] "M" "H" "H" "H" "M" "M" "H" "M" "M" "H" "M" "H" "H" "M" "H" "M" "M"
## [103] "H" "M" "M" "M" "H" "M" "H" "H" "H" "M" "H" "H" "H" "M" "H" "M" "H"
## [120] "M" "M" "M" "M" "M" "M" "H" "M" "H" "M" "M" "M" "M" "H"
kobe_streak<-calc_streak(kobe$basket)
kobe_streak
## [1] 1 0 2 0 0 0 3 2 0 3 0 1 3 0 0 0 0 0 1 1 0 4 1 0 1 0 1 0 1 2 0 1 2 1 0
## [36] 0 1 0 0 0 1 1 0 1 0 2 0 0 0 3 0 1 0 1 2 1 0 1 0 0 1 3 3 1 1 0 0 0 0 0
## [71] 1 1 0 0 0 1
table(kobe_streak)
## kobe_streak
## 0 1 2 3 4
## 39 24 6 6 1
result<-c("H","M")
sim_bas<-sample(result, size = 133, replace = TRUE, prob = c(0.45,0.55))
sim_bas
## [1] "M" "H" "H" "H" "M" "M" "H" "H" "H" "M" "H" "M" "H" "H" "M" "H" "M"
## [18] "H" "M" "M" "M" "H" "M" "M" "M" "M" "H" "M" "H" "M" "M" "M" "H" "M"
## [35] "H" "M" "M" "M" "M" "M" "H" "M" "M" "M" "M" "M" "H" "H" "M" "H" "M"
## [52] "M" "H" "M" "M" "M" "H" "H" "H" "H" "M" "M" "M" "M" "M" "M" "H" "H"
## [69] "M" "M" "H" "H" "M" "M" "H" "H" "M" "M" "M" "H" "M" "M" "H" "H" "H"
## [86] "H" "M" "M" "M" "M" "M" "M" "M" "M" "H" "M" "M" "M" "M" "H" "H" "M"
## [103] "H" "H" "H" "M" "M" "M" "M" "H" "H" "H" "H" "H" "H" "M" "M" "H" "H"
## [120] "M" "M" "H" "H" "H" "M" "H" "H" "M" "M" "M" "M" "H" "H"
sim_streak<-calc_streak(sim_bas)
sim_streak
## [1] 0 3 0 3 1 2 1 1 0 0 1 0 0 0 1 1 0 0 1 1 0 0 0 0 1 0 0 0 0 2 1 0 1 0 0
## [36] 4 0 0 0 0 0 2 0 2 0 2 0 0 1 0 4 0 0 0 0 0 0 0 1 0 0 0 2 3 0 0 0 6 0 2
## [71] 0 3 2 0 0 0 2
table(sim_streak)
## sim_streak
## 0 1 2 3 4 6
## 48 13 9 4 2 1
barplot(table(sim_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.
#The outcome will differ each time on the grounds that the reenactment of the 133 shots from the indenpendent shooter are ramdom tests and are being put back for examining pool even idea it was chosen beforehand. To get a similar outcome one needs to utilize the set.seed work.
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.
# Notwithstanding number of reenactment runs I expect Kobe's appropriation of streak lengths will be emphatically reflecting those of the free shooter.
#Each shot is autonomous of the other so a past Hit won't influence the result of the following shot.