I'm new in matlab and i tried to normalize two normal distributions according to How to normalize a histogram in MATLAB?, but i couldn't. Can someone tell me how to normalize the two normal distribution below:
[f,x]=hist(normrnd(25,2.5),50);%# create histogram from a normal distribution.
g=1/sqrt(2*pi)*exp(-0.5*x.^2);%# pdf of the normal distribution
figure(1)
bar(x,f/trapz(x,f));hold on
plot(x,g,'r');hold off
Thanks!
Two suggestions:
Code:
[f,x]=hist(randn(10000,2.5),50);%# create histogram from a normal distribution.
g=1/sqrt(2*pi)*exp(-0.5*x.^2);%# pdf of the normal distribution
figure(1)
bar(x,f/trapz(x,f));hold on
plot(x,g,'r');hold off