Hi all,
I am trying to create a function that includes the cdf of the standart gaussian e.g.: a*phi(sqrt(x))+b
where a and b are some constants and phi() the cdf of the std gaussian.
I was wondering if the std-gaussian-cdf is already declared like RooGaussian or RooPoisson but I could not find something like that. (Is there something like that?)
So I tried to compose the desired function by using the “createCdf” method on the RooGaussian. But when evaluating, the cdf gives not the expected values (see the little program below). I think “createCdf” has a problem with interpreted functions (RooFormulaVar) as I used one to declare the Gaussian gauss(sqrt(x),0,1).
So all in all:
- Is there an other way to compose a RooAbsReal that is “a*phi(sqrt(x))+b”?
- What is the problem with that “createCdf”?
Thanks a lot,
Christian
now the little program (just compile within root):
#include "RooFormulaVar.h"
#include "RooWorkspace.h"
#include "RooRealVar.h"
#include "TH1.h"
#include "TCanvas.h"
#include "RooGaussian.h"
using namespace RooFit ;
void problem()
{
//I want to create a function (eg. a RooAbsReal) that is : F=phi(sqrt(x))
//where phi should be the cumulative Distribution (cdf) of the standart gaussian (mean=0,sigma=1)
RooWorkspace WS("WS","WS");
WS.factory("x[0,-900,900]");
WS.factory("expr::argument('(1*(x>=0)-1*(x<0))*sqrt(abs(x))',x)");
//I think RooFit may has problems with negativ arguments in a sqrt.
//to get standard gaussian with argument sqrt(x) that has no problems with normalisation I just used the absolute value
//of "x" in the sqrt and changeing the sign outside the sqrt, so the gaussian declared next is symmetric and has an
//argument that is also defined for negativ values
WS.factory("RooGaussian::gauss(argument,0,1)"); //creating standard gaussian with argument sqrt(x)
RooAbsReal* gauss_cdf = WS.pdf("gauss")->createCdf(WS.argSet("argument")); //creating cumulative distribution
//now, that should be it. But if you look now at the plots you see that gauss_cdf doas not look like a cdf.
//the interpreted function looks proper, the gaussian with sqrt(x) as argument looks also quite well, but the cdf doas not.
//it seems that the problem lies within the method "createCdf" in combination with an interpreted function as argument
//
TH1* hist_argument = WS.function("argument")->createHistogram("argument",*WS.var("x"),Binning(1800,-900,900));
TH1* hist_gauss = WS.pdf("gauss")->createHistogram("gauss",*WS.var("x"),Binning(60,-30,30));
TH1* hist_gauss_cdf = gauss_cdf->createHistogram("cdf",*WS.var("x"),Binning(60,-30,30));
TCanvas* c1 = new TCanvas("plot","plot",2000,2000) ;
c1->Divide(2,2);
c1->cd(1) ; hist_argument->Draw();
c1->cd(2) ; hist_gauss->Draw();
c1->cd(3) ; hist_gauss_cdf->Draw();
}