HELP! check my coding please for histogram with overlay of normal distribution?
3 views (last 30 days)
Show older comments
x=[23948,25977, 29136, 33815, 36435, 40591, 43243, 44691, 44805, 45509, 44830, 45094, 44236, 43467, 44189, 45846, 48375, 48285, 46372, 44667, 41938]; [n,x] = hist(x,12); %Compute histogram hbar = bar(x, n/trapz(x,n)); %Bar plot of histogram hold on
%Overlay theoretical Gaussian curve
Ytheory = normpdf(x,41211.85714,50732773.43);
htheory = line(x,Ytheory,'Color','r','LineWidth', 2);
(1) Can anyone explain whi i don't get a proper Gaussian curve ontop of my histogram and it just looks like a line?
NOTE:The mean and variance values I used for the normal are the sample mean and variance. If possible check these in case this is the problem (as variance seems VERY large).
(2)Also have I rescaled my histogram (so distribution under curve has area 1) so it can be compared with the distribution correctly?
4 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!