Re: root : unbinned fit 1D

From: Arthur E. Snyder <snyder_at_slac.stanford.edu>
Date: Sat, 5 Dec 2009 21:08:00 -0800


Marc,

Elemer's precription assumes you're fitting to a Gaussian PDF (probability density function) which is what I guess you wanted from the fit-to-histogram snipet you gave. Likeihood fits whether binned or unbinned are more general than that ... but Elemer's note shows what Gaussian unbinned likelihood would look like.

If I remember the syntax (maybe you should look it up) to do a _binned_ likelihood fit you just need to do

h->Fit("gaus","L")

If the bins are small compared to the width of your Gaussian this should be just as good as an unbinned fit and essentially no work. There's nothing magic about unbinned fit that makes it better than binned unless the bins are too big.

-Art S.

A.E. Snyder, Group EC                        \!c*p?/
SLAC Mail Stop #95                          ((.   .))
Box 4349                                        |
Stanford, Ca, USA, 94309                      '\|/`
e-mail:snyder_at_slac.stanford.edu                 o
phone:650-926-2701                              _
http://www.slac.stanford.edu/~snyder          BaBar
FAX:650-926-2657                          Collaboration



On Sun, 6 Dec 2009, Elemer Nagy wrote:

>
> Hi Marc,
>
> assuming that each of the N data points x_i is independent:
> construct a likelihood L as a product of Gaussians from the datapoints and
> apply MINUIT to determine the Gaussian central value, c and (if needed)
> its sigma, s. It is more easy if you take the logarithm of the likelihood,
> in this case you deal with the sum of data:
>
> - log L = Sum_i [(x_i-c)/s]**2/2 + N ln s
>
> Even w/o MINUIT you can solve the fit equations:
>
> dL/dc = dL/ds = 0
>
> which gives you (of course):
>
> c ~ c_f = 1/N Sum_i x_i
> and
> s ~ s_f = 1/N Sum_i (x_i - c_f)**2
>
> Elemer
>
>
> On Sun, 6 Dec 2009, Marc Escalier wrote:
>
> Dear root experts,
>
> would somebody know how to proceed to do a unbinned fit of a TH1 histo ?
>
> for example, lets consider
> MyTH1Histo->Fit("gaus")
>
> ==>i wish to do this fit, but with a unbinned fit
>
> thank you
>
> (i will thank those who know in private to prevent spamming people)
>
>
>
> --
> --------------------------------------------------------------------------
> | Elemér Nagy | Phone : (+33) (0)4-91-82-72-73
> |
> | C.P.P.M. | Fax : (+33) (0)4-91-82-72-99 |
> | 163, av. de Luminy Case 902 | Internet : nagy_at_cppm.in2p3.fr |
> | F-13288 Marseille CEDEX 09 | |
> | FRANCE | |
> --------------------------------------------------------------------------
>
>
Received on Sun Dec 06 2009 - 06:08:18 CET

This archive was generated by hypermail 2.2.0 : Mon Dec 07 2009 - 11:50:02 CET