Find the goodness fitting and find the best fit
Show older comments
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]
Answers (1)
Shashank Prasanna
on 4 Aug 2013
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 Comment
Carter Hoffman
on 14 Mar 2023
@Shashank Prasanna Can you provide some context on how to use the covariance parameters (pd.ParamCov) to assess goodness of fit ?
Categories
Find more on Exploration and Visualization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!