%program to generate Pareto random numbers
%according to the inversion method.
points=1000;
%generate 1000 pointsa = 2;
b = 2.5;
x=rand(points,1);
for
i=1:points,y1=1-x(i);
y2=-(1/b)*(log(y1));
y3(i)=a*exp(y2);
end
hold on
subplot(1,2,1)
plot(y3,
'k');box off
axis square
xlabel(
'Sample index')ylabel(
'Random number value')%generate a histogram of the data to view the pdf
x = 0:0.1:1;
subplot(1,2,2)
hist(y3)
box off
axis square
xlabel(
'Bins')ylabel(
'Bin count')
Go back to book Homepage | Go back to book's matlab Homepage | Go back to book's Chapter 1 Homepage |
Copyright © 2001 Northstar Digital Design, Inc.