Re: fitting different subranges with different functions

From: Nevzat Guler <nguler_at_jlab.org>
Date: Sat, 14 Jul 2007 00:16:30 -0400 (EDT)

	Hello,
	Thanks for quick reply. The errors are zero only when the data is
zero because error is just scale*sqrt(data). When I force to fit with Minuit, it also did not converge.
Manually setting errors to some value is not safe because fitting is extremely effected from that even if there are 5-10 such points among 300 data points.. And I have more that 2000 such data with all different numbers of occasional zeros in them.. The best I can do is when error is zero, I can just equate data and error to the previous nonzero value, that should not make any harm but I wonder if there is a way to ignore/exclude data from fitting when it is zero?

I tried to use TF1::RejectPoint(); but it is not what I want, I want smooth fit.. (And strangely with zero points rejected, the fit still did not converge anyway..)

Apart from root question, I apologize if this is inapropriate for here, I would like to ask a separate fitting question: I am trying to determine amount of small bump at low x in the data attached (one example), I tried several user defined fitting functions but the best I can find is pol7, or pol7+pol2 averaged in some regions sometime gives better result.. But still, pol7 sometimes fails when I use error bars on the data.. With fine tuning, it can be made work but there are many similar data all have their peaks at different locations and the size of the bump peak also changes etc.. The data does not really have any clear function defined to it.
I tried poisson*gaussian fits as well, one example of fit i tried is also attached fitFunc1.C, compiler takes long time to finish that one and result is still very wiggly..
I wonder if anyone has a good technique to isolate the small bump at low x in such data without fine tuning for different cases.. Thanks,

                                Nevzat Guler

On Fri, 13 Jul 2007, Rene Brun wrote:

> Your TGraphErrors has several points with a null error in y. This gives
> an infinite weight to these points and the fit does not converge when
> fitting with a poln that uses by default the linear fitter.
> You can force a fit with equal weights for all points by doing
> graph.Fit("pol7","w");
> One can force a fit with Minuit (instead of the LinearFitter) by doing
> graph.Fit("pol7","l"); or graph.fit("pol7","lw");
>
> Rene Brun
>
> Nevzat Guler wrote:
> > Hello,
> > I am having a difficulty in finding a nice fit to the data I
> > am sending in attachment. I am mostly using pol7 for similar data in
> > different but this one fails. (By the way fitting converges if I
> > don't include errors to the graph (TGraph), but when I fit TGraphErrors it
> > fails..)
> > I have two questions:
> > 1. Is there a flag that I can look when fit fails, so that I can try
> > another function immediaetly in the program..
> >
> > 2.
> > I am trying to find a way to fit different subranges with
> > different functions but the demo multifit.C does not work for me. One of
> > the things I tried by using this example is printed at the end of this
> > email. The multifit.C example only uses parameters of fits from different
> > subranges and using them as initial parameters it manages to find
> > resulting combined fit. But what I need, I think, to fit different
> > subranges and then combine resulting fits, merge them. One way I can think
> > of to do this I can evaluate values of different fits and I can take their
> > average in overlapping regions but it is not a good way to do this, I am
> > wondering if there is a better and more reliable method..
> > I will appreciate any suggestion.
> >
> > Thanks,
> >
> > Double_t el_par[19];
> > TF1 *g1 = new TF1("g1","pol2",1,7);
> > TF1 *g2 = new TF1("g2","pol7",4,20);
> > TF1 *g3 = new TF1("g3","pol7",10,25);
> > TF1 *total = new TF1("total","pol2(0)+pol7(3)+pol7(11)",1.1,29);
> > total->SetLineColor(2);
> > EL_scl2EL->Fit("g1","R");
> > EL_scl2EL->Fit("g2","R+");
> > EL_scl2EL->Fit("g3","R+");
> > g1->GetParameters(&el_par[0]);
> > g2->GetParameters(&el_par[3]);
> > g3->GetParameters(&el_par[11]);
> > total->SetParameters(el_par);
> > total->SetParameters(el_par);
> > total->FixParameter(0,0.0);
> > EL_scl2EL->Fit(total,"R+");
> >
> >
> >
> > Nevzat Guler
>
>

Received on Sat Jul 14 2007 - 06:16:42 CEST

This archive was generated by hypermail 2.2.0 : Sat Jul 14 2007 - 11:50:01 CEST