Chi-Squared Distribution Fitting
29 views (last 30 days)
Star Strider on 28 Dec 2017
It doesn’t because fitting the chi-square distribution is generally not recommended. The chi-square distribution is used to describe the distribution of parameters, not data. At least that’s how I understand it.
However if you must, this comes close:
V = 10; % Create Data
R = chi2rnd(V, 1, 100); % Create Data
X = histcounts(R,20); % Create Data
RNCF = @(v) norm(X - chi2pdf((1:length(X)),v)); % Residual Norm Cost Function
Ve = fminsearch(RNCF, rand); % Extimate Parameter
plot((1:length(X)), chi2pdf((1:length(X)),Ve), '-r')
Experiment to get the result you want.