Probability Distribution Function and Shape

The Beta Distribution

A random variable X has a Beta( [Maple Math] ) distribution if its probability density function (PDF) is given by

[Maple Math] for 0 < x < 1

f ( x ) =

0 elsewhere

where [Maple Math] > 0. The following code will draw the density function for the Beta( [Maple Math] ) distribution, but you are encouraged to try other values of [Maple Math] and [Maple Math] .

> restart;

> with(plots):

> f:=(alpha,beta,x)->GAMMA(alpha+beta)/(GAMMA(alpha)*GAMMA(beta))*x^(alpha-1)*(1-x)^(beta-1);

[Maple Math]

> alpha:=2; beta:=3;

[Maple Math]

[Maple Math]

> plot(f(alpha,beta,x),x=0..1);

[Maple Plot]

>

The Beta distribution can take on a variety of shapes. To see the effect of [Maple Math] on the shape of the Beta( [Maple Math] , [Maple Math] ) distribution, the following animation will draw a series of probability density curves as [Maple Math] varies from 0.1 to 2 by increments of 0.1, while holding [Maple Math] constant at 3.

> alpha[0]:=0.1; alpha_step:=0.1; beta:=3;

[Maple Math]

[Maple Math]

[Maple Math]

> for n from 0 to 19 do

> density[n]:=plot(f(alpha[0]+n*alpha_step,beta,x),x=0..1):

> num:=convert(evalf(alpha[0]+n*alpha_step),string):

> tracker[n]:=textplot([0.8,1,`alpha is `.num],color=blue):

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

> od:

> display([seq(P[n], n=0..19)], insequence=true, title="Varying Alpha While Beta is Fixed at 3");

>

[Maple Plot]

This next section of code will animate Beta( [Maple Math] , [Maple Math] ) distributions while holding [Maple Math] constant at 2 and varying [Maple Math] from 1 to 4 with steps of 0.1.

> alpha:=2; beta[0]:=1.0; beta_step:=0.1;

[Maple Math]

[Maple Math]

[Maple Math]

> for n from 0 to 30 do

> density[n]:=plot(f(alpha,beta[0]+n*beta_step,x),x=0..1):

> num:=convert(evalf(beta[0]+n*beta_step),string):

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

> P[n]:=display({density[n],tracker[n]});

> od:

> display([seq(P[n], n=0..30)], insequence=true,title="Alpha is Fixed at 2 While Beta Varies");

[Maple Plot]

>