Properties of the Distribution

Calculation of Mean, Variance, and Moment Generating Function

Calculating E( X ), the expectation or mean of the Binomial( n,p ) distribution.

> restart;

> with(plots):

> f:=x->BinomialPDF(n,p,x);

[Maple Math]

> EX:=simplify(sum(x*f(x),x=0..n));

[Maple Math]

This is Maple's final simplified form. However, cancelling common factors of the numerator and denominator in the above expression reveals that E( X )= np .

Calculating Var( X ), the variance of the Binomial( n,p ) distribution,

we will employ the formula: Var( X ) = E( [Maple Math] ) - [Maple Math]

> E_X_SQ:=simplify(sum(x^2*f(x),x=0..n));

[Maple Math]

The above expression for E( [Maple Math] ) clearly simplifies as [Maple Math] .

> VarX:=simplify(n*p*(n*p+1-p)-(n*p)^2);

[Maple Math]

Therefore, Var( X ) for a Binomial( n,p ) distribution is [Maple Math] .

The Moment Generating Function (MGF) can be easily calculated via Maple.

Recall the moment generating function of a random variable X is defined

as M ( t ) = E( [Maple Math] ), provided this expectation exists.

> simplify(sum(exp(t*x)*f(x),x=0..n));

[Maple Math]

This is Maple's final simplified form. However, cancelling common factors of the numerator and denominator in the above expression reveals that

M ( t ) = [Maple Math]

We will define M ( t ) as a function of t .

> M:=t->(1-p+p*exp(t))^n;

[Maple Math]

The moment generating function provides us alternative ways to calculate the

mean and variance by way of the formula.

[Maple Math] (0) = E( [Maple Math] ) , where [Maple Math] ( t ) denotes the r th derivative of M ( t ) with respect to t .

This formula holds as long as M ( t ) exists in an open interval containing zero.

See, for example, Mathematical Statistics and Data Analysis by John A. Rice for

more on the moment generating function.

> M_p:=diff(M(t),t);

[Maple Math]

> simplify(M_p);

[Maple Math]

> simplify(subs(t=0,M_p));

[Maple Math]

And therefore if X is a Binomial( n,p ) variable, then E( X ) = np , which agrees with

what we found earlier. Now turning to the second moment.

> M_pp:=diff(M_p,t);

[Maple Math]

> simplify(subs(t=0,M_pp));

[Maple Math]

>

Therefore E( [Maple Math] ) = [Maple Math] , which again is in agreement with the value

calculated previously. The variance is now quickly calculated as

Var( X ) = E( [Maple Math] ) - [Maple Math]

= [Maple Math]

= [Maple Math]

= [Maple Math]

Special Properties of the Binomial( n,p ) Distribution

You probably noticed in the previous animations that as n grew larger with p remaining a fixed value, the probability histogram for the Binomial( n,p ) distribution seemed to become increasingly bell-shaped (i.e., normal). Look again at the animation for n varying from 4 to 50 with an overlayed normal curve.

> p:=0.2;

[Maple Math]

> for n from 4 to 50 do

> H[n]:=ProbHist(BinomialPDF(n,p,x),0..50,51):

> N[n]:=plot(NormalPDF(n*p,n*p*(1-p),x),x = 0..50):

> num:=convert(n, string):

> tracker[n]:=textplot([40,0.4,`n is `.num],color=blue):

> P[n]:=display({H[n],N[n],tracker[n]}):

> od:

> display([seq(P[n], n=4..50)], insequence=true,title="Normal Approximation to the Binomial as n increases");

>

[Maple Plot]

>

Indeed, as n becomes larger, for fixed p , the Binomial( n,p ) distribution becomes increasingly better approximated by the Normal( [Maple Math] , [Maple Math] ) distribution.