Error scaling in weighted fits


when performing extended likelihood fits to weighted datasets, the fitted yield uncertainty (unlike the fitted yield itself) is observed not to scale with the weights as would be expected

this is illustrated for a simple toy gaussian model, see attached code, plot and numbers

this uses a recent Root version 5.30/02, and the fitting setting is

could someone please advise whether there are better settings one could use, or how the systematic bias could be accounted for (eg for weights >10 the relative error appears to be underestimated by a constant factor of about 30%)

thanks in advance,

ps: for fit parameters which do not scale with the yield the uncertainties appear to be comparably stable

using namespace RooFit ;

void weight(double wgt=1.0) {

  // define a gaussian model
  RooRealVar x1("x1","x1",8,11);
  RooRealVar sigma1("sigma1","sigma1",0.1,0.05,0.2) ;
  RooRealVar mean1("mean1","mean1",9.46,8,11) ;
  RooRealVar n1("yield1","number of events",10000,0,10000000) ;
  RooGaussian gauss1("gauss1","gauss1",x1,mean1,sigma1) ;
  RooExtendPdf egauss1("egauss1","extended gaussian PDF",gauss1,n1) ;

  //generate dataset
  RooDataSet* data1 = egauss1.generate(x1,10000) ;

  //add constant weight to the dataset
  RooRealVar w("w","w",wgt);
  RooDataSet* wdata =  new RooDataSet("wdata", "wdata", *data1->get(), Import(*data1), WeightVar("w"));
  // fit the data 
  RooFitResult* fitres = egauss1.fitTo(*wdata,Extended(kTRUE),Save(),SumW2Error(kTRUE)) ;

  double yield     = ((RooRealVar*)fitres->floatParsFinal().find("yield1"))->getVal();
  double yield_err = ((RooRealVar*)fitres->floatParsFinal().find("yield1"))->getError();

  printf("weight %3.0f:\t", w.getVal());
  printf("yield: %6.0f +/- %4.0f \t rel. error: %4.2f%%\n",
	   yield, yield_err, yield_err/yield*100);