binomial - binomial distribution probabilities
pr=binomial(p,n) returns the binomial probability vector, i.e. pr(k+1) is the probability of k success in n independent Bernouilli trials with probability of success p. In other words : pr(k+1) = probability(X=k) , with X a random variable following the B(n,p) distribution, and numerically :
/ n \ k n-k / n \ n! pr(k+1) = | | p (1-p) with | | = --------- \ k / \ k / k! (n-k)!
// first example n=10;p=0.3; xbasc(); plot2d3(0:n,binomial(p,n)); // second example n=50;p=0.4; mea=n*p; sigma=sqrt(n*p*(1-p)); x=( (0:n)-mea )/sigma; xbasc() plot2d(x, sigma*binomial(p,n)); deff('y=Gauss(x)','y=1/sqrt(2*%pi)*exp(-(x.^2)/2)') plot2d(x, Gauss(x), style=2);