23 Oct 2008
Probability of surviving k of n trials where the outcome is to win or to lose.
function b = BinomialProbability(n,k,p)
% This function provides the probability of surviving k of n trials for
% which the probability of each trial is p (for success) or 1-p for
% So, if one has a 60% chance of surviving each event, there are 10 events,
% and you want to know the chance of surviving 4, and only 4, events then
% n=10, k=4, p=0.60
% IT'S NOT FANCY, BUT IT WORKS.
% Michael Robbins
q = 1 - p;
C = combination(n,k);
b = C .* p.^k .* q.^(n-k);