Sample Probability Calculations

Sample Probability Calculations

The cumulative distribution function (CDF) may be used to compute probabilities for uniform distributions.

The next plot depicts the CDFs for a Uniform (0,1), Uniform(0,2), Uniform(0,3), Uniform(1,2), and Uniform(0.5,1). Can you identify which is which? What happens to the Uniform CDF as [Maple Math] and [Maple Math] change?

> restart: with(plots):

> F[1](x):=piecewise(x<=0,0,x>0 and x<1,x,x>=1,1):

> F[2](x):=piecewise(x<=0,0,x>0 and x<2,x/2,x>=2,1):

> F[3](x):=piecewise(x<=0,0,x>0 and x<3,x/3,x>=3,1):

> F[4](x):=piecewise(x<=1,0,x>1 and x<2,x-1,x>=2,1):

> F[5](x):=piecewise(x<=0.5,0,x>0.5 and x<1,2*x-1,x>=1,1):

> plot([F[1](x),F[2](x),F[3](x),F[4](x),F[5](x)],x=0..3);

[Maple Plot]

> alpha:=0; beta:=1:

[Maple Math]

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

[Maple Math]

> a:=plot(f(x),x=alpha..beta,color=black,title="Uniform(0,1) PDF"):

> b:=plot(f(x),x=alpha..0.4,color=yellow,filled=true):

> display([a,b]);

[Maple Plot]

Find the value of the yellow shaded area, the area under the Unif(0, 1) density to the left of 0.4.

> UniformCDF(alpha..beta,0.4);

[Maple Math]

Areas can also be found using the integration command.

> evalf(int(f(x),x=alpha..0.4));

[Maple Math]

> a:=plot(f(x),x=alpha..beta,color=black,title="Uniform(0,1) PDF"):

> b:=plot(f(x),x=0.4..0.6,color=yellow,filled=true):

> display([a,b]);

[Maple Plot]

Find the value of the yellow shaded area, the area between 0.4 and 0.6.

Using the CDF, we find the area to the left of 0.6 and then subtract the area to the left of 0.4.

> area1:=UniformCDF(alpha..beta,0.6);

[Maple Math]

> area2:=UniformCDF(alpha..beta,0.4);

[Maple Math]

> area_between:=area1-area2;

[Maple Math]

Using the integration command, we simply integrate Uni(0,1) PDF from 0.4 to 0.6..

> evalf(int(f(x),x=0.4..0.6));

[Maple Math]

> a:=plot(f(x),x=alpha..beta,color=black,title="Uniform(0,1) PDF",labels=[" "," "]):

> b:=plot(f(x),x=0.75..beta,color=yellow,filled=true,labels=[" "," "]):

> c:=textplot([0.75,-0.1,"x"],color=blue):

> d:=textplot([0.8,0.2,"0.25"]):

> display([a,b,c,d]);

Find the value of x . x is known as the third quartile for the Uniform(0,1) distribution.

[Maple Plot]

Now we know the area under the curve to the left is 0.75 and we want to solve for x .

> fsolve(UniformCDF(alpha..beta,x)=0.75,x);

[Maple Math]