90 points · by ColinWright · 14y ago · 16 comments
http://www.increpare.com/2009/11/platonic-archetypes-of-dice...
I'm working on a set of dice for rolling passwords, and wanted to simulate it in software - while this is trivial to do if it's already been done I'd like to avoid the effort.
> s <- sample(c(3,3,3,3,3,4), size=100, replace=T)
[...] output elided
> table(s)
3 4
86 14
In order: this samples size times from a vector created by c with 5 3s and one 4 (you could also say c(rep(3,5), 4) with replacement and assigns the sample to a vector called s. table(s) produces counts of unique values.Great channel! Check it out: http://www.youtube.com/numberphile