Skip to content

Instantly share code, notes, and snippets.

@olliefr
Last active May 20, 2016 11:33
Show Gist options
  • Save olliefr/19c9e93cd2f6babae0b103feb7f63ab7 to your computer and use it in GitHub Desktop.
Save olliefr/19c9e93cd2f6babae0b103feb7f63ab7 to your computer and use it in GitHub Desktop.
Brain teaser - summing the PMFs approach.
n <- 400 # number of tosses in a single trial
m <- 220 # threshold of interest
s <- 0 # the sum of binomial coefficients
for (k in m:n) {
s = s + choose(n,k)
}
p = s / 2^n
print(round(p, digits=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment