# What is difference between RooChi2Var and RooPlot.chiSquare?

Dear Rooters,

I could not get same value from RooChi2Var and RooPlot.chiSquare.
Do they return the different value?
Following macro is sample, I could not get same values.
Is it normal? or is there a mistake?

{
TH1F h(“h”, “h”, 50, 0.0, 10.0);
for (Int_t i=0;i<1000;i++)h.Fill(gRandom->Gaus(5.0, 3.0));
h->Draw();
//
RooRealVar x (“x”, “x”, 0.0, 10.0);
RooRealVar mean (“mean”,“mean”, 0.0, 10.0);
RooRealVar sigma (“sigma”,“sigma”, 0.0, 10.0);
RooGaussian gauss (“gauss”, “gauss”, x, mean, sigma);
double integral_lower = 0.0;
double integral_upper = 10000000.0;
RooRealVar gauss_integral (“gauss_integral”, “gauss_integral”, integral_lower, integral_upper);
RooDataHist data (“data”, “data”, x, &h);
//
pdf.fitTo(data);
//
RooChi2Var chi2 (“chi2”, “chi2”, pdf, data);
Double_t chi2_val = chi2.getVal();
//
RooPlot* plot = x.frame();
data.plotOn(plot);
pdf.plotOn(plot);
pdf.plotOn(plot, RooFit::Components(gauss), RooFit::LineColor(2));
plot->Draw();
//
cout << "Integral value = " << gauss_integral.getVal() << endl;
cout << "Error = " << gauss_integral.getError() << endl << endl;
//
cout << "chi2 from RooChi2Var = " << chi2_val/(h.GetNbinsX()-2.0) << endl;
cout << "chi2 form plot = " << plot->chiSquare(2) << endl;
}

Best regards,