Load data from kobe.RData located in working directory/more and create data frame “kobe.RData”.

```
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
```

`summary(kobe)`

```
## vs game quarter time
## ORL:133 Min. :1.000 1 :36 0:00 : 3
## 1st Qu.:1.000 1OT: 7 0:04 : 2
## Median :3.000 2 :25 11:00 : 2
## Mean :2.902 3 :34 1:20 : 2
## 3rd Qu.:4.000 4 :31 2:17 : 2
## Max. :5.000 3:33 : 2
## (Other):120
## description basket
## Bryant 3pt Shot: Missed : 5 Length:133
## Kobe Bryant misses layup : 5 Class :character
## Kobe Bryant makes 11-foot two point shot: 4 Mode :character
## Kobe Bryant makes 20-foot jumper : 4
## Kobe Bryant misses 19-foot jumper : 4
## Kobe Bryant misses 20-foot jumper : 4
## (Other) :107
```

sample size is 133

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

```
#Possible outcomes of shooting a basket
outcomes <- c("H", "M")
#Simulation for 133 times. Probability for hit=45% and miss=55%.
simulator_basket <- sample(outcomes, size = 133, replace = TRUE, prob = c(0.45, 0.55))
independent_streak <- calc_streak(simulator_basket)
```

`summary(independent_streak)`

```
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 0.0000 0.0000 0.8873 1.0000 5.0000
```

`barplot(table(independent_streak))`

- Independent shooter with 45% shooting percentage distribution suggests that it is right skewed and existence of hit streak of length 5. So, longest streak of baskets is 5.
- It is unimodal and mean is 0. This suggests that typical streak length of 0.

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

According to the observations each time a simulation is run for independent shooter distribution changes. I have observed longest streak of baskets range from 4 to 8. Each simulation is totally different.

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

For a valid comparison between Kobe and simulated shooter, shooting percentage needs to be fair. Lets change it for *hit* or *miss* to 50%.

```
#Possible outcomes of shooting a basket
outcomes <- c("H", "M")
#Simulation for 133 times. Probability of hit or miss is 50%.
simulator_basket <- sample(outcomes, size = 133, replace = TRUE)
independent_streak <- calc_streak(simulator_basket)
kobe_streak <- calc_streak(kobe$basket)
```

`summary(independent_streak)`

```
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 0.000 1.000 1.161 2.000 5.000
```

`summary(kobe_streak)`

```
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 0.0000 0.0000 0.7632 1.0000 4.0000
```

```
#Kobe strek bar plot
barplot(table(kobe_streak))
```

```
#simulated shooter
barplot(table(independent_streak))
```

Kobe Bryant’s distribution of streak lengths are similar to simulated shooter. Each shot is independent. Outcome of a shot is independent of previous shot. It is fair to say Kobe Bryant shooting pattern does not fit *hot hand* model.

# Apendix

```
load("more/kobe.RData")
head(kobe)
summary(kobe)
#Possible outcomes of shooting a basket
outcomes <- c("H", "M")
#Simulation for 133 times. Probability for hit=45% and miss=55%.
simulator_basket <- sample(outcomes, size = 133, replace = TRUE, prob = c(0.45, 0.55))
independent_streak <- calc_streak(simulator_basket)
summary(independent_streak)
barplot(table(independent_streak))
#Possible outcomes of shooting a basket
outcomes <- c("H", "M")
#Simulation for 133 times. Probability of hit or miss is 50%.
simulator_basket <- sample(outcomes, size = 133, replace = TRUE)
independent_streak <- calc_streak(simulator_basket)
kobe_streak <- calc_streak(kobe$basket)
summary(independent_streak)
summary(kobe_streak)
#Kobe strek bar plot
barplot(table(kobe_streak))
#simulated shooter
barplot(table(independent_streak))
```