|
||||
File indexing completed on 2025-01-18 10:10:22
0001 // @(#)root/mathmore:$Id$ 0002 // Authors: B. List 29.4.2010 0003 0004 /********************************************************************** 0005 * * 0006 * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT * 0007 * * 0008 * This library is free software; you can redistribute it and/or * 0009 * modify it under the terms of the GNU General Public License * 0010 * as published by the Free Software Foundation; either version 2 * 0011 * of the License, or (at your option) any later version. * 0012 * * 0013 * This library is distributed in the hope that it will be useful, * 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0016 * General Public License for more details. * 0017 * * 0018 * You should have received a copy of the GNU General Public License * 0019 * along with this library (see file COPYING); if not, write * 0020 * to the Free Software Foundation, Inc., 59 Temple Place, Suite * 0021 * 330, Boston, MA 02111-1307 USA, or contact the author. * 0022 * * 0023 **********************************************************************/ 0024 0025 // Header file for class VavilovFast 0026 // 0027 // Created by: blist at Thu Apr 29 11:19:00 2010 0028 // 0029 // Last update: Thu Apr 29 11:19:00 2010 0030 // 0031 #ifndef ROOT_Math_VavilovFast 0032 #define ROOT_Math_VavilovFast 0033 0034 0035 /** 0036 @ingroup StatFunc 0037 */ 0038 0039 0040 #include "Math/Vavilov.h" 0041 0042 namespace ROOT { 0043 namespace Math { 0044 0045 //____________________________________________________________________________ 0046 /** 0047 Class describing a Vavilov distribution. 0048 0049 The probability density function of the Vavilov distribution 0050 as function of Landau's parameter is given by: 0051 \f[ p(\lambda_L; \kappa, \beta^2) = 0052 \frac{1}{2 \pi i}\int_{c-i\infty}^{c+i\infty} \phi(s) e^{\lambda_L s} ds\f] 0053 where \f$\phi(s) = e^{C} e^{\psi(s)}\f$ 0054 with \f$ C = \kappa (1+\beta^2 \gamma )\f$ 0055 and \f$\psi(s)= s \ln \kappa + (s+\beta^2 \kappa) 0056 \cdot \left ( \int \limits_{0}^{1} 0057 \frac{1 - e^{\frac{-st}{\kappa}}}{t} \,d t- \gamma \right ) 0058 - \kappa \, e^{\frac{-s}{\kappa}}\f$. 0059 \f$ \gamma = 0.5772156649\dots\f$ is Euler's constant. 0060 0061 For the class VavilovFast, 0062 Pdf returns the Vavilov distribution as function of Landau's parameter 0063 \f$\lambda_L = \lambda_V/\kappa - \ln \kappa\f$, 0064 which is the convention used in the CERNLIB routines, and in the tables 0065 by S.M. Seltzer and M.J. Berger: Energy loss stragglin of protons and mesons: 0066 Tabulation of the Vavilov distribution, pp 187-203 0067 in: National Research Council (U.S.), Committee on Nuclear Science: 0068 Studies in penetration of charged particles in matter, 0069 Nat. Akad. Sci. Publication 1133, 0070 Nucl. Sci. Series Report No. 39, 0071 Washington (Nat. Akad. Sci.) 1964, 388 pp. 0072 Available from 0073 <A HREF="http://books.google.de/books?id=kmMrAAAAYAAJ&lpg=PP9&pg=PA187#v=onepage&q&f=false">Google books</A> 0074 0075 Therefore, for small values of \f$\kappa < 0.01\f$, 0076 pdf approaches the Landau distribution. 0077 0078 For values \f$\kappa > 10\f$, the Gauss approximation should be used 0079 with \f$\mu\f$ and \f$\sigma\f$ given by Vavilov::mean(kappa, beta2) 0080 and sqrt(Vavilov::variance(kappa, beta2). 0081 0082 For values \f$\kappa > 10\f$, the Gauss approximation should be used 0083 with \f$\mu\f$ and \f$\sigma\f$ given by Vavilov::mean(kappa, beta2) 0084 and sqrt(Vavilov::variance(kappa, beta2). 0085 0086 The original Vavilov pdf is obtained by 0087 v.Pdf(lambdaV/kappa-log(kappa))/kappa. 0088 0089 For detailed description see 0090 A. Rotondi and P. Montagna, Fast calculation of Vavilov distribution, 0091 <A HREF="http://dx.doi.org/10.1016/0168-583X(90)90749-K">Nucl. Instr. and Meth. B47 (1990) 215-224</A>, 0092 which has been implemented in 0093 <A HREF="https://cern-tex.web.cern.ch/cern-tex/shortwrupsdir/g115/top.html"> 0094 CERNLIB (G115)</A>. 0095 0096 The class stores coefficients needed to calculate \f$p(\lambda; \kappa, \beta^2)\f$ 0097 for fixed values of \f$\kappa\f$ and \f$\beta^2\f$. 0098 Changing these values is computationally expensive. 0099 0100 The parameter \f$\kappa\f$ must be in the range \f$0.01 \le \kappa \le 12\f$. 0101 0102 The parameter \f$\beta^2\f$ must be in the range \f$0 \le \beta^2 \le 1\f$. 0103 0104 Average times on a Pentium Core2 Duo P8400 2.26GHz: 0105 - 9.9us per call to SetKappaBeta2 or constructor 0106 - 0.095us per call to Pdf, Cdf 0107 - 3.7us per first call to Quantile after SetKappaBeta2 or constructor 0108 - 0.137us per subsequent call to Quantile 0109 0110 Benno List, June 2010 0111 0112 @ingroup StatFunc 0113 */ 0114 0115 0116 class VavilovFast: public Vavilov { 0117 0118 public: 0119 0120 0121 /** 0122 Initialize an object to calculate the Vavilov distribution 0123 0124 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0125 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0126 */ 0127 0128 VavilovFast(double kappa=1, double beta2=1); 0129 0130 0131 /** 0132 Destructor 0133 */ 0134 ~VavilovFast() override; 0135 0136 0137 public: 0138 0139 /** 0140 Evaluate the Vavilov probability density function 0141 0142 @param x The Landau parameter \f$x = \lambda_L\f$ 0143 */ 0144 double Pdf (double x) const override; 0145 0146 /** 0147 Evaluate the Vavilov probability density function, 0148 and set kappa and beta2, if necessary 0149 0150 @param x The Landau parameter \f$x = \lambda_L\f$ 0151 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0152 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0153 */ 0154 double Pdf (double x, double kappa, double beta2) override; 0155 0156 /** 0157 Evaluate the Vavilov cumulative probability density function 0158 0159 @param x The Landau parameter \f$x = \lambda_L\f$ 0160 */ 0161 double Cdf (double x) const override; 0162 0163 /** 0164 Evaluate the Vavilov cumulative probability density function, 0165 and set kappa and beta2, if necessary 0166 0167 @param x The Landau parameter \f$x = \lambda_L\f$ 0168 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0169 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0170 */ 0171 double Cdf (double x, double kappa, double beta2) override; 0172 0173 /** 0174 Evaluate the Vavilov complementary cumulative probability density function 0175 0176 @param x The Landau parameter \f$x = \lambda_L\f$ 0177 */ 0178 double Cdf_c (double x) const override; 0179 0180 /** 0181 Evaluate the Vavilov complementary cumulative probability density function, 0182 and set kappa and beta2, if necessary 0183 0184 @param x The Landau parameter \f$x = \lambda_L\f$ 0185 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0186 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0187 */ 0188 double Cdf_c (double x, double kappa, double beta2) override; 0189 0190 /** 0191 Evaluate the inverse of the Vavilov cumulative probability density function 0192 0193 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 0194 */ 0195 double Quantile (double z) const override; 0196 0197 /** 0198 Evaluate the inverse of the Vavilov cumulative probability density function, 0199 and set kappa and beta2, if necessary 0200 0201 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 0202 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0203 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0204 */ 0205 double Quantile (double z, double kappa, double beta2) override; 0206 0207 /** 0208 Evaluate the inverse of the complementary Vavilov cumulative probability density function 0209 0210 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 0211 */ 0212 double Quantile_c (double z) const override; 0213 0214 /** 0215 Evaluate the inverse of the complementary Vavilov cumulative probability density function, 0216 and set kappa and beta2, if necessary 0217 0218 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 0219 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0220 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0221 */ 0222 double Quantile_c (double z, double kappa, double beta2) override; 0223 0224 /** 0225 Change \f$\kappa\f$ and \f$\beta^2\f$ and recalculate coefficients if necessary 0226 0227 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0228 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0229 */ 0230 void SetKappaBeta2 (double kappa, double beta2) override; 0231 0232 /** 0233 Return the minimum value of \f$\lambda\f$ for which \f$p(\lambda; \kappa, \beta^2)\f$ 0234 is nonzero in the current approximation 0235 */ 0236 double GetLambdaMin() const override; 0237 0238 /** 0239 Return the maximum value of \f$\lambda\f$ for which \f$p(\lambda; \kappa, \beta^2)\f$ 0240 is nonzero in the current approximation 0241 */ 0242 double GetLambdaMax() const override; 0243 0244 /** 0245 Return the current value of \f$\kappa\f$ 0246 */ 0247 double GetKappa() const override; 0248 0249 /** 0250 Return the current value of \f$\beta^2\f$ 0251 */ 0252 double GetBeta2() const override; 0253 0254 /** 0255 Returns a static instance of class VavilovFast 0256 */ 0257 static VavilovFast *GetInstance(); 0258 0259 /** 0260 Returns a static instance of class VavilovFast, 0261 and sets the values of kappa and beta2 0262 0263 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0264 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0265 */ 0266 static VavilovFast *GetInstance(double kappa, double beta2); 0267 0268 0269 private: 0270 double fKappa; 0271 double fBeta2; 0272 0273 double fAC[14]; 0274 double fHC[9]; 0275 double fWCM[201]; 0276 int fItype; 0277 int fNpt; 0278 0279 static VavilovFast *fgInstance; 0280 0281 }; 0282 0283 /** 0284 The Vavilov probability density function 0285 0286 @param x The Landau parameter \f$x = \lambda_L\f$ 0287 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0288 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0289 0290 @ingroup PdfFunc 0291 */ 0292 double vavilov_fast_pdf (double x, double kappa, double beta2); 0293 0294 /** 0295 The Vavilov cumulative probability density function 0296 0297 @param x The Landau parameter \f$x = \lambda_L\f$ 0298 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0299 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0300 0301 @ingroup ProbFunc 0302 */ 0303 double vavilov_fast_cdf (double x, double kappa, double beta2); 0304 0305 /** 0306 The Vavilov complementary cumulative probability density function 0307 0308 @param x The Landau parameter \f$x = \lambda_L\f$ 0309 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0310 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0311 0312 @ingroup ProbFunc 0313 */ 0314 double vavilov_fast_cdf_c (double x, double kappa, double beta2); 0315 0316 /** 0317 The inverse of the Vavilov cumulative probability density function 0318 0319 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 0320 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0321 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0322 0323 @ingroup QuantFunc 0324 */ 0325 double vavilov_fast_quantile (double z, double kappa, double beta2); 0326 0327 /** 0328 The inverse of the complementary Vavilov cumulative probability density function 0329 0330 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 0331 @param kappa The parameter \f$\kappa\f$, which must be in the range \f$0.01 \le \kappa \le 12 \f$ 0332 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 0333 0334 @ingroup QuantFunc 0335 */ 0336 double vavilov_fast_quantile_c (double z, double kappa, double beta2); 0337 0338 } // namespace Math 0339 } // namespace ROOT 0340 0341 #endif /* ROOT_Math_VavilovFast */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |