Usage of chisquare_cdf from Math libraries

I need a function that, given a chi square value X and the associated number r of degrees of freedom, returns the respective cumulative distribution value. I found it is possible to call it from the ROOT Math libraries, but I need some example as reference… In particular:

  • which class have I to write in the header file?
  • How do I initialize the function?
    Thank you very much!


the function ROOT::Math::ROOT::Math::chisquared_cdf (x, r) where r is the number of degree of freedom, returns the cumulative distribution (i.e. the intergral from 0 to x) of the chi2 distribution. If you need the integral of the right tail (i.e. from x to + inf) you can use ROOT::Math::ROOT::Math::chisquared_cdf_c (x, r)

For using in a compiled program you need to include the header file
#include "Math/DistFunc.h"
and there is not need to do any initialization.
If you want to plot the function, just do:

TF1 *f = new TF1("f","ROOT::Math::chisquared_cdf(x,[0])",0,10);
f->SetParameter(0,2.);  // set the n.d.f to 2

Best Regards


Thank you! It works perfectly!
We love ROOT Talk Forum!!!