download.file("http://www.openintro.org/stat/data/kobe.RData", destfile = "kobe.RData")
load("kobe.RData")

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?

Streak of 1 - One hit and then one miss

Streak of 0 - One miss

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?

kobe_streak = calc_streak(kobe$basket)
barplot(table(kobe_streak))

Kobe’s distribution streak length is right-skewed. His typical streak length was 0, meaning misses. His longest streak of baskets was 4 consecutive hits.

Exercise 3

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

outcomes = c("H", "T")
sample(outcomes, size = 1, replace = T)
## [1] "T"
fair = sample(outcomes, size = 100, replace = T)
table(fair)
## fair
##  H  T 
## 51 49
unfair = sample(outcomes, size = 100, replace = T, prob = c(0.2, 0.8))
unfair
##   [1] "T" "T" "T" "T" "T" "T" "T" "T" "H" "T" "T" "T" "T" "T" "T" "T" "T"
##  [18] "T" "T" "H" "T" "T" "T" "T" "T" "T" "T" "T" "T" "H" "T" "T" "T" "T"
##  [35] "T" "T" "H" "T" "T" "H" "T" "T" "T" "T" "H" "T" "T" "H" "T" "T" "H"
##  [52] "T" "T" "T" "T" "T" "T" "H" "T" "T" "T" "T" "T" "T" "T" "T" "T" "T"
##  [69] "T" "T" "T" "T" "T" "H" "H" "T" "T" "H" "T" "T" "H" "T" "T" "H" "T"
##  [86] "T" "T" "T" "T" "T" "H" "H" "T" "T" "T" "T" "H" "T" "T" "T"
table(unfair)
## unfair
##  H  T 
## 17 83

For the unfair coin, my Heads outcome came up 17 times.

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.

outcomes = c("H", "M")
sim_basket = sample(outcomes, size = 133, replace = T, prob = c(0.45, 0.55))
sim_basket
##   [1] "H" "M" "H" "M" "H" "M" "M" "M" "M" "M" "M" "H" "M" "H" "M" "M" "M"
##  [18] "M" "H" "H" "M" "M" "M" "H" "M" "M" "H" "M" "H" "H" "H" "M" "H" "M"
##  [35] "H" "M" "M" "M" "M" "H" "M" "M" "H" "M" "H" "M" "M" "M" "H" "M" "H"
##  [52] "H" "H" "M" "M" "M" "H" "H" "M" "H" "H" "H" "M" "H" "M" "H" "H" "M"
##  [69] "M" "M" "M" "M" "H" "M" "M" "H" "M" "H" "H" "M" "H" "M" "H" "M" "H"
##  [86] "H" "H" "M" "H" "H" "M" "H" "H" "H" "M" "M" "H" "M" "M" "M" "H" "M"
## [103] "M" "H" "H" "H" "M" "M" "H" "H" "H" "M" "M" "H" "M" "M" "H" "H" "H"
## [120] "H" "H" "H" "M" "M" "M" "H" "H" "H" "H" "H" "H" "M" "M"
table(sim_basket)
## sim_basket
##  H  M 
## 64 69

ON YOUR OWN

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?

sim_streak = calc_streak(sim_basket)
table(sim_streak)
## sim_streak
##  0  1  2  3  6 
## 35 21  5  7  2
barplot(table(sim_streak))

The distribution is right-skewed. The typical streak lenght was 0, which is indicative of misses. The player’s longest streak was 6 consecutive hits.

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 distribution would be somewhat similar in that it would most likely be right-skewed, however it will not be exactly the same because just like the outcomes within the simulation is independent, so is each simulation independent from other simulations. The shooter will still have approximately a 45% shooting percentacy (allowing distributions to be similar), but the results will not be copies of other simulations.

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.

kobe_streak = calc_streak(kobe$basket)
barplot(table(kobe_streak))

barplot(table(sim_streak))

After comparing the distributions between simulated shooter and Kobe Bryant’s distribution of streak lenghts and noting how similar they look, it seems that the hot hand model does not fit Kobe’s shooting patterns.