49 VavilovAccurate *VavilovAccurate::fgInstance = 0;
54 Set (kappa, beta2, epsilonPM, epsilon);
78 static const double eu = 0.577215664901532860606;
79 static const double pi2 = 6.28318530717958647693,
80 rpi = 0.318309886183790671538,
81 pih = 1.57079632679489661923;
83 double deltaEpsilon = 0.001;
84 static const double logdeltaEpsilon = -
std::log(deltaEpsilon);
86 static const double eps = 1e-5;
89 9.29, 2.47, 0.89, 0.36, 0.15, 0.07, 0.03, 0.02};
91 0.012, 0.03, 0.08, 0.26, 0.87, 3.83};
94 std::cerr <<
"VavilovAccurate::Set: kappa = " << kappa <<
" - out of range" << std::endl;
95 if (kappa < 0.001) kappa = 0.001;
97 if (beta2 < 0 || beta2 > 1) {
98 std::cerr <<
"VavilovAccurate::Set: beta2 = " << beta2 <<
" - out of range" << std::endl;
99 if (beta2 < 0) beta2 = -beta2;
100 if (beta2 > 1) beta2 = 1;
104 fH[5] = 1-beta2*(1-
eu)-logEpsilonPM/kappa;
107 double h4 = logEpsilonPM/kappa-(1+beta2*
eu);
109 double kappaInv = 1/kappa;
115 while (lp < 9 && kappa < xp[lp]) ++lp;
117 while (lq < 7 && kappa >= xq[lq]) ++
lq;
124 }
while (ifail == 2);
134 fH[1] = kappa*(2+beta2*
eu)+h1;
135 if(kappa >= 0.07) fH[1] += logdeltaEpsilon;
157 double d = rpi*
std::exp(kappa*(1+beta2*(eu-logKappa)));
162 for (
int k = 1; k <
n; ++k) {
165 double x1 = kappaInv*
x;
170 double xf1 = kappa*(beta2*c1-c4)-x*c2;
171 double xf2 = x*(c1 +
fT0) + kappa*(c3+beta2*c2);
172 double d1 = q*d*fOmega*
std::exp(xf1);
191 if (
fKappa < 0.02)
return;
197 if (estmedian>1.3) estmedian = 1.3;
200 for (
int i = 1; i <
fNQuant/2; ++i) {
206 double x = estmedian + (i-fNQuant/2)*(
fT1-estmedian)/(fNQuant/2-1);
220 static const double pi = 3.14159265358979323846;
226 }
else if (x <=
fT1) {
229 double cof = 2*
cos(u);
233 for (
int k = 2; k <= n+1; ++k) {
240 for (
int k = 2; k <=
n; ++k) {
245 f = 0.5*(a0-a2)+b0*
sin(u);
259 static const double pi = 3.14159265358979323846;
265 }
else if (x <=
fT1) {
268 double cof = 2*
cos(u);
272 for (
int k = 2; k <= n+1; ++k) {
279 for (
int k = 2; k <=
n; ++k) {
284 f = 0.5*(a0-a2)+b0*
sin(u);
299 static const double pi = 3.14159265358979323846;
305 }
else if (x <=
fT1) {
308 double cof = 2*
cos(u);
312 for (
int k = 2; k <= n+1; ++k) {
319 for (
int k = 2; k <=
n; ++k) {
324 f = -0.5*(a0-a2)+b0*
sin(u);
338 if (z < 0 || z > 1)
return std::numeric_limits<double>::signaling_NaN();
351 while (z >
fQuant[i]) ++i;
377 if (x <
fT0) x = 0.5*(
fT0+x-dx);
378 else if (x >
fT1) x = 0.5*(
fT1+x-dx);
390 if (z < 0 || z > 1)
return std::numeric_limits<double>::signaling_NaN();
405 while (z1 >
fQuant[i]) ++i;
435 double y1 = -
Pdf (x);
439 if (x <
fT0) x = 0.5*(
fT0+x-dx);
440 else if (x >
fT1) x = 0.5*(
fT1+x-dx);
464 return vavilov->
Pdf (x);
469 return vavilov->
Cdf_c (x);
474 return vavilov->
Cdf (x);
508 double xa, xb, fa, fb,
r;
529 bool recalcF12 =
true;
530 bool recalcFab =
true;
534 double x1=0,
x2=0,
f1=0,
f2=0, fx=0, ee=0;
568 if(u2 == 0 || u4 == 0)
continue;
574 double cb = (x1+
x2)*u2-(x2+x0)*u1;
575 double cc = (x1-x0)*
f1-x1*(ca*x1+cb);
577 if(cb == 0)
continue;
583 x0 = -u3 + (x0+u3 >= 0 ? +1 : -1)*
std::sqrt(u4);
585 if(x0 < xa || x0 > xb)
continue;
601 fx = (this->*
f) (x0);
617 if (fx*ff <= 0)
break;
635 std::cerr <<
"VavilovAccurate::Rzero: fail=" << fail <<
", f(" << a <<
")=" << (this->*
f) (a)
636 <<
", f(" << b <<
")=" << (this->*
f) (b) << std::endl;
646 static const double eu = 0.577215664901532860606;
649 return (x-0.25*x)*x-
eu;
678 if (x>-0.223172) x = -0.223172;
683 double p0 =
Pdf (x - eps);
685 double p2 =
Pdf (x + eps);
686 double y1 = 0.5*(p2-p0)/eps;
687 double y2 = (p2-2*p1+p0)/(eps*eps);
690 if (
fabs(dx) < eps) eps = 0.1*
fabs(dx);
691 }
while (
fabs(dx) > 1
E-5);
double cosint(double x)
Calculates the real part of the cosine integral (Ci).
double G116f1(double x) const
Namespace for new ROOT classes and functions.
void InitQuantile() const
double sinint(double x)
Calculates the sine integral.
double Cdf_c(double x) const
Evaluate the Vavilov complementary cummulative probability density function.
int Rzero(double a, double b, double &x0, double eps, int mxf, double(VavilovAccurate::*f)(double) const) const
double fA_cdf[MAXTERMS+1]
double vavilov_accurate_cdf_c(double x, double kappa, double beta2)
The Vavilov complementary cummulative probability density function.
static const double x2[5]
virtual void SetKappaBeta2(double kappa, double beta2)
Change and and recalculate coefficients if necessary.
double G116f2(double x) const
static double p2(double t, double a, double b, double c)
double fQuant[kNquantMax]
static Vc_ALWAYS_INLINE Vector< T > abs(const Vector< T > &x)
double GetEpsilonPM() const
Return the current value of .
double fB_cdf[MAXTERMS+1]
double Pdf(double x) const
Evaluate the Vavilov probability density function.
double Cdf(double x) const
Evaluate the Vavilov cummulative probability density function.
virtual double GetLambdaMax() const
Return the maximum value of for which is nonzero in the current approximation.
double expint(double x)
Calculates the exponential integral.
void Set(double kappa, double beta2, double epsilonPM=5E-4, double epsilon=1E-5)
(Re)Initialize the object
virtual double GetLambdaMin() const
Return the minimum value of for which is nonzero in the current approximation.
static VavilovAccurate * GetInstance()
Returns a static instance of class VavilovFast.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
static VavilovAccurate * fgInstance
double fA_pdf[MAXTERMS+1]
double Quantile_c(double z) const
Evaluate the inverse of the complementary Vavilov cummulative probability density function...
static double p1(double t, double a, double b)
VavilovAccurate(double kappa=1, double beta2=1, double epsilonPM=5E-4, double epsilon=1E-5)
Initialize an object to calculate the Vavilov distribution.
static const double x1[5]
double vavilov_accurate_pdf(double x, double kappa, double beta2)
The Vavilov probability density function.
Class describing a Vavilov distribution.
double Quantile(double z) const
Evaluate the inverse of the Vavilov cummulative probability density function.
virtual double GetBeta2() const
Return the current value of .
Namespace for new Math classes and functions.
virtual double Mode() const
Return the value of where the pdf is maximal.
static double E1plLog(double x)
double landau_quantile(double z, double xi=1)
Inverse ( ) of the cumulative distribution function of the lower tail of the Landau distribution (lan...
double GetNTerms() const
Return the number of terms used in the series expansion.
double f2(const double *x)
double fLambda[kNquantMax]
virtual ~VavilovAccurate()
Destructor.
virtual double GetKappa() const
Return the current value of .
double GetEpsilon() const
Return the current value of .
double fB_pdf[MAXTERMS+1]
double vavilov_accurate_quantile_c(double z, double kappa, double beta2)
The inverse of the complementary Vavilov cummulative probability density function.
double vavilov_accurate_quantile(double z, double kappa, double beta2)
The inverse of the Vavilov cummulative probability density function.
double vavilov_accurate_cdf(double x, double kappa, double beta2)
The Vavilov cummulative probability density function.
static const double x3[11]