qqplot of chi2 distribution

10 views (last 30 days)
Morten Nissov
Morten Nissov on 15 Jun 2021
I am attempting to check if some data fits to a chi2 distribution with 1 DOF, since it isn't possible to makedist a chi2 distribution I've been using pd = makedist('Gamma', 'a', 1/2, 'b', 2); instead. Which I've read should be equivalent.
When making the qqplot I get some strange behavior from something I would expect to be chi2, for example sampling directly from chi2rng
x = chi2rnd(1, 1e3,1);
pd = makedist('Gamma', 'a', 1/2, 'b', 2); % chi2 1dof
figure(6)
clf
subplot(211)
histogram(x, 'Normalization', 'pdf')
xvals = linspace(0, 10, 100);
hold on
plot(xvals, pdf(pd, xvals), 'linewidth', 2)
% plot(xvals, chi2pdf(xvals, 1), 'linewidth', 2)
hold off
grid on
subplot(212)
qqplot(x, pd);
grid on
Returns something not as nice as one would like, this got me thinking: how many quantiles can I really expect from data before concuding it's sufficiently chi2?
Of course this is all good and fine, obviously sampling from chi2rnd should present chi2 distributed variables. The actual context for me is in GLR test, where 2 times the test statistic should be chi2 distributed assuming H0. Making the GLR test on a gaussian sequence results in
looking at the histogram one could be very tempted to call this chi2 distributed, the qqplot however is not quite as convincing. Is this just me nitipicking at high quantiles? It all comes back to what are reasonable expectations in qqplot fits vs large quantiles?

Answers (0)

Community Treasure Hunt

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

Start Hunting!