필터 지우기
필터 지우기

distributionFitter: What is the best fit for my data?

조회 수: 4 (최근 30일)
Mohamed Zied
Mohamed Zied 2023년 1월 14일
답변: Drew 2023년 11월 16일
Hi;
I used the distributionFitter tool to find the best fit to my data.
I am wondering how can I judge the goodness of the fit based on the distributionFitter outcomes?
Thank you in advance.

채택된 답변

Drew
Drew 2023년 11월 16일
In the "Results" section of each "Edit Fit" window, the second line "Log likelihood" is one indication of the goodness of fit. In general, higher values of log likelihood (that is, closer to zero, since all log-likelihood values are negative) indicate a better fit to the data. However, it can be helpful to examine other metrics as well.
To visually examine the goodness of fit, compare the plots in the main Distribution Fitter window. For goodness-of-fit assessment, it can be helpful to examine the "Cumulative probability (CDF)" plot.
For additional quantitative goodness-of-fit metrics, one approach is to take these steps:
(1) Generate code from distribution fitter (find this option under "File --> Generate Code")
(2) Use the generated code to re-calculate all the distribution objects. (One could alternately export the fit objects from the "Fit Manager" window, but export happens one-fit-at-a-time, so that takes longer).
(3) Use tests such as the Kolmogorov-Smirnov test (kstest) and chi-squared goodness-of-fit (chi2gof) test to evaluate the goodness-of-fit.
One can use the MATLAB doc pages, or the MathWorks AI Chat Playground (https://www.mathworks.com/matlabcentral/playground/new) to help witih generating code to calculate the kstest and chi2gof. For example, here is some code generated to evaluate how well pd1 (normal distribution) and pd2 (Weibull distribution) fit the data in vector MPG, using the Kolmogorov-Smirnov test.
% Perform Kolmogorov-Smirnov test for normal distribution
[h1, p1, ksstat1] = kstest(MPG, 'CDF', pd1);
fprintf('Kolmogorov-Smirnov test for normal distribution:\n')
fprintf('h = %d, p = %f, ksstat = %f\n', h1, p1, ksstat1)
% Perform Kolmogorov-Smirnov test for Weibull distribution
[h2, p2, ksstat2] = kstest(MPG, 'CDF', pd2);
fprintf('Kolmogorov-Smirnov test for Weibull distribution:\n')
fprintf('h = %d, p = %f, ksstat = %f\n', h2, p2, ksstat2)
If this answer helps you, please remember to accept the answer.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Hypothesis Tests에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by