RE: Fitting/minimizing Python functions.

From: Amnon Harel <amnon.harel_at_cern.ch>
Date: Tue, 28 Feb 2012 22:14:10 +0000


Hi Brett,

For what it's worth, I'm just going through the process Axel is describing right now :-)

This is basically a bet on Minuit working well for your problem. The last 40 years or so have shown that to be an amazingly good bet. There are many more fitting algorithms available in python from scipy. My colleagues and myself have had mixed results from them, so I'm going back to Minuit, and re-coding the low-level fitting code in C++.

(there are also some other options on the C++ side)

 cheers,
 Amnon Harel
 University of Rochester



From: owner-roottalk_at_root.cern.ch [owner-roottalk_at_root.cern.ch] on behalf of Axel Naumann [Axel.Naumann_at_cern.ch] Sent: 28 February 2012 22:06
To: brett viren
Cc: roottalk (Mailing list discussing all aspects of the ROOT system.) Subject: Re: [ROOT] Fitting/minimizing Python functions.

Hi Brett,

> Any opinions on the "best" route to take for a Python-side fitter?
> Pointers to docs/examples are also appreciated.

Yes: write your minimization function in compiled C++ (I intentionally misread your question).

Especially if you might have to move it to C++ in the future then this will save you a lot of (probably already) wasted time. And trust me, it's *much* more likely that you will actually benefit from the extra performance of compiled code if you start with compiled (or at least compilable) code. Otherwise you'll always weigh the amount of effort you have invested into your fragile python + fitting + root setup plus the effort it takes to rewrite and verify it in compiled C++ and the possible but unknown until implemented performance improvement.

Cheers, Axel.

On 2/28/12 7:00 PM, Brett Viren wrote:
> Hi,
>
> I'm looking for a good way to develop a fitter (chi-squared
> minimization) in Python (ie, a Python-defined model) with the
> option to later port everything to C++ after the kinks are worked
> out and only if necessary for runtime speed.
>
> I'm a little confused about the available options. What I've
> found:
>
> * ROOT has a Python interface to its TMinuit F77->C++
> transliteration. This appears to be best supported in ROOT, has
> been made to accept Python functions but keeps and exposes a very
> F77 interface.
>
> * ROOT has a copy of the C++ rewrite, Minuit2. In principle this
> would give a more "pythonic" interface but currently requires
> subclassing from C++ so is apparently a non-starter for Python
> functions (?) There has been some discussion in the forum about
> this but I don't find a conclusion.
>
> * There are two related projects on google code[1] which provide
> Python interfaces to the stand-alone Minuit2 and ROOT's slightly
> modified version. This looks good but it means yet another package
> for our code base (not a deal breaker) and I'm unclear as to future
> plans.
>
> * There is ROOT.Fit.Fitter() but it won't accept a Python function
> (?)
>
> * I find RooFit available Python-side but its largeness has kept
> me away so far.
>
> Any opinions on the "best" route to take for a Python-side fitter?
> Pointers to docs/examples are also appreciated.
>
> Thanks, -Brett.
>
>
> [1] http://code.google.com/p/pyminuit/ and
> http://code.google.com/p/pyminuit2/
Received on Tue Feb 28 2012 - 23:14:19 CET

This archive was generated by hypermail 2.2.0 : Wed Feb 29 2012 - 11:50:01 CET