Skip to main content
Source Link
Michal
  • 215
  • 3
  • 11

how to normalize histogram

I ma creating the exponential distribution using inverse method. I want to normalize histogram. How can I do it?

This is my code

N=100;
Lambda=2;
r=rand(N,1);
X=-log(1-r)/Lambda;
hist(X), colormap(bone);

t = 0:0.01:5;
pdf=Lambda*exp(-Lambda*t);
hold on, plot(t,pdf,'LineWidth',2)