Probability Distribution Function and Shape

The Gamma Distribution

A random variable X has a Gamma( [Maple Math] , [Maple Math] ) distribution if and only its probability density is given by

[Maple Math] for x > 0

f ( x ) =

0 elsewhere

where [Maple Math] > 0.

The following code will draw the density function for the Gamma( [Maple Math] ) distribution for [Maple Math] , but you are encouraged to try other values. Remember to make sure that they are both positive numbers.

> restart;

> with(plots):

> alpha:=2; beta:=3;

[Maple Math]

[Maple Math]

> f(x):=GammaPDF(alpha,beta,x);

[Maple Math]

> plot(f(x),x=0..20, title="Gamma(2,3) PDF");

[Maple Plot]

To see the effect of [Maple Math] on the shape of the Gamma( [Maple Math] , [Maple Math] ) distribution, the following animation will draw a series of probability density functions as [Maple Math] varies from 0.1 to 2.1 by increments of 0.1 while holding [Maple Math] constant at 3. Do you see why [Maple Math] is a "shape" parameter?

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

[Maple Math]

[Maple Math]

[Maple Math]

> for n from 0 to 20 do

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

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

> tracker[n]:=textplot([14,0.3,`alpha is `.num],color=blue);

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

> od:

> display([seq(P[n], n=0..20)], insequence=true, title="Ranging Alpha");

[Maple Plot]

This next bit of code will animate a Gamma( [Maple Math] , [Maple Math] ) with a dynamic [Maple Math] , holding [Maple Math] constant at 2. [Maple Math] will vary from 0.2 to 3 at intervals of 0.2. Do you see why [Maple Math] is a "scale" parameter?

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

[Maple Math]

[Maple Math]

[Maple Math]

> for n from 0 to 30 do

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

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

> tracker[n]:=textplot([14,1,`beta is `.num],color=blue);

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

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

> od:

> display([seq(P[n], n=0..30)], insequence=true, title="Ranging Beta");

[Maple Plot]