You are on page 1of 1

%Name:Talha Parvez

%Roll Number : 2021UEC2625

clc;
close all;
N =100000;
u=rand(1,N);
X=-log(1-u);
range = 0:0.1:5;
h = histc(X,range);
Theory_pdf = exp(-range);
sim_pdf=h/(0.1*sum(h));
plot(range,Theory_pdf);
hold on;
plot(range,sim_pdf,'k *');
legend('Theory','Simulated');

Published with MATLAB® R2023b

You might also like