Skip to content

Instantly share code, notes, and snippets.

@arvi1000
Created May 27, 2020 20:19
Show Gist options
  • Save arvi1000/3bb7df8456cbb1886cfb81118943905a to your computer and use it in GitHub Desktop.
Save arvi1000/3bb7df8456cbb1886cfb81118943905a to your computer and use it in GitHub Desktop.
library(tidyverse)
streak_len <- 7
ref_denom <- 276
tibble(x=1:streak_len,
y=(1/6)^x) %>%
ggplot(aes(x=x+1, y=y)) +
geom_point() +
geom_line() +
geom_hline(yintercept = 1/ref_denom, linetype='dotted', color='red') +
annotate('text',
x=(streak_len+1), y=1/ref_denom,
label=paste0('(1/', ref_denom, ', chance)'),
color='red', size=3, vjust=-1, hjust=1) +
scale_x_continuous(breaks=1:(streak_len+1), minor_breaks = NULL) +
scale_y_log10(labels=scales::percent) +
labs(title='Chance of X consecutive identical rools of a 6-sided die',
x='Same-roll streak', y='Probability') +
theme_light()
@arvi1000
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment