RooNDKeysPDF and getVal

I’m trying to calculate a measure (Mututal Information) where I need f(x,y)/(f(x)*f(y)). I’d like to use KeysPDFs for this but have run into a problem if nothing else in my understanding of the normalisation of RooNDKeysPDF.
Here’s a sample code (TTree: tree is loaded earlier as pointer):

RooRealVar pointx("pointx","pointx",-10.,10.);
RooRealVar pointy("pointy","pointy",-10.,10.) ;
RooDataSet* data = new RooDataSet("data","dataset",RooArgSet(pointx,pointy),Import(*tree) );

RooKeysPdf keys1("keys1","keys1",pointx,*data,RooKeysPdf::MirrorBoth) ;
RooKeysPdf keys2("keys2","keys2",pointy,*data,RooKeysPdf::MirrorBoth) ;
RooNDKeysPdf keys12("keys12","keys12",RooArgSet(pointx,pointy),*data,"am") ;

RooArgSet* pdfObs = keys12.getObservables(data) ; double sum12=0; double sum1=0;

for (int i=0 ; i<data->numEntries() ; i++) {
	*pdfObs = *data->get(i);
         cout << "keys12.getVal() " <<keys12.getVal()<< endl;
	 cout << "keys12.getNorm() " <<keys12.getNorm()<< endl;
         cout<< "keys1.getVal() " << keys1.getVal()  << endl;
	  cout << "keys1.getNorm() " <<keys1.getNorm()<< endl;
	  cout << "keys12.getVal(pdfObs) " <<keys12.getVal(pdfObs)<< endl;
	  cout << "keys12.getNorm(pdfObs) " <<keys12.getNorm(pdfObs)<< endl;
	  cout << "keys1.getVal(pdfObs) " << keys1.getVal(pdfObs)  << endl;

with the output for each event:
keys12.getVal() 40.4498
keys12.getNorm() 1
keys1.getVal() 0.189049
keys1.getNorm() 1
keys12.getVal(pdfObs) 0.404498
keys12.getNorm(pdfObs) 100
keys1.getVal(pdfObs) 0.567152
keys1.getNorm(pdfObs) 0.333331
… etc …

keys12.getVal() larger than 1 I believe is because it is the normalised to number of entries in the dataset which is 100. I however still don’t understand the value and the sum total for alle entries is ~1000 for the keys12.getVal(). and ~10 for the two others. To how this makes sense I’m at a complete loss. What I really just want are the values at x for the pdfs normalised to unity.

Any help would be most appreciated,


Hi just to make my question even more clear it is along the lines of: RooFit: Evaluate fitted function at a point
Is it correct to use getVal() to get the y value of a pdf for a given x value and if so how is the normalisation to be understood? I’ve included an even simpler example to illustrate.

[code] RooRealVar x(“x”,“x”,-10,10) ;
RooRealVar mean(“mean”,“mean of gaussian”,0,-10,10) ;
RooRealVar sigma(“sigma”,“width of gaussian”,7) ;
RooGaussian gauss(“gauss”,“gaussian PDF”,x,mean,sigma) ;

// Generate a toy MC set
RooDataSet* data = gauss.generate(x,1000) ;

double sum=0;
RooArgSet test(x);
for (int i=0 ; inumEntries() ; i++) {
test = *data->get(i);
cout << data->sumEntries()<<endl;
cout << sum << endl;
cout << (gauss.createIntegral(x,x))->getVal() << endl;
sumEntries is of course 1000, and the inegral is 1 but the sum is 799.096 so it seems to me, that they sum to 0.8 and not 1 and that the value is dependent on sigma, e.g. something like the area described by the gauss relative to a flat distribution with y=1 in the x-range. I’m sure the logic is simple but I haven’t been able to find out sp any help would be most appreciated.