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

3 visualizaciones (últimos 30 días)
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 comentarios
mabdorab
mabdorab el 16 de Dic. de 2016
Editada: mabdorab el 16 de Dic. de 2016
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 el 16 de Dic. de 2016
Editada: José-Luis el 16 de Dic. de 2016
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.

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by