How to plot Central/Non-central chi square pdf?
Show older comments
I have 1000 samples of energy. I want to plot central and non-central chi square pdf. I checked the Matlab documentation, I don't understand, how to calculate/choose values of degree of freedom and delta. Can anyone help?
Answers (1)
Jeff Miller
on 14 Dec 2018
You need to estimate the distribution parameter(s) from your 1000 data values (call them x).
In principle you would use fitdist(x,'chisquare') or 'noncentralchisquare', but I don't think the matlab distribution-fitter recognizes either of these two distributions.
The commands would look something like this:
mychi=ChiSq(10); % Make a chi-square distribution object
mychi.EstML(x) % Estimate its parameter based on your data
xvals = 0.1:.1:20; % Pick a range of x values over which you want to plot the distribution
pdfvals = mychi.PDF(xvals,); % Compute the pdf of the distribution at each x value
plot(xvals,pdfvals); % plot the distribution
mynoncenchi=ChiSqNoncentral(10,.2); % Same as above, but using a different distribution object.
mynoncenchi.EstML(x)
noncenpdfvals = mynoncenchi.PDF(xvals,);
plot(xvals,noncenpdfvals);
where x is your data, and 10 and .2 are your initial guesses for the distribution parameters.
Categories
Find more on Chi-Square Distribution 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!