glimpse(kobe_basket)
## Rows: 133
## Columns: 6
## $ vs <fct> ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL~
## $ game <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1~
## $ quarter <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3~
## $ time <fct> 9:47, 9:07, 8:11, 7:41, 7:03, 6:01, 4:07, 0:52, 0:00, 6:35~
## $ description <fct> Kobe Bryant makes 4-foot two point shot, Kobe Bryant misse~
## $ shot <chr> "H", "M", "M", "H", "H", "M", "M", "M", "M", "H", "H", "H"~
streak = 1 means 1 hit followed by a miss streak = 0 means a miss
kobe_streak <- calc_streak(kobe_basket$shot)
ggplot(data = kobe_streak, aes(x = length)) +
geom_bar(fill = "darkorange") +
xlab("streak length")
The distribution on streak lengths is right skewed. Kobe’s average streak length is
mean(kobe_streak$length)
## [1] 0.7631579
Kobe’s longest streak of baskets is
max(kobe_streak$length)
## [1] 4
coin_outcomes <- c("heads", "tails")
sample(coin_outcomes, size = 1, replace = TRUE)
## [1] "tails"
sim_fair_coin <- sample(coin_outcomes, size = 100, replace = TRUE)
sim_fair_coin
## [1] "heads" "tails" "heads" "tails" "tails" "tails" "heads" "heads" "heads"
## [10] "tails" "heads" "heads" "tails" "heads" "heads" "tails" "heads" "tails"
## [19] "tails" "tails" "heads" "tails" "tails" "heads" "tails" "heads" "heads"
## [28] "heads" "heads" "tails" "heads" "heads" "tails" "tails" "heads" "tails"
## [37] "tails" "heads" "tails" "heads" "tails" "tails" "tails" "heads" "heads"
## [46] "heads" "heads" "tails" "tails" "tails" "tails" "tails" "tails" "tails"
## [55] "tails" "heads" "tails" "heads" "tails" "heads" "heads" "heads" "tails"
## [64] "tails" "heads" "tails" "heads" "heads" "heads" "tails" "tails" "heads"
## [73] "tails" "heads" "tails" "tails" "heads" "tails" "heads" "heads" "heads"
## [82] "heads" "tails" "heads" "tails" "tails" "heads" "heads" "heads" "heads"
## [91] "tails" "heads" "tails" "tails" "tails" "heads" "tails" "heads" "tails"
## [100] "heads"
table(sim_fair_coin)
## sim_fair_coin
## heads tails
## 50 50
set.seed(454545)
sim_unfair_coin <- sample(coin_outcomes, size = 100,
replace = TRUE, prob = c(0.2, 0.8))
sim_unfair_coin
## [1] "tails" "tails" "tails" "tails" "tails" "tails" "tails" "heads" "tails"
## [10] "tails" "heads" "heads" "tails" "heads" "tails" "tails" "tails" "heads"
## [19] "tails" "tails" "tails" "tails" "tails" "tails" "tails" "heads" "tails"
## [28] "tails" "tails" "heads" "tails" "tails" "tails" "tails" "tails" "tails"
## [37] "heads" "tails" "heads" "tails" "heads" "tails" "tails" "tails" "heads"
## [46] "tails" "tails" "tails" "tails" "tails" "tails" "tails" "tails" "heads"
## [55] "heads" "tails" "tails" "tails" "tails" "heads" "tails" "tails" "tails"
## [64] "heads" "heads" "tails" "tails" "heads" "tails" "tails" "tails" "tails"
## [73] "heads" "heads" "heads" "tails" "heads" "tails" "tails" "heads" "tails"
## [82] "tails" "tails" "tails" "tails" "tails" "tails" "heads" "tails" "tails"
## [91] "tails" "tails" "tails" "tails" "tails" "tails" "tails" "tails" "tails"
## [100] "tails"
table(sim_unfair_coin)
## sim_unfair_coin
## heads tails
## 23 77
There were 23 heads in 100 flips in the unfair coin simulation.
shot_outcomes <- c("H", "M")
set.seed(454555)
sim_basket <- sample(shot_outcomes, size = 133,
replace = TRUE, prob = c(0.45, 0.55))
sim_basket
## [1] "M" "H" "H" "H" "M" "M" "M" "H" "H" "H" "M" "H" "M" "M" "M" "H" "H" "M"
## [19] "H" "M" "H" "H" "M" "H" "M" "H" "M" "M" "M" "M" "H" "H" "H" "M" "M" "M"
## [37] "M" "H" "H" "H" "M" "M" "M" "H" "M" "M" "M" "M" "H" "H" "M" "H" "M" "H"
## [55] "H" "H" "H" "M" "M" "H" "M" "M" "M" "M" "H" "H" "M" "M" "H" "H" "H" "M"
## [73] "M" "M" "M" "M" "H" "M" "M" "M" "H" "M" "H" "H" "H" "M" "H" "H" "H" "M"
## [91] "H" "M" "M" "H" "M" "M" "H" "M" "M" "H" "H" "M" "M" "M" "H" "H" "H" "M"
## [109] "M" "M" "H" "M" "M" "H" "H" "H" "H" "M" "M" "M" "H" "M" "M" "H" "M" "H"
## [127] "H" "M" "M" "M" "M" "M" "M"
table(sim_basket)
## sim_basket
## H M
## 59 74
sim_streak <- calc_streak(sim_basket)
ggplot(data = sim_streak, aes(x = length)) +
geom_bar(fill = "darkorange") +
xlab("simulation streak length")
The distribution of simulated streak lengths is right skewed. The average streak length is
mean(sim_streak$length)
## [1] 0.7866667
The simulation’s longest streak of baskets is
max(sim_streak$length)
## [1] 4
Without setting the simulation seed, I expect the distribution of the second simulation to be similar, but not exactly the same as that of the first simulation. Because the probability is set in the simulation, the distribution of hits and misses should be similar, and the distribution of streaks should also be similar.
Since I have set the seed, the simulation returns the same results each time it’s run.
The distributions of Kobe’s streak length and the simulation’s are similar. Both are right skewed, the majority are length 0 (misses).
Kobe’s average streak is 0.7631579.
The simulation’s average streak is 0.7866667.
Kobe’s maximum streak length is 4.
The simulation’s maximum streak length is 4.
Based on this comparison Kobe’s shooting is similar to the independent shooter simulation, so it doesn’t support the hot hand model fitting Kobe’s shooting patterns.