You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Fit chi distribution to measurement data
13 views (last 30 days)
Show older comments
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!
Accepted Answer
Torsten
on 16 Aug 2022
Square your measurement data, and you can fit them against a chi-squared distribution.
21 Comments
dj1du
on 16 Aug 2022
Edited: dj1du
on 16 Aug 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
on 16 Aug 2022
Edited: Torsten
on 16 Aug 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.
dj1du
on 16 Aug 2022
Edited: dj1du
on 16 Aug 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.
Torsten
on 16 Aug 2022
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.
dj1du
on 16 Aug 2022
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
on 16 Aug 2022
Edited: Torsten
on 16 Aug 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.
Torsten
on 16 Aug 2022
Edited: Torsten
on 16 Aug 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:
Torsten
on 16 Aug 2022
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.
Torsten
on 17 Aug 2022
Edited: Torsten
on 17 Aug 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
on 17 Aug 2022
Edited: dj1du
on 17 Aug 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
on 17 Aug 2022
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 ?
More Answers (0)
See Also
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)