Probability of something happening at least n out of m times
Mathematica, 29 bytes
BetaRegularized[#3,#,1+#2-#]&
Takes input in the order n,m,p
. Mathematica is so good, it even golfs your code for you:
BetaRegularized
is the regularised incomplete beta function.
R, 32 31 bytes
function(p,n,m)pbeta(p,m,1+n-m)
edit - 1 byte switching to beta distribution (along the lines of @Sp3000 Mathematica Answer)
Python, 57 bytes
f=lambda p,n,m:m and(1-p)*f(p,n,m-1)+p*f(p,n-1,m-1)or n<1
The recursive formula for binomial coefficients, except the base case m==0
indicates whether the remaining number of required successes n
is nonnegative, with True/False
for 1/0
. Because of its exponential recursion tree, this stalls on large inputs.