00001
00002
00003
00004 #include <cmath>
00005
00006 #include "Math/SpecFuncMathMore.h"
00007 #include "Math/SpecFuncMathCore.h"
00008 #include "Math/PdfFuncMathCore.h"
00009 #include "Math/DistFuncMathMore.h"
00010
00011
00012 #include "gsl/gsl_sf_hyperg.h"
00013
00014
00015 namespace ROOT {
00016 namespace Math {
00017
00018
00019
00020
00021
00022 double noncentral_chisquared_pdf(double x, double k, double lambda) {
00023
00024
00025 if(lambda==0){
00026 return ROOT::Math::chisquared_pdf(x,k);
00027 }
00028 double ret = 0;
00029 if (k < 2.0) {
00030
00031
00032
00033
00034
00035
00036
00037 ret = std::exp( - 0.5 *(x + lambda) ) * 1./(std::pow(2.0, 0.5 * k) * ROOT::Math::tgamma(0.5*k)) * std::pow( x, 0.5 * k - 1.0)
00038 * gsl_sf_hyperg_0F1( 0.5 * k, 0.25 * lambda * x );
00039
00040 }
00041 else {
00042
00043
00044
00045
00046
00047
00048 ret = 0.5 * std::exp(-0.5 * (x+lambda) ) * std::pow(x/lambda, 0.25*k-0.5)
00049 * ROOT::Math::cyl_bessel_i (0.5*k-1., std::sqrt(lambda*x));
00050
00051
00052
00053
00054 }
00055
00056 return ret;
00057 }
00058
00059
00060 }
00061
00062 }