Probability Distribution Function and Shape

The Uniform Distribution

A random variable X has a uniform distribution if and only if its probability density is given by

[Maple Math] for [Maple Math] < x < [Maple Math]

f ( x ) =

0 elsewhere

where [Maple Math] are real numbers.

The following code will draw the density function for the Unif( [Maple Math] ) distribution for your choices of [Maple Math] .

> restart:

> with(plots):

> alpha:=0; beta:=1;

[Maple Math]

[Maple Math]

> f(x):=piecewise(x>alpha and x<beta,1/(beta-alpha));

[Maple Math]

> plot(f(x),x=alpha..beta,title="Uniform(0,1) PDF");

[Maple Plot]

To see the effect of [Maple Math] on the shape of the Uniform( [Maple Math] , [Maple Math] ) distribution, the following animation will draw a series of probability density functions as [Maple Math] varies from 0 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; initial:=0; alpha_step:=0.1; beta:=3;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> f(x):=piecewise(x>alpha and x<beta,1/(beta-alpha));

[Maple Math]

> for n from 0 to 21 do

> density[n]:=plot(f(x),x=0..3):

> num:=convert(alpha,string):

> tracker[n]:=textplot([2.2,0.8,"alpha is ".num],color=blue);

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

> alpha:=initial+n*alpha_step:

> f(x):=piecewise(x>alpha and x<beta,1/(beta-alpha)):

> od:

> display([seq(P[n],n=0..21)],insequence=true, title="Changing alpha");

[Maple Plot]

This next bit of code will animate a Uniform( [Maple Math] , [Maple Math] ) with a dynamic [Maple Math] , holding [Maple Math] constant at 0. [Maple Math] will

vary from 1 to 3 at intervals of 0.1.

> alpha:=0; beta:=1; initial:=1; beta_step:=0.1;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> f(x):=piecewise(x>alpha and x<beta,1/(beta-alpha));

[Maple Math]

> for n from 0 to 21 do

> density[n]:=plot(f(x),x=0..3):

> num:=convert(beta,string):

> tracker[n]:=textplot([2.2,0.8,"beta is ".num],color=blue);

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

> beta:=initial+n*beta_step:

> f(x):=piecewise(x>alpha and x<beta,1/(beta-alpha)):

> od:

> display([seq(P[n],n=0..21)],insequence=true, title="Changing beta");

[Maple Plot]

Can you anticipate what happens if [Maple Math] and [Maple Math] both increase at the same rate? In the following animation, they both increase at a step size of 0.1 After you examine this animation, feel free to change the code so that they increase at different rates. If you'd like, you can change it so one is decreasing while the other is increasing.

> alpha:=0; ainitial:=0; alpha_step:=0.1; beta:=1; binitial:=1; beta_step:=0.1;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> f(x):=piecewise(x>alpha and x<beta,1/(beta-alpha));

[Maple Math]

> for n from 0 to 21 do

> numa:=convert(alpha,string):

> tracka[n]:=textplot([2.2,0.8,"alpha is ".numa],color=blue);

> numb:=convert(beta,string):

> trackb[n]:=textplot([2.2,0.5,"beta is ".numb],color=blue);

> density[n]:=plot(f(x),x=0..3):

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

> alpha:=ainitial+n*alpha_step:

> beta:=binitial+n*beta_step:

> f(x):=piecewise(x>alpha and x<beta,1/(beta-alpha)):

> od:

> display([seq(P[n], n=0..21)],insequence=true,title="Changing alpha and beta, with beta - alpha fixed.");

>

>

[Maple Plot]