Probability Distribution Function and Shape
The Beta Distribution
A random variable X has a Beta( ) distribution if its probability density function (PDF) is given by
for 0 < x < 1
f ( x ) =
0 elsewhere
where > 0. The following code will draw the density function for the Beta( ) distribution, but you are encouraged to try other values of and .
> restart;
> with(plots):
> f:=(alpha,beta,x)->GAMMA(alpha+beta)/(GAMMA(alpha)*GAMMA(beta))*x^(alpha-1)*(1-x)^(beta-1);
> alpha:=2; beta:=3;
> plot(f(alpha,beta,x),x=0..1);
>
The Beta distribution can take on a variety of shapes. To see the effect of on the shape of the Beta( , ) distribution, the following animation will draw a series of probability density curves as varies from 0.1 to 2 by increments of 0.1, while holding constant at 3.
> alpha[0]:=0.1; alpha_step:=0.1; beta:=3;
> 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");
>
This next section of code will animate Beta( , ) distributions while holding constant at 2 and varying from 1 to 4 with steps of 0.1.
> alpha:=2; beta[0]:=1.0; beta_step:=0.1;
> 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");
>