- Joined
- 9/19/14
- Messages
- 52
- Points
- 18
Hi all, I was wondering, what is the best method to calculate the the Non central chi square distribution function?
I want to compute the non central chi square distribution and I was wondering, what was the best method to do this?What do want to 'calculate'?
double dof = 3.0;
double lambda = 1.5;
boost::math::non_central_chi_squared_distribution<double> myNonCentralChiSquared(dof, lambda);
cout << "pdf: " << pdf(myNonCentralChiSquared, x) << endl;
cout << "cdf: " << cdf(myNonCentralChiSquared, x) << endl;
// Other properties
cout << "\n***Noncentral Chi^2 Distribution: \n";
cout << "mean: " << mean(myNonCentralChiSquared) << endl;
cout << "variance: " << variance(myNonCentralChiSquared) << endl;
cout << "median: " << median(myNonCentralChiSquared) << endl;
cout << "mode: " << mode(myNonCentralChiSquared) << endl;
cout << "kurtosis excess: " << kurtosis_excess(myNonCentralChiSquared) << endl;
cout << "kurtosis: " << kurtosis(myNonCentralChiSquared) << endl;
cout << "characteristic function: " << chf(myNonCentralChiSquared, x) << endl;
cout << "hazard: " << hazard(myNonCentralChiSquared, x) << endl;
Thank you for that,
Thank you for that,
I think I am a little confused. I think my original question should have been which is the best method to approximate the non central chi square distribution?
Because I am looking for the maths behind it and I have come across many methods etc...
In C++Mathematica and MATLAB both have built in functions, e.g.:
http://www.mathworks.co.uk/help/stats/noncentral-chi-square-distribution.html?refresh=true
I am guessing you want to generate pdf and/or cdf?
boost::math::non_central_chi_squared_distribution<double> myNonCentralChiSquared(dof, lambda);
5.
6. double x = 0.5;
7. cout << "pdf: " << pdf(myNonCentralChiSquared, x) << endl;
8. cout << "cdf: " << cdf(myNonCentralChiSquared, x) << endl;