Re: [ROOT] Fitting problems

From: Emily Nurse (emily@hep.man.ac.uk)
Date: Sat Apr 20 2002 - 00:29:02 MEST


Hi Rene,
I tried that but it didn't work. I use the histogram to make the user
defined function which I fit my TGraphError to, which is just my data
points and their associated errors. So will the errors on the histogram be
used?
Emily.


On Fri, 19 Apr 2002, Rene Brun wrote:

> Emily,
>
> It looks like your histogram bin errors are not defined
> correctly.
> By default (if TH1::Sumw2 was not called before filling),
> the bin error will be the sqrt(bin content).
> In case you have filled your histograms with weights
> or have made an operation (add,multiply,divide,scale)
> and you did not call TH1::Sumw2, your errors are
> meaningless. The fit parameters may be OK, but
> certainly not the chisquare and the errors on the
> parameters.
> So, check this point first. If you do not find a solution,
> send me a Root file containing the histogram you want
> to fit together with a small script containing
> your fitting function and the calls to TH1::Fit
>
> Rene Brun
>
> On Fri, 19 Apr 2002, Emily Nurse wrote:
>
> > Hi Rene,
> >
> > I am fitting a user defined function (just the bin content from a
> > histogramme as a function of x-axis) to data points. I want to do it
> > without changing the normalisation scale how-ever when I use the option
> > "w" my chisquared value is too large. I have checked by getting the
> > integral of my function before and after fitting without the "w" option so
> > as to get the normalisation constant. I then weight my function by the
> > ratio of these integrals and then make a fit with the "w" option. My
> > chisquared value is nearly a factor 10 higher when really it should be the
> > same. Can you explain?
> > Cheers,
> > Emily.
> >
> >
> > On Fri, 15 Mar 2002, Rene Brun wrote:
> >
> > > Hi Emily,
> > >
> > >
> > >
> > > On Thu, 14 Mar 2002, Emily Nurse wrote:
> > >
> > > > Hello,
> > > > I have a couple of questions involving the Fit function.
> > > > Firstly when I use it it normalises my user defined function for me to
> > > > give the loest possible chisquared value when fitted to my data points. I
> > > > was wandering if I could switch this action off and just get a straight
> > > > forward chisquared value as I will be fitting different ranges seperately
> > > > that need to be normalised by the same amount even though this may not
> > > > give the lowest chi-squared value.
> > >
> > > If you use the fit option "w" (all weights equal to 1), you should obtain
> > > what you want.
> > >
> > > >
> > > Secondly I am getting an error message when I run my macro which includes
> > > > the function:
> > > >
> > > >  Double_t norm ( Double_t *x, Double_t *par)
> > > >             {
> > > > 	    Double_t xx=x[0];
> > > >             Int_t bin = w_pte1->GetXaxis()->FindBin(xx);
> > > >             return par[0]*(w_pte1->GetBinContent(bin));
> > > >             }
> > > >
> > > > (where w_pte1 is a TH1D object). Then at the root prompt I type:
> > >
> > > But where do you define it ?
> > > If the code above is in a macro, declare your TH1D object as global.
> > >
> > > Rene Brun
> > >
> > > >
> > > > root [3] TF1 *f1 = new TF1("norm",norm,0.,50.,1)
> > > > root [5] f1->SetParameter(0,1)
> > > > root [6] f1->Draw()
> > > > <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
> > > > Error: non class,struct,union object $w_pte1 used with . or ->Error: non
> > > > class,struct,union object $w_pte1 used with . or ->Error: non
> > > > class,struct,union object $w_pte1 used with . or ->root [7]
> > > >
> > > > Things do seem to work but I was wandering what I was doing wrong,
> > > > thanks for your help,
> > > > Emily.
> > > >
> > >
> >
>



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:50 MET