Probability

Getting Started

load("more/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

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?

Answer:

Streak length of 1 means that there was only one basket that was a hit in that streak.There is one hit and one miss in a Streak length of 1. Streak lenght of zero means that there was no hit in that streak and one miss.

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

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?

Answer:

39, 24, 6, 6, 1

Total 29 of his streak lengths were 0 , 24 of his streaks had a length of 1, 6 of his streaks were of length 2 and 3 finally he has 1 streak of length 4. . His longest streak of baskets had a length of 4.

Simulations in R

outcomes <- c("heads", "tails")
sample(outcomes, size = 1, replace = TRUE)
## [1] "tails"
sim_fair_coin <- sample(outcomes, size = 100, replace = TRUE)
sim_fair_coin
##   [1] "tails" "tails" "heads" "tails" "tails" "heads" "tails" "tails"
##   [9] "tails" "tails" "tails" "heads" "heads" "tails" "tails" "heads"
##  [17] "heads" "tails" "tails" "heads" "tails" "tails" "tails" "tails"
##  [25] "tails" "tails" "tails" "heads" "tails" "heads" "heads" "heads"
##  [33] "tails" "heads" "tails" "tails" "tails" "heads" "heads" "heads"
##  [41] "tails" "heads" "heads" "heads" "heads" "heads" "tails" "tails"
##  [49] "heads" "heads" "tails" "tails" "tails" "heads" "tails" "tails"
##  [57] "tails" "heads" "heads" "tails" "tails" "heads" "heads" "tails"
##  [65] "heads" "tails" "heads" "tails" "tails" "heads" "heads" "heads"
##  [73] "tails" "tails" "tails" "heads" "tails" "tails" "heads" "tails"
##  [81] "tails" "tails" "tails" "tails" "heads" "tails" "tails" "heads"
##  [89] "tails" "heads" "tails" "tails" "tails" "tails" "tails" "tails"
##  [97] "tails" "tails" "heads" "heads"

Exercise 3

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

tbl_flips=table(sim_fair_coin)
tbl_flips
## sim_fair_coin
## heads tails 
##    39    61

Answer:

` In my simulation the number of flips that came up heads are 39

Simulating the Independent Shooter

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

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.

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

On your own

Question 1

Comparing Kobe Bryant to the Independent Shooter Using calc_streak, compute the streak lengths of sim_basket. 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?

independant_streak=calc_streak(sim_basket)
table(independant_streak)
## independant_streak
##  0  1  2  3  4  5 
## 21 25  8  3  3  2
barplot(table(independant_streak))

Answer

0 lenght streak is the highest as that was expected because the chance of a miss was 55% as compared to a hit which was only 45%. The typical streak length is 1 again as expected because of 55% chance of him missing the shot.The longest streak of basket is 5

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

Answer

If I run the simulation the second time I would expect to get a similar distribution as the chances of missing the shot is higher so basically there will be very similar distribution

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

Answer

I think the distribution lengths of Kobe Bryant and Independant Shooter are very similar . If I look at the comparisons it doesn’t seem to like that Kobe’s shooting fits the hot hands model because his shotting percentage is 48.68% It looks like it is more close to a probability that when he takes a shot it is a 50% chance of hitting and 50% chance of missing.