Dear ROOTers,
I would like to implement the Vavilov distribution in MathMore.
In CERNLIB there are two implementations: G115 wwwasdoc.web.cern.ch/wwwasdoc/sh … 6/top.html (VVIDEN etc), where G115 is supposedly faster, and G116 is more accurate.
Curently, G115 is implemented in TMath::Vavilov and TMath::VavilovI,
G116 is unavailable in ROOT (as far as I know).
Both methods need a relatively expensive setup routine to be called before the function can be evaluated. In TMath::Vavilov, the setup is repeated every time, which is probably not optimal in terms of speed. I think that a class is more suited to this problem, where the object holds the setup information for a specific combination of kappa and beta.
I propose the following:
- Define a base class Vavilov, with two subclasses VavilovFast (G115) and VavilovAccurate (G116).
- Vavilov has these methods:
- set (kappa, beta2) // set or change kappa and beta2
- pdf (x) //evaluates the pdf
- pdf (x, kappa, beta2) // if necessary, calls set, then evaluates the pdf
- cdf (x)
- cdf (x, kappa, beta2)
- quantile (z) // only for VavilovFast
- quantile (z, kappa, beta2)
For many applications, free functions
- vavilov_pdf
- vavilov_cdf
- vavilov_quantile
are probably needed. I propose to add a static “instance” pointer to the Vavilov base class, plus something like “SetPolicy” (either kFast or kAccurate), and implement the free functions like this:
double vavilov_pdf (x, kappa, beta2) {
Vavilov *v = Vavilov::GetInstance();
return v->pdf (x, kappa, beta);
}
I have already written a first version of VavilovAccurate, by the way.
Any comments or suggestions?
Cheers, Benno