Class describing a Vavilov distribution.
The probability density function of the Vavilov distribution as function of Landau's parameter is given by:
\[ p(\lambda_L; \kappa, \beta^2) = \frac{1}{2 \pi i}\int_{c-i\infty}^{c+i\infty} \phi(s) e^{\lambda_L s} ds\]
where \(\phi(s) = e^{C} e^{\psi(s)}\) with \( C = \kappa (1+\beta^2 \gamma )\) and \(\psi(s)= s \ln \kappa + (s+\beta^2 \kappa) \cdot \left ( \int \limits_{0}^{1} \frac{1 - e^{\frac{-st}{\kappa}}}{t} \,d t- \gamma \right ) - \kappa \, e^{\frac{-s}{\kappa}}\). \( \gamma = 0.5772156649\dots\) is Euler's constant.
For the class VavilovAccurate, Pdf returns the Vavilov distribution as function of Landau's parameter \(\lambda_L = \lambda_V/\kappa - \ln \kappa\), which is the convention used in the CERNLIB routines, and in the tables by S.M. Seltzer and M.J. Berger: Energy loss stragglin of protons and mesons: Tabulation of the Vavilov distribution, pp 187-203 in: National Research Council (U.S.), Committee on Nuclear Science: Studies in penetration of charged particles in matter, Nat. Akad. Sci. Publication 1133, Nucl. Sci. Series Report No. 39, Washington (Nat. Akad. Sci.) 1964, 388 pp. Available from Google books
Therefore, for small values of \(\kappa < 0.01\), pdf approaches the Landau distribution.
For values \(\kappa > 10\), the Gauss approximation should be used with \(\mu\) and \(\sigma\) given by Vavilov::mean(kappa, beta2) and sqrt(Vavilov::variance(kappa, beta2).
The original Vavilov pdf is obtained by v.Pdf(lambdaV/kappa-log(kappa))/kappa.
For detailed description see B. Schorr, Programs for the Landau and the Vavilov distributions and the corresponding random numbers, Computer Phys. Comm. 7 (1974) 215-224, which has been implemented in CERNLIB (G116).
The class stores coefficients needed to calculate \(p(\lambda; \kappa, \beta^2)\) for fixed values of \(\kappa\) and \(\beta^2\). Changing these values is computationally expensive.
The parameter \(\kappa\) should be in the range \(0.01 \le \kappa \le 10\). In contrast to the CERNLIB implementation, all values of \(\kappa \ge 0.001\) may be used, but may result in slower running and/or inaccurate results.
The parameter \(\beta^2\) must be in the range \(0 \le \beta^2 \le 1\).
Two parameters which are fixed in the CERNLIB implementation may be set by the user:
For the quantile calculation, the algorithm given by Schorr is not used, because it turns out to be very slow and still inaccurate. Instead, an initial estimate is calculated based on a pre-calculated table, which is subsequently improved by Newton iterations.
While the CERNLIB implementation calculates at most 156 terms in the series expansion for the pdf and cdf calculation, this class calculates up to 500 terms, depending on the values of epsilonPM and epsilon.
Average times on a Pentium Core2 Duo P8400 2.26GHz:
Benno List, June 2010
Definition at line 131 of file VavilovAccurate.h.
Public Member Functions | |
VavilovAccurate (double kappa=1, double beta2=1, double epsilonPM=5E-4, double epsilon=1E-5) | |
Initialize an object to calculate the Vavilov distribution. | |
~VavilovAccurate () override | |
Destructor. | |
double | Cdf (double x) const override |
Evaluate the Vavilov cumulative probability density function. | |
double | Cdf (double x, double kappa, double beta2) override |
Evaluate the Vavilov cumulative probability density function, and set kappa and beta2, if necessary. | |
double | Cdf_c (double x) const override |
Evaluate the Vavilov complementary cumulative probability density function. | |
double | Cdf_c (double x, double kappa, double beta2) override |
Evaluate the Vavilov complementary cumulative probability density function, and set kappa and beta2, if necessary. | |
double | GetBeta2 () const override |
Return the current value of \(\beta^2\). | |
double | GetEpsilon () const |
Return the current value of \(\epsilon\). | |
double | GetEpsilonPM () const |
Return the current value of \(\epsilon^+ = \epsilon^-\). | |
double | GetKappa () const override |
Return the current value of \(\kappa\). | |
double | GetLambdaMax () const override |
Return the maximum value of \(\lambda\) for which \(p(\lambda; \kappa, \beta^2)\) is nonzero in the current approximation. | |
double | GetLambdaMin () const override |
Return the minimum value of \(\lambda\) for which \(p(\lambda; \kappa, \beta^2)\) is nonzero in the current approximation. | |
double | GetNTerms () const |
Return the number of terms used in the series expansion. | |
double | Mode () const override |
Return the value of \(\lambda\) where the pdf is maximal. | |
double | Mode (double kappa, double beta2) override |
Return the value of \(\lambda\) where the pdf is maximal function, and set kappa and beta2, if necessary. | |
double | Pdf (double x) const override |
Evaluate the Vavilov probability density function. | |
double | Pdf (double x, double kappa, double beta2) override |
Evaluate the Vavilov probability density function, and set kappa and beta2, if necessary. | |
double | Quantile (double z) const override |
Evaluate the inverse of the Vavilov cumulative probability density function. | |
double | Quantile (double z, double kappa, double beta2) override |
Evaluate the inverse of the Vavilov cumulative probability density function, and set kappa and beta2, if necessary. | |
double | Quantile_c (double z) const override |
Evaluate the inverse of the complementary Vavilov cumulative probability density function. | |
double | Quantile_c (double z, double kappa, double beta2) override |
Evaluate the inverse of the complementary Vavilov cumulative probability density function, and set kappa and beta2, if necessary. | |
void | Set (double kappa, double beta2, double epsilonPM=5E-4, double epsilon=1E-5) |
(Re)Initialize the object | |
void | SetKappaBeta2 (double kappa, double beta2) override |
Change \(\kappa\) and \(\beta^2\) and recalculate coefficients if necessary. | |
Public Member Functions inherited from ROOT::Math::Vavilov | |
Vavilov () | |
Default constructor. | |
virtual | ~Vavilov () |
Destructor. | |
virtual double | Kurtosis () const |
Return the theoretical kurtosis \(\gamma_2 = \frac{1/3 - \beta^2/4}{\kappa^3 \sigma^4}\). | |
virtual double | Mean () const |
Return the theoretical mean \(\mu = \gamma-1- \ln \kappa - \beta^2\), where \(\gamma = 0.5772\dots\) is Euler's constant. | |
virtual double | Skewness () const |
Return the theoretical skewness \(\gamma_1 = \frac{1/2 - \beta^2/3}{\kappa^2 \sigma^3} \). | |
virtual double | Variance () const |
Return the theoretical variance \(\sigma^2 = \frac{1 - \beta^2/2}{\kappa}\). | |
Static Public Member Functions | |
static VavilovAccurate * | GetInstance () |
Returns a static instance of class VavilovFast. | |
static VavilovAccurate * | GetInstance (double kappa, double beta2) |
Returns a static instance of class VavilovFast, and sets the values of kappa and beta2. | |
Static Public Member Functions inherited from ROOT::Math::Vavilov | |
static double | Kurtosis (double kappa, double beta2) |
Return the theoretical kurtosis \(\gamma_2 = \frac{1/3 - \beta^2/4}{\kappa^3 \sigma^4}\). | |
static double | Mean (double kappa, double beta2) |
Return the theoretical Mean \(\mu = \gamma-1- \ln \kappa - \beta^2\). | |
static double | Skewness (double kappa, double beta2) |
Return the theoretical skewness \(\gamma_1 = \frac{1/2 - \beta^2/3}{\kappa^2 \sigma^3} \). | |
static double | Variance (double kappa, double beta2) |
Return the theoretical Variance \(\sigma^2 = \frac{1 - \beta^2/2}{\kappa}\). | |
Private Member Functions | |
double | G116f1 (double x) const |
double | G116f2 (double x) const |
void | InitQuantile () const |
int | Rzero (double a, double b, double &x0, double eps, int mxf, double(VavilovAccurate::*f)(double) const) const |
Static Private Member Functions | |
static double | E1plLog (double x) |
Private Attributes | |
double | fA_cdf [MAXTERMS+1] |
double | fA_pdf [MAXTERMS+1] |
double | fB_cdf [MAXTERMS+1] |
double | fB_pdf [MAXTERMS+1] |
double | fBeta2 |
double | fEpsilon |
double | fEpsilonPM |
double | fH [8] |
double | fKappa |
double | fLambda [kNquantMax] |
int | fNQuant |
double | fOmega |
double | fQuant [kNquantMax] |
bool | fQuantileInit |
double | fT |
double | fT0 |
double | fT1 |
double | fX0 |
Static Private Attributes | |
static VavilovAccurate * | fgInstance = nullptr |
static constexpr int | kNquantMax {32} |
static constexpr int | MAXTERMS {500} |
#include <Math/VavilovAccurate.h>
ROOT::Math::VavilovAccurate::VavilovAccurate | ( | double | kappa = 1 , |
double | beta2 = 1 , |
||
double | epsilonPM = 5E-4 , |
||
double | epsilon = 1E-5 |
||
) |
Initialize an object to calculate the Vavilov distribution.
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
epsilonPM | \(\epsilon^+ = \epsilon^-\) in Eqs. (2.1) and (2.2) of Schorr's paper; gives an estimate on the integral of the cumulative distribution function outside the range \(\lambda_{min} \le \lambda \le \lambda_{max}\) where the approximation is valid. |
epsilon | \(\epsilon\) in Eq. (4.10) of Schorr's paper; determines the accuracy of the series expansion. |
Definition at line 51 of file VavilovAccurate.cxx.
|
override |
Destructor.
Definition at line 57 of file VavilovAccurate.cxx.
Evaluate the Vavilov cumulative probability density function.
x | The Landau parameter \(x = \lambda_L\) |
Implements ROOT::Math::Vavilov.
Definition at line 256 of file VavilovAccurate.cxx.
Evaluate the Vavilov cumulative probability density function, and set kappa and beta2, if necessary.
x | The Landau parameter \(x = \lambda_L\) |
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
Implements ROOT::Math::Vavilov.
Definition at line 291 of file VavilovAccurate.cxx.
Evaluate the Vavilov complementary cumulative probability density function.
x | The Landau parameter \(x = \lambda_L\) |
Implements ROOT::Math::Vavilov.
Definition at line 296 of file VavilovAccurate.cxx.
Evaluate the Vavilov complementary cumulative probability density function, and set kappa and beta2, if necessary.
x | The Landau parameter \(x = \lambda_L\) |
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
Implements ROOT::Math::Vavilov.
Definition at line 331 of file VavilovAccurate.cxx.
Definition at line 644 of file VavilovAccurate.cxx.
Definition at line 486 of file VavilovAccurate.cxx.
Definition at line 495 of file VavilovAccurate.cxx.
|
overridevirtual |
Return the current value of \(\beta^2\).
Implements ROOT::Math::Vavilov.
Definition at line 671 of file VavilovAccurate.cxx.
double ROOT::Math::VavilovAccurate::GetEpsilon | ( | ) | const |
Return the current value of \(\epsilon\).
Definition at line 703 of file VavilovAccurate.cxx.
double ROOT::Math::VavilovAccurate::GetEpsilonPM | ( | ) | const |
Return the current value of \(\epsilon^+ = \epsilon^-\).
Definition at line 699 of file VavilovAccurate.cxx.
|
static |
Returns a static instance of class VavilovFast.
Definition at line 450 of file VavilovAccurate.cxx.
|
static |
Returns a static instance of class VavilovFast, and sets the values of kappa and beta2.
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
Definition at line 455 of file VavilovAccurate.cxx.
|
overridevirtual |
Return the current value of \(\kappa\).
Implements ROOT::Math::Vavilov.
Definition at line 667 of file VavilovAccurate.cxx.
|
overridevirtual |
Return the maximum value of \(\lambda\) for which \(p(\lambda; \kappa, \beta^2)\) is nonzero in the current approximation.
Implements ROOT::Math::Vavilov.
Definition at line 663 of file VavilovAccurate.cxx.
|
overridevirtual |
Return the minimum value of \(\lambda\) for which \(p(\lambda; \kappa, \beta^2)\) is nonzero in the current approximation.
Implements ROOT::Math::Vavilov.
Definition at line 659 of file VavilovAccurate.cxx.
double ROOT::Math::VavilovAccurate::GetNTerms | ( | ) | const |
Return the number of terms used in the series expansion.
Definition at line 707 of file VavilovAccurate.cxx.
|
private |
Definition at line 185 of file VavilovAccurate.cxx.
|
overridevirtual |
Return the value of \(\lambda\) where the pdf is maximal.
Reimplemented from ROOT::Math::Vavilov.
Definition at line 675 of file VavilovAccurate.cxx.
Return the value of \(\lambda\) where the pdf is maximal function, and set kappa and beta2, if necessary.
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
Reimplemented from ROOT::Math::Vavilov.
Definition at line 694 of file VavilovAccurate.cxx.
Evaluate the Vavilov probability density function.
x | The Landau parameter \(x = \lambda_L\) |
Implements ROOT::Math::Vavilov.
Definition at line 217 of file VavilovAccurate.cxx.
Evaluate the Vavilov probability density function, and set kappa and beta2, if necessary.
x | The Landau parameter \(x = \lambda_L\) |
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
Implements ROOT::Math::Vavilov.
Definition at line 251 of file VavilovAccurate.cxx.
Evaluate the inverse of the Vavilov cumulative probability density function.
z | The argument \(z\), which must be in the range \(0 \le z \le 1\) |
Implements ROOT::Math::Vavilov.
Definition at line 336 of file VavilovAccurate.cxx.
|
overridevirtual |
Evaluate the inverse of the Vavilov cumulative probability density function, and set kappa and beta2, if necessary.
z | The argument \(z\), which must be in the range \(0 \le z \le 1\) |
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
Implements ROOT::Math::Vavilov.
Definition at line 383 of file VavilovAccurate.cxx.
Evaluate the inverse of the complementary Vavilov cumulative probability density function.
z | The argument \(z\), which must be in the range \(0 \le z \le 1\) |
Implements ROOT::Math::Vavilov.
Definition at line 388 of file VavilovAccurate.cxx.
|
overridevirtual |
Evaluate the inverse of the complementary Vavilov cumulative probability density function, and set kappa and beta2, if necessary.
z | The argument \(z\), which must be in the range \(0 \le z \le 1\) |
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
Implements ROOT::Math::Vavilov.
Definition at line 445 of file VavilovAccurate.cxx.
|
private |
Definition at line 504 of file VavilovAccurate.cxx.
void ROOT::Math::VavilovAccurate::Set | ( | double | kappa, |
double | beta2, | ||
double | epsilonPM = 5E-4 , |
||
double | epsilon = 1E-5 |
||
) |
(Re)Initialize the object
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
epsilonPM | \(\epsilon^+ = \epsilon^-\) in Eqs. (2.1) and (2.2) of Schorr's paper; gives an estimate on the integral of the cumulative distribution function outside the range \(\lambda_{min} \le \lambda \le \lambda_{max}\) where the approximation is valid. |
epsilon | \(\epsilon\) in Eq. (4.10) of Schorr's paper; determines the accuracy of the series expansion. |
Definition at line 66 of file VavilovAccurate.cxx.
Change \(\kappa\) and \(\beta^2\) and recalculate coefficients if necessary.
kappa | The parameter \(\kappa\), which must be in the range \(\kappa \ge 0.001 \) |
beta2 | The parameter \(\beta^2\), which must be in the range \(0 \le \beta^2 \le 1 \) |
Implements ROOT::Math::Vavilov.
Definition at line 62 of file VavilovAccurate.cxx.
Definition at line 333 of file VavilovAccurate.h.
Definition at line 333 of file VavilovAccurate.h.
Definition at line 333 of file VavilovAccurate.h.
Definition at line 333 of file VavilovAccurate.h.
|
private |
Definition at line 334 of file VavilovAccurate.h.
|
private |
Definition at line 335 of file VavilovAccurate.h.
|
private |
Definition at line 335 of file VavilovAccurate.h.
|
staticprivate |
Definition at line 345 of file VavilovAccurate.h.
|
private |
Definition at line 333 of file VavilovAccurate.h.
|
private |
Definition at line 334 of file VavilovAccurate.h.
|
mutableprivate |
Definition at line 341 of file VavilovAccurate.h.
|
mutableprivate |
Definition at line 338 of file VavilovAccurate.h.
|
private |
Definition at line 333 of file VavilovAccurate.h.
|
mutableprivate |
Definition at line 340 of file VavilovAccurate.h.
|
mutableprivate |
Definition at line 337 of file VavilovAccurate.h.
|
private |
Definition at line 333 of file VavilovAccurate.h.
|
private |
Definition at line 333 of file VavilovAccurate.h.
|
private |
Definition at line 333 of file VavilovAccurate.h.
|
private |
Definition at line 333 of file VavilovAccurate.h.
|
staticconstexprprivate |
Definition at line 339 of file VavilovAccurate.h.
|
staticconstexprprivate |
Definition at line 332 of file VavilovAccurate.h.