function y = ibinom(n,p,k) % IBINOM y = ibinom(n,p,k) Individual binomial probabilities % Version of 10/5/93 % n is a positive integer; p is a probability % k a matrix of integers between 0 and n % y = P(X>=k) (a matrix of probabilities) if p > 0.5 a = [1 ((1-p)/p)*ones(1,n)]; b = [1 n:-1:1]; c = [1 1:n]; br = (p^n)*cumprod(a.*b./c); bi = fliplr(br); else a = [1 (p/(1-p))*ones(1,n)]; b = [1 n:-1:1]; c = [1 1:n]; bi = ((1-p)^n)*cumprod(a.*b./c); end y = bi(k+1);