Find the goodness fitting and find the best fit

2 次查看(过去 30 天)
I have plotted the histogram of some data. The plot of the data can be seen in this link.
The code of the histogram is the following:
vals=discardval(:,2); % vals is my data
numbins = 40;
hist(vals,numbins)
set(get(gca,'Children'),'FaceColor',[.8 .8 1])
Although, I am not familiar with the statistical methods that are used for fitting a distribution, I have used fitdist function to fit the histogram. Below is the code for the fitting.
hold on
[bincounts,binpositions]=hist(vals,numbins);
binwidth = binpositions(2) - binpositions(1);
histarea = binwidth*sum(bincounts);
x = binpositions(1):binwidth/10:binpositions(end);
pd = fitdist(discardval(:,2),'tLocationScale');
y = pdf('tLocationScale',x,pd.Params(1),pd.Params(2),pd.Params(3));
plot(x,histarea*y,'r','LineWidth',2)
You can see the plot of fitting in this link
I have a couple of questions regarding the fitting:
  1. How can assess the fitting? I would like a measure of how good is the fitting.
  2. How can I make an iterative method that finds the best fit
  3. Transform this histogram in showing the probability. This is seems is easy to do if I divide the the bincounts with the population of the sample. But how can I visualize it?
  4. And last, how can find the range in which 95% of the population lies. i.e 95% of the population lies in the interval [-0.005 0.005]

回答(1 个)

Shashank Prasanna
1) The parameter estimates are Maximum Likelihood estimates. All properties of the fit are available in the distribution object, for example:
>> pd.ParamCov
for the covariance matrix of parameter estimates.
2) Use you control some parameters of the optimization using statset and pass it as an 'Options' to fitdist:
3) use cdf :
4) Percentiles:
  1 个评论
Carter Hoffman
Carter Hoffman 2023-3-14
@Shashank Prasanna Can you provide some context on how to use the covariance parameters (pd.ParamCov) to assess goodness of fit ?

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by