How to get the error value when fitting a gaussin curve to a data?

I have the following data fitting curve:
And i'd like to compute the error associated to this fitting, the var error! If some one knows how to do it please help me.
Thanks

 採用された回答

Star Strider
Star Strider 2015 年 1 月 5 日

1 投票

To do the plot and get the data to analyse the error of the fit, this works:
x = 0.25*randn(1000,1)+1; % Create Data
h = histfit(x,50);
histdata = get(h(1),'XData'); % Get Histogram Data
redcurve = get(h(2),'YData'); % Get Fit Data
histctrs = mean(histdata); % Mean Of Bin Edges
redcurve2 = mean(reshape(redcurve, 2, [])); % Mean Of Bin Edges Fit
fit_err = histctrs - redcurve2; % Error
SSE = sum(fit_err.^2); % Sum-Squared Error
MSE = mean(fit_err.^2); % Mean-Squared-Error
RMSE = sqrt(MSE); % Root-Mean-Squared-Error
Your data actually seem to me to be lognormally distributed, so consider using the 'lognormal' distribution option.

その他の回答 (2 件)

Joao Costa
Joao Costa 2015 年 1 月 5 日

0 投票

But how do I get the red line (gaussian curve) In my code I did this:
histfit(data);
Thank you
Joao Costa
Joao Costa 2015 年 1 月 7 日

0 投票

Thanks a lot star strider! I only had to normalize the vector!

カテゴリ

ヘルプ センター および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by