Find the goodness fitting and find the best fit
2 次查看(过去 30 天)
显示 更早的评论
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)
I have a couple of questions regarding the fitting:
- How can assess the fitting? I would like a measure of how good is the fitting.
- How can I make an iterative method that finds the best fit
- 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?
- 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]
0 个评论
回答(1 个)
Shashank Prasanna
2013-8-4
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
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!