Created
December 30, 2018 18:55
-
-
Save jalapic/a3ae8d96684efe847bfddeee1a256b85 to your computer and use it in GitHub Desktop.
17 consonants out of scrabble tile distribution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Drawing consonants in a row | |
tiles <- c(rep("V", 44), rep("C", 56)) # 42 vowels + 2 blanks, 56 consonants | |
# combined vowels and blanks into "V" as don't care about difference for this | |
# loop 1 million times | |
res<-NULL | |
for(i in 1:1000000){ | |
draw <- sample(tiles, 17, F) | |
res[[i]]<-length(draw[draw=="C"]) | |
} | |
library(ggplot2) | |
ggplot(data.frame(value=res), | |
aes(x=value)) + | |
geom_histogram(color="darkseagreen", | |
fill="lightseagreen")+ | |
xlab("Number of consonants drawn") | |
sum(res==17) # number of times got 17 consonants |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment