Skip to content

Instantly share code, notes, and snippets.

@kalebr
Last active December 22, 2015 11:18
Show Gist options
  • Save kalebr/6464396 to your computer and use it in GitHub Desktop.
Save kalebr/6464396 to your computer and use it in GitHub Desktop.
R - cumulative probability of at least number of positive outcomes
cumProb <- function(min, trials, prob) {
x = 0
if(min == 0) {
error("Mininum must be greater than 0")
}
if(min > trials) {
return(0)
}
for (i in seq(min, trials)) {
x = x + dbinom(i, trials, prob)
}
return(x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment