CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: CumulativeChiSquare.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $ 00003 // --------------------------------------------------------------------------- 00004 00005 #include "CLHEP/GenericFunctions/CumulativeChiSquare.hh" 00006 #include "CLHEP/GenericFunctions/IncompleteGamma.hh" 00007 #include "CLHEP/GenericFunctions/Variable.hh" 00008 00009 namespace Genfun { 00010 FUNCTION_OBJECT_IMP(CumulativeChiSquare) 00011 00012 //---------------------------------------------------------------------------------// 00013 // Implementation notes: The Cumulative Chi Square function is implemented in // 00014 // terms of the incomplete gamma function. // 00015 //---------------------------------------------------------------------------------// 00016 00017 CumulativeChiSquare::CumulativeChiSquare(unsigned int nDof): 00018 _nDof(nDof) 00019 { 00020 create(); 00021 } 00022 00023 CumulativeChiSquare::~CumulativeChiSquare() { 00024 delete _function; 00025 } 00026 00027 CumulativeChiSquare::CumulativeChiSquare(const CumulativeChiSquare & right): 00028 _nDof(right._nDof) 00029 { 00030 create(); 00031 } 00032 00033 double CumulativeChiSquare::operator() (double x) const { 00034 return (*_function)(x); 00035 } 00036 00037 unsigned int CumulativeChiSquare::nDof() const { 00038 return _nDof; 00039 } 00040 00041 void CumulativeChiSquare::create() { 00042 Variable x; 00043 IncompleteGamma incompleteGamma; 00044 incompleteGamma.a().setValue(_nDof/2.0); 00045 _function = (incompleteGamma(x/2.0)).clone(); 00046 } 00047 } // namespace Genfun