Re: Limiting Y range in TGraph::Fit

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 20 Oct 2010 08:29:37 +0200


Sorry, I misread your mail, confusing Draw and Fit. To do what you want, you have 2 possibilities

   -use the ExcludePoint facility of TF1(see example in tutorials/fit/fitExclude.C), but you have to write your own function instead of pol1.
  -use a TGraphErrors instead of TGraph and assign a huge error to the point that you want to exclude.

Rene

OKUMURA, Akira wrote:
> Hello Rene,
>
> Thank you for your quick reply. But it does not work as I expected. In the following example, the fit result should be y = x, by the actual result is y = 1.4 x - 0.8
>
> root [0] TGraph* gra = new TGraph
> root [1] gra->SetPoint(0, 0, -1)
> root [2] gra->SetPoint(1, 1, 1)
> root [3] gra->SetPoint(2, 2, 2)
> root [4] gra->SetPoint(3, 3, 3)
> root [5] gra->SetPoint(4, 4, 5)
> root [6] gra->SetMaximum(4)
> root [7] gra->SetMinimum(0)
> root [8] gra->Fit("pol1")
> ****************************************
> Minimizer is Linear
> Chi2 = 0.4
> NDf = 3
> p0 = -0.8 +/- 0.282843
> p1 = 1.4 +/- 0.11547
> (class TFitResultPtr)4329991824
> root [9] gra->Draw("a*")
>
> Regards,
>
> --
> OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu}
> Institute of Space and Astronautical Science (ISAS/JAXA)
> Now at KIPAC/SLAC/Stanford
> Varian Physics #306, 382 Via Pueblo Mall, MC 4060
> Stanford, CA 94305-4060
> TEL 650-736-0971/FAX 650-724-5065
> Skype : okumura.akira
>
> On 2010/10/19, at 11:53, Rene Brun wrote:
>
>
>> Use TGraph::SetMaximum, SetMinimum
>>
>> Rene Brun
>>
>>
>> On 19/10/2010 20:45, OKUMURA, Akira wrote:
>>
>>> Hello ROOTers,
>>>
>>> Is there any simple way to limit the Y range in TGraph::Fit?
>>>
>>> The 4th and 5th arguments (rxmin, rxmax) in the regular TGraph::Fit method are used for the high/low limit of the X axis. But I would like to set rymin and rymax instead.
>>>
>>> Of course, I can do it manually by removing data points outside the range from a graph. But if there is a better solution which is already implemented, I would use it.
>>>
>>> Regards,
>>>
>>> --
>>> OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu}
>>> Institute of Space and Astronautical Science (ISAS/JAXA)
>>> Now at KIPAC/SLAC/Stanford
>>> Varian Physics #306, 382 Via Pueblo Mall, MC 4060
>>> Stanford, CA 94305-4060
>>> TEL 650-736-0971/FAX 650-724-5065
>>> Skype : okumura.akira
>>>
>>>
>
>
Received on Wed Oct 20 2010 - 08:29:42 CEST

This archive was generated by hypermail 2.2.0 : Wed Oct 20 2010 - 17:50:01 CEST