00001 // @(#)root/mathmore:$Id: Vavilov.h 34123 2010-06-25 08:21:13Z moneta $ 00002 // Authors: B. List 29.4.2010 00003 00004 /********************************************************************** 00005 * * 00006 * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT * 00007 * * 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU General Public License * 00010 * as published by the Free Software Foundation; either version 2 * 00011 * of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this library (see file COPYING); if not, write * 00020 * to the Free Software Foundation, Inc., 59 Temple Place, Suite * 00021 * 330, Boston, MA 02111-1307 USA, or contact the author. * 00022 * * 00023 **********************************************************************/ 00024 00025 // Header file for class Vavilov 00026 // 00027 // Created by: blist at Thu Apr 29 11:19:00 2010 00028 // 00029 // Last update: Thu Apr 29 11:19:00 2010 00030 // 00031 #ifndef ROOT_Math_Vavilov 00032 #define ROOT_Math_Vavilov 00033 00034 00035 00036 /** 00037 @ingroup StatFunc 00038 */ 00039 00040 00041 #include <iostream> 00042 00043 namespace ROOT { 00044 namespace Math { 00045 00046 //____________________________________________________________________________ 00047 /** 00048 Base class describing a Vavilov distribution 00049 00050 The Vavilov distribution is defined in 00051 P.V. Vavilov: Ionization losses of high-energy heavy particles, 00052 Sov. Phys. JETP 5 (1957) 749 [Zh. Eksp. Teor. Fiz. 32 (1957) 920]. 00053 00054 The probability density function of the Vavilov distribution 00055 as function of Landau's parameter is given by: 00056 \f[ p(\lambda_L; \kappa, \beta^2) = 00057 \frac{1}{2 \pi i}\int_{c-i\infty}^{c+i\infty} \phi(s) e^{\lambda_L s} ds\f] 00058 where \f$\phi(s) = e^{C} e^{\psi(s)}\f$ 00059 with \f$ C = \kappa (1+\beta^2 \gamma )\f$ 00060 and \f$\psi(s)= s \ln \kappa + (s+\beta^2 \kappa) 00061 \cdot \left ( \int \limits_{0}^{1} 00062 \frac{1 - e^{\frac{-st}{\kappa}}}{t} \,d t- \gamma \right ) 00063 - \kappa \, e^{\frac{-s}{\kappa}}\f$. 00064 \f$ \gamma = 0.5772156649\dots\f$ is Euler's constant. 00065 00066 For the class Vavilov, 00067 Pdf returns the Vavilov distribution as function of Landau's parameter 00068 \f$\lambda_L = \lambda_V/\kappa - \ln \kappa\f$, 00069 which is the convention used in the CERNLIB routines, and in the tables 00070 by S.M. Seltzer and M.J. Berger: Energy loss stragglin of protons and mesons: 00071 Tabulation of the Vavilov distribution, pp 187-203 00072 in: National Research Council (U.S.), Committee on Nuclear Science: 00073 Studies in penetration of charged particles in matter, 00074 Nat. Akad. Sci. Publication 1133, 00075 Nucl. Sci. Series Report No. 39, 00076 Washington (Nat. Akad. Sci.) 1964, 388 pp. 00077 Available from 00078 <A HREF="http://books.google.de/books?id=kmMrAAAAYAAJ&lpg=PP9&pg=PA187#v=onepage&q&f=false">Google books</A> 00079 00080 Therefore, for small values of \f$\kappa < 0.01\f$, 00081 pdf approaches the Landau distribution. 00082 00083 For values \f$\kappa > 10\f$, the Gauss approximation should be used 00084 with \f$\mu\f$ and \f$\sigma\f$ given by Vavilov::Mean(kappa, beta2) 00085 and sqrt(Vavilov::Variance(kappa, beta2). 00086 00087 The original Vavilov pdf is obtained by 00088 v.Pdf(lambdaV/kappa-log(kappa))/kappa. 00089 00090 Two subclasses are provided: 00091 - VavilovFast uses the algorithm by 00092 A. Rotondi and P. Montagna, Fast calculation of Vavilov distribution, 00093 <A HREF="http://dx.doi.org/10.1016/0168-583X(90)90749-K">Nucl. Instr. and Meth. B47 (1990) 215-224</A>, 00094 which has been implemented in 00095 <A HREF="http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/g115/top.html"> 00096 CERNLIB (G115)</A>. 00097 00098 - VavilovAccurate uses the algorithm by 00099 B. Schorr, Programs for the Landau and the Vavilov distributions and the corresponding random numbers, 00100 <A HREF="http://dx.doi.org/10.1016/0010-4655(74)90091-5">Computer Phys. Comm. 7 (1974) 215-224</A>, 00101 which has been implemented in 00102 <A HREF="http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/g116/top.html"> 00103 CERNLIB (G116)</A>. 00104 00105 Both subclasses store coefficients needed to calculate \f$p(\lambda; \kappa, \beta^2)\f$ 00106 for fixed values of \f$\kappa\f$ and \f$\beta^2\f$. 00107 Changing these values is computationally expensive. 00108 00109 VavilovFast is about 5 times faster for the calculation of the Pdf than VavilovAccurate; 00110 initialization takes about 100 times longer than calculation of the Pdf value. 00111 For the quantile calculation, VavilovFast 00112 is 30 times faster for the initialization, and 6 times faster for 00113 subsequent calculations. Initialization for Quantile takes 00114 27 (11) times longer than subsequent calls for VavilovFast (VavilovAccurate). 00115 00116 @ingroup StatFunc 00117 00118 */ 00119 00120 00121 class Vavilov { 00122 00123 public: 00124 00125 00126 /** 00127 Default constructor 00128 */ 00129 Vavilov(); 00130 00131 /** 00132 Destructor 00133 */ 00134 virtual ~Vavilov(); 00135 00136 public: 00137 00138 /** 00139 Evaluate the Vavilov probability density function 00140 00141 @param x The Landau parameter \f$x = \lambda_L\f$ 00142 00143 */ 00144 virtual double Pdf (double x) const = 0; 00145 00146 /** 00147 Evaluate the Vavilov probability density function, 00148 and set kappa and beta2, if necessary 00149 00150 @param x The Landau parameter \f$x = \lambda_L\f$ 00151 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00152 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00153 */ 00154 virtual double Pdf (double x, double kappa, double beta2) = 0; 00155 00156 /** 00157 Evaluate the Vavilov cummulative probability density function 00158 00159 @param x The Landau parameter \f$x = \lambda_L\f$ 00160 */ 00161 virtual double Cdf (double x) const = 0; 00162 00163 /** 00164 Evaluate the Vavilov cummulative probability density function, 00165 and set kappa and beta2, if necessary 00166 00167 @param x The Landau parameter \f$x = \lambda_L\f$ 00168 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00169 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00170 */ 00171 virtual double Cdf (double x, double kappa, double beta2) = 0; 00172 00173 /** 00174 Evaluate the Vavilov complementary cummulative probability density function 00175 00176 @param x The Landau parameter \f$x = \lambda_L\f$ 00177 */ 00178 virtual double Cdf_c (double x) const = 0; 00179 00180 /** 00181 Evaluate the Vavilov complementary cummulative probability density function, 00182 and set kappa and beta2, if necessary 00183 00184 @param x The Landau parameter \f$x = \lambda_L\f$ 00185 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00186 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00187 */ 00188 virtual double Cdf_c (double x, double kappa, double beta2) = 0; 00189 00190 /** 00191 Evaluate the inverse of the Vavilov cummulative probability density function 00192 00193 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 00194 */ 00195 virtual double Quantile (double z) const = 0; 00196 00197 /** 00198 Evaluate the inverse of the Vavilov cummulative probability density function, 00199 and set kappa and beta2, if necessary 00200 00201 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 00202 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00203 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00204 */ 00205 virtual double Quantile (double z, double kappa, double beta2) = 0; 00206 00207 /** 00208 Evaluate the inverse of the complementary Vavilov cummulative probability density function 00209 00210 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 00211 */ 00212 virtual double Quantile_c (double z) const = 0; 00213 00214 /** 00215 Evaluate the inverse of the complementary Vavilov cummulative probability density function, 00216 and set kappa and beta2, if necessary 00217 00218 @param z The argument \f$z\f$, which must be in the range \f$0 \le z \le 1\f$ 00219 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00220 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00221 */ 00222 virtual double Quantile_c (double z, double kappa, double beta2) = 0; 00223 00224 /** 00225 Change \f$\kappa\f$ and \f$\beta^2\f$ and recalculate coefficients if necessary 00226 00227 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00228 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00229 */ 00230 virtual void SetKappaBeta2 (double kappa, double beta2) = 0; 00231 00232 /** 00233 Return the minimum value of \f$\lambda\f$ for which \f$p(\lambda; \kappa, \beta^2)\f$ 00234 is nonzero in the current approximation 00235 */ 00236 virtual double GetLambdaMin() const = 0; 00237 00238 /** 00239 Return the maximum value of \f$\lambda\f$ for which \f$p(\lambda; \kappa, \beta^2)\f$ 00240 is nonzero in the current approximation 00241 */ 00242 virtual double GetLambdaMax() const = 0; 00243 00244 /** 00245 Return the current value of \f$\kappa\f$ 00246 */ 00247 virtual double GetKappa() const = 0; 00248 00249 /** 00250 Return the current value of \f$\beta^2\f$ 00251 */ 00252 virtual double GetBeta2() const = 0; 00253 00254 /** 00255 Return the value of \f$\lambda\f$ where the pdf is maximal 00256 */ 00257 virtual double Mode() const; 00258 00259 /** 00260 Return the value of \f$\lambda\f$ where the pdf is maximal function, 00261 and set kappa and beta2, if necessary 00262 00263 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00264 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00265 */ 00266 virtual double Mode(double kappa, double beta2); 00267 00268 /** 00269 Return the theoretical mean \f$\mu = \gamma-1- \ln \kappa - \beta^2\f$, 00270 where \f$\gamma = 0.5772\dots\f$ is Euler's constant 00271 */ 00272 virtual double Mean() const; 00273 00274 /** 00275 Return the theoretical variance \f$\sigma^2 = \frac{1 - \beta^2/2}{\kappa}\f$ 00276 */ 00277 virtual double Variance() const; 00278 00279 /** 00280 Return the theoretical skewness 00281 \f$\gamma_1 = \frac{1/2 - \beta^2/3}{\kappa^2 \sigma^3} \f$ 00282 */ 00283 virtual double Skewness() const; 00284 00285 /** 00286 Return the theoretical kurtosis 00287 \f$\gamma_2 = \frac{1/3 - \beta^2/4}{\kappa^3 \sigma^4}\f$ 00288 */ 00289 virtual double Kurtosis() const; 00290 00291 /** 00292 Return the theoretical Mean \f$\mu = \gamma-1- \ln \kappa - \beta^2\f$ 00293 00294 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00295 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00296 */ 00297 static double Mean(double kappa, double beta2); 00298 00299 /** 00300 Return the theoretical Variance \f$\sigma^2 = \frac{1 - \beta^2/2}{\kappa}\f$ 00301 00302 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00303 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00304 */ 00305 static double Variance(double kappa, double beta2); 00306 00307 /** 00308 Return the theoretical skewness 00309 \f$\gamma_1 = \frac{1/2 - \beta^2/3}{\kappa^2 \sigma^3} \f$ 00310 00311 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00312 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00313 */ 00314 static double Skewness(double kappa, double beta2); 00315 00316 /** 00317 Return the theoretical kurtosis 00318 \f$\gamma_2 = \frac{1/3 - \beta^2/4}{\kappa^3 \sigma^4}\f$ 00319 00320 @param kappa The parameter \f$\kappa\f$, which should be in the range \f$0.01 \le \kappa \le 10 \f$ 00321 @param beta2 The parameter \f$\beta^2\f$, which must be in the range \f$0 \le \beta^2 \le 1 \f$ 00322 */ 00323 static double Kurtosis(double kappa, double beta2); 00324 00325 00326 }; 00327 00328 } // namespace Math 00329 } // namespace ROOT 00330 00331 #endif /* ROOT_Math_Vavilov */