HELP! check my coding please for histogram with overlay of normal distribution?

조회 수: 2 (최근 30일)
mabdorab
mabdorab 2016년 12월 16일
편집: José-Luis 2016년 12월 16일
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
mabdorab
mabdorab 2016년 12월 16일
편집: mabdorab 2016년 12월 16일
Jose-Luis Thank you so much, its fixed it for me.
Suppose I wanted to compare my data to a chi2pdf(x,V) Would I use my mean value as an estimator for V or is V (21-1) because there are 21 different observation years.
José-Luis
José-Luis 2016년 12월 16일
편집: José-Luis 2016년 12월 16일
I don't get it. You could test whether your sample comes for chi-squared distribution. The number of data points would only influence the statistic you are comparing against.

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by