Difference between manually fitting data with a distribution and Histfit() function?
Ältere Kommentare anzeigen
I'm trying to fit my time series data with a distribution. In the beginning, I used the function fitdist() to get the parameters and then used makedist() and pdf() to plot the histogram and pdf. However, the plot is a little bit different from the plot obtained with the function histfit(). Here's my code and plots (The left one is manual fitting while the right is plotted by function histfit()). Could anyone point out my mistakes? Is it due to the different scaling of y axis for the pdf?
a = n_rt(2:991); % time series data
subplot(1,2,1)
yyaxis left
histogram(a, 20); % histogram
yyaxis right
pd = fitdist(a', 'Gamma'); % fit the data with gamma distribution
pd2 = makedist('Gamma', pd.a, pd.b); % make the pdf
y = pdf(pd2, 0.2:0.01:1.8);
y = y/sum(y);
plot(0.2:0.01:1.8, y, 'LineWidth', 2);
subplot(1,2,2)
histfit(a, 20, 'gamma');

Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Half-Normal Distribution finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!