Fit chi distribution to measurement data

Good Morning,
I would like to fit a chi distribution (not chi-squared!) with 6 degrees of freedom to my measurement data. Unfortunately, the chi distribution does not seem to be implemented in the Matlab function fitdist, and the only possibility I found was described in:
Although there is an example for a Laplace distribution on how to define a custom distribution, I'm not sure which lines of code to change, in order to define my chi distribution properly. Could someone perhaps help me out here?
Thank you very much!
BTW: I found out, that the Nakagami distribution supported by fitdist is similar to a chi distribution, but I really need to use a chi distribution and not a Nakagami one!

 Risposta accettata

Torsten
Torsten il 16 Ago 2022
Square your measurement data, and you can fit them against a chi-squared distribution.

21 Commenti

dj1du
dj1du il 16 Ago 2022
Modificato: dj1du il 16 Ago 2022
This is no solution for me, since my task explicitly demands to plot a chi distribution to visibly show that the data is really chi distributed, although your solution makes sense in itself.
Torsten
Torsten il 16 Ago 2022
Modificato: Torsten il 16 Ago 2022
Then use the parameters obtained from the chi-squares fit in the chi-distribution and compare to your unsquared data.
Do you have a curve you want to fit the chi distribution to or only a one-dimensional data vector ?
See under
whether curve fitting or distribution fitting applies in your case.
Ok good suggestion, but nevertheless I need a plot of a chi distribution, under any circumstances.
But I gave you the way how to get a plot of the fit of your data with a chi-distribution. Don't you understand what I meant ?
dj1du
dj1du il 16 Ago 2022
Modificato: dj1du il 16 Ago 2022
I'm sorry, I didn't see the last sentence of your response. I have a 1D data vector to which the chi distribution should be fitted. Perhaps you can explain it once again in a step by step manner, as I am not really sure about the procedure you mentioned, to be honest.
No, I meant the first sentence:
Fit your data squared to a chi-squared distribution, insert the parameters thus obtained in the chi distribution and plot the chi distribution together with a histogram of your data unsquared.
Ok, the chi- and chi-squared distribution have both just one same distribution parameter, so when I have determined this parameter by fitting the squared data, what's the Matlab command for plotting the chi distribution eventually? Or do I have to program the chi distribution's pdf manually with the known distribution parameter? Sorry for asking...
Torsten
Torsten il 16 Ago 2022
Modificato: Torsten il 16 Ago 2022
It doesn't seem to be in the list here:
So I think you will have to define a function handle with the determined parameter to plot it afterwards together with a histogram of your data unsquared.
Ok, thank you very much for your help!
Torsten
Torsten il 16 Ago 2022
Modificato: Torsten il 16 Ago 2022
If you use "mle" directly, you can fit your data against a chi distribution:
Here, you can define a custom distribution (e.g. its pdf) by using a function handle.
The "Distribution Fitter" also seems to accept your own custom distribution:
Ok, the use of mle looks more straight-forward, I will try this solution, I guess. Thank you again for your help!
Maybe there is a statistician in the forum who can tell whether it's legitimate to fit a chi squared distribution to measurement data squared if one knows that the data unsquared follow a chi distribution. I'm not quite sure if this introduces a bias in the parameter estimation.
By the way: How can I fit a chi-squared distribution to my squared data? I just found out that chi-squared distributions are not supported by MATLAB functions like fitdist!
Torsten
Torsten il 17 Ago 2022
Modificato: Torsten il 17 Ago 2022
I didn't look that up, but since you insisted to fit your data to a chi distribution, not a chi squared distribution, I thought you knew of a way for the latter.
Did you succeed with "mle" or "Distribution Fitter" ?
dj1du
dj1du il 17 Ago 2022
Modificato: dj1du il 17 Ago 2022
I tried mle based on the following code
chipdf = @(data,k) ...
(data.^(k-1).*exp(-(data.^2)/2))/((2^(k/2-1))*gamma(k/2));
phat_hirf = mle(measurement_data,'pdf',chipdf,'Start',1)
and it gives me the desired distribution parameter k, but to be sure this method really provides correct results, I was hoping for implementing your alternative chi-squared approach, too, and compare the result from both different methods. But chi-square is not implemented in Matlab for fitting, unfortunately, so I don't know how to implement your chi-squared approach...
Torsten
Torsten il 17 Ago 2022
Modificato: Torsten il 17 Ago 2022
And does the histogram for your data and the fitted chi distribution look similar in the plot ?
Yes, but as I need all this stuff for a publication I want to be absolutely sure and try a second method for comparison. Any ideas left?
Distribution Fitter. As you write, an example for a Laplace Distribution is given. Doesn't sound too difficult to imitate it for your case.
And you write in your first question that you want to fit a chi distribution with 6 degrees of freedom to your measurement data. Why do you need to fit it if you already know the parameter k ? To check whether it turns out to be 6 ?
@dj1du comment moved here:
Yes, exactly, the data are not perfectly chi-distributed with k=6 and I need to show how well it fit the ideal case k=6
Oh, then you will also have to do some statistical test(s), don't you ?

Accedi per commentare.

Più risposte (0)

Richiesto:

il 16 Ago 2022

Commentato:

il 19 Ago 2022

Community Treasure Hunt

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

Start Hunting!

Translated by