Browse Source

analyze final minute of regulation

George C. Privon 6 years ago
parent
commit
df63a76525
1 changed files with 15 additions and 0 deletions
  1. 15 0
      code/foul_analysis.R

+ 15 - 0
code/foul_analysis.R

@@ -36,6 +36,21 @@ ggplot(earlyfouls, aes(x=SCOREMARGIN_CORR)) +
     geom_histogram(data=allfouls, binwidth=1, fill="green", alpha=0.5)
 dev.off()
 
+# look at the distribution of fouls in the final minute
+lastminfouls <- filter(allfouls,
+                       (PERIOD == 4 & PCTIMESTRING < "00:01:00"))
+median(lastminfouls$SCOREMARGIN_CORR)
+mean(lastminfouls$SCOREMARGIN_CORR)
+sd(lastminfouls$SCOREMARGIN_CORR)
+png('figures/foul_histogram-regular_finalmin.png')
+ggplot(lastminfouls, aes(x=SCOREMARGIN_CORR)) +
+    geom_histogram(binwidth=1, fill="red", alpha=0.5) +
+    theme_bw() +
+    scale_y_log10() +
+    xlab("Score Margin") + ylab("N Fouls") +
+    geom_histogram(data=allfouls, binwidth=1, fill="green", alpha=0.5)
+dev.off()
+
 # overtime fouls
 overtimefouls <- filter(allfouls,
                         PERIOD > 4)