residuals from histfit result

4 ビュー (過去 30 日間)
David Morgan
David Morgan 2017 年 9 月 29 日
コメント済み: Star Strider 2017 年 9 月 29 日
Hi,
I'm trying to curve fit some histogram data using histfit and would like to know if there is a good way to evaluate the fit to the binned data. I know that I can manually extract both the parameters from the fit and the bin centers and heights from the histogram, and then calculate things like an RMS difference. Is there an easier or more automatic way to do this?
Thanks in advance.

採用された回答

Star Strider
Star Strider 2017 年 9 月 29 日
I’m not aware of one.
One approach that avoids the need to extract the parameters of the distribution and calculate the curve at the histogram centres:
r = normrnd(10,1,100,1); % Create Data
h = histfit(r,10,'normal'); % Return Handle Values
bars = h(1); % ‘Bar’ Structure
curve = h(2); % ‘Line’ Structure
curve_at_bars = interp1(curve.XData, curve.YData, bars.XData, 'pchip'); % Interpolate
resid = curve_at_bars - bars.YData; % Calculate Residuals
The 'pchip' interpolation method would probably be more appropriate than the alternatives here.
I don’t know what data you will actually be analysing, so I don’t know if this approach is appropriate to them.
  2 件のコメント
David Morgan
David Morgan 2017 年 9 月 29 日
Thanks so much. This looks like exactly what I need, and is far more simple than I was thinking of when extracting various pieces and working with them.
Star Strider
Star Strider 2017 年 9 月 29 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by