You are on page 1of 3

EXPERIMENT NO.

7
AIM: To generate and plot the cumulative distribution function and probability distribution
function of a continuous random variable with uniform distribution.
SOFTWARE: Scilab
THOERY:
Probability density function
The probability density function of the continuous uniform distribution is:

The values of f(x) at the two boundaries a and b are usually unimportant because they do not
alter the values of the integrals of f(x) dx over any interval, nor of x f(x) dx or any higher
moment. Sometimes they are chosen to be zero, and sometimes chosen to be 1/(b − a).
The latter is appropriate in the context of estimation by the method of maximum
likelihood. In the context of Fourier analysis, one may take the value of f(a) or f(b) to be
1/(2(b − a)), since then the inverse transform of many integral transforms of this uniform
function will yield back the function itself, rather than a function which is equal "almost
everywhere", i.e. except on a set of points with zero measure. Also, it is consistent with
the sign function which has no such ambiguity.
Cumulative distribution function
The cumulative distribution function is:
CODE:
clc
a=2
b=5
x=a-2:0.01:b+2
pdf=zeros(1,length(x))
pdf(1,find(x==(a-0.01)))=0
pdf(find(x==a):find(x==b))=1/(b-a)
pdf(find(x==(b+0.01)))=0
disp(length(x),length(pdf))
subplot(2,1,1)
title("pdf")
xlabel("x")
ylabel("F(x)")
plot(x,pdf)
subplot(2,1,2)
for i=1:length(x)
cf(i)=0
for j=1:i
cf(i)=pdf(j)+cf(i)
end
end
title("cdf")
xlabel("x")
ylabel("F(x)")
plot(x,cf)

OUTPUT:
OUTPUT WINDOW:

CONCLUSION:

You might also like