Logo ROOT   6.14/05
Reference Guide
PdfFuncMathCore.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Authors: Andras Zsenei & Lorenzo Moneta 06/2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 , LCG ROOT MathLib Team *
7  * *
8  * *
9  **********************************************************************/
10 
11 
12 
13 /**
14 
15 Probability density functions, cumulative distribution functions
16 and their inverses (quantiles) for various statistical distributions (continuous and discrete).
17 Whenever possible the conventions followed are those of the
18 CRC Concise Encyclopedia of Mathematics, Second Edition
19 (or <A HREF="http://mathworld.wolfram.com/">Mathworld</A>).
20 By convention the distributions are centered around 0, so for
21 example in the case of a Gaussian there is no parameter mu. The
22 user must calculate the shift themselves if they wish.
23 
24 MathCore provides the majority of the probability density functions, of the
25 cumulative distributions and of the quantiles (inverses of the cumulatives).
26 Additional distributions are also provided by the
27 <A HREF="../../MathMore/html/group__StatFunc.html">MathMore</A> library.
28 
29 
30 @defgroup StatFunc Statistical functions
31 
32 @ingroup MathCore
33 @ingroup MathMore
34 
35 */
36 
37 #ifndef ROOT_Math_PdfFuncMathCore
38 #define ROOT_Math_PdfFuncMathCore
39 
40 
41 namespace ROOT {
42 namespace Math {
43 
44 
45 
46  /** @defgroup PdfFunc Probability Density Functions (PDF)
47  * @ingroup StatFunc
48  * Probability density functions of various statistical distributions
49  * (continuous and discrete).
50  * The probability density function returns the probability that
51  * the variate has the value x.
52  * In statistics the PDF is also called the frequency function.
53  *
54  *
55  */
56 
57  /** @name Probability Density Functions from MathCore
58  * Additional PDF's are provided in the MathMore library
59  * (see PDF functions from MathMore)
60  */
61 
62  //@{
63 
64  /**
65 
66  Probability density function of the beta distribution.
67 
68  \f[ p(x) = \frac{\Gamma (a + b) } {\Gamma(a)\Gamma(b) } x ^{a-1} (1 - x)^{b-1} \f]
69 
70  for \f$0 \leq x \leq 1 \f$. For detailed description see
71  <A HREF="http://mathworld.wolfram.com/BetaDistribution.html">
72  Mathworld</A>.
73 
74  @ingroup PdfFunc
75 
76  */
77 
78  double beta_pdf(double x, double a, double b);
79 
80 
81  /**
82 
83  Probability density function of the binomial distribution.
84 
85  \f[ p(k) = \frac{n!}{k! (n-k)!} p^k (1-p)^{n-k} \f]
86 
87  for \f$ 0 \leq k \leq n \f$. For detailed description see
88  <A HREF="http://mathworld.wolfram.com/BinomialDistribution.html">
89  Mathworld</A>.
90 
91  @ingroup PdfFunc
92 
93  */
94 
95  double binomial_pdf(unsigned int k, double p, unsigned int n);
96 
97 
98  /**
99 
100  Probability density function of the negative binomial distribution.
101 
102  \f[ p(k) = \frac{(k+n-1)!}{k! (n-1)!} p^{n} (1-p)^{k} \f]
103 
104  For detailed description see
105  <A HREF="http://mathworld.wolfram.com/NegativeBinomialDistribution.html">
106  Mathworld</A> (where $k \to x$ and $n \to r$).
107  The distribution in <A HREF="http://en.wikipedia.org/wiki/Negative_binomial_distribution">
108  Wikipedia</A> is defined with a $p$ corresponding to $1-p$ in this case.
109 
110 
111  @ingroup PdfFunc
112 
113  */
114 
115  double negative_binomial_pdf(unsigned int k, double p, double n);
116 
117 
118 
119  /**
120 
121  Probability density function of Breit-Wigner distribution, which is similar, just
122  a different definition of the parameters, to the Cauchy distribution
123  (see #cauchy_pdf )
124 
125  \f[ p(x) = \frac{1}{\pi} \frac{\frac{1}{2} \Gamma}{x^2 + (\frac{1}{2} \Gamma)^2} \f]
126 
127 
128  @ingroup PdfFunc
129 
130  */
131 
132  double breitwigner_pdf(double x, double gamma, double x0 = 0);
133 
134 
135 
136 
137  /**
138 
139  Probability density function of the Cauchy distribution which is also
140  called Lorentzian distribution.
141 
142 
143  \f[ p(x) = \frac{1}{\pi} \frac{ b }{ (x-m)^2 + b^2} \f]
144 
145  For detailed description see
146  <A HREF="http://mathworld.wolfram.com/CauchyDistribution.html">
147  Mathworld</A>. It is also related to the #breitwigner_pdf which
148  will call the same implementation.
149 
150  @ingroup PdfFunc
151 
152  */
153 
154  double cauchy_pdf(double x, double b = 1, double x0 = 0);
155 
156 
157 
158 
159  /**
160 
161  Probability density function of the \f$\chi^2\f$ distribution with \f$r\f$
162  degrees of freedom.
163 
164  \f[ p_r(x) = \frac{1}{\Gamma(r/2) 2^{r/2}} x^{r/2-1} e^{-x/2} \f]
165 
166  for \f$x \geq 0\f$. For detailed description see
167  <A HREF="http://mathworld.wolfram.com/Chi-SquaredDistribution.html">
168  Mathworld</A>.
169 
170  @ingroup PdfFunc
171 
172  */
173 
174  double chisquared_pdf(double x, double r, double x0 = 0);
175 
176 
177  /**
178 
179  Crystal ball function
180 
181  See the definition at
182  <A HREF="http://en.wikipedia.org/wiki/Crystal_Ball_function">
183  Wikipedia</A>.
184 
185  It is not really a pdf since it is not normalized
186 
187  @ingroup PdfFunc
188 
189  */
190 
191  double crystalball_function(double x, double alpha, double n, double sigma, double x0 = 0);
192 
193  /**
194  pdf definition of the crystal_ball which is defined only for n > 1 otherwise integral is diverging
195  */
196  double crystalball_pdf(double x, double alpha, double n, double sigma, double x0 = 0);
197 
198  /**
199 
200  Probability density function of the exponential distribution.
201 
202  \f[ p(x) = \lambda e^{-\lambda x} \f]
203 
204  for x>0. For detailed description see
205  <A HREF="http://mathworld.wolfram.com/ExponentialDistribution.html">
206  Mathworld</A>.
207 
208 
209  @ingroup PdfFunc
210 
211  */
212 
213  double exponential_pdf(double x, double lambda, double x0 = 0);
214 
215 
216 
217 
218  /**
219 
220  Probability density function of the F-distribution.
221 
222  \f[ p_{n,m}(x) = \frac{\Gamma(\frac{n+m}{2})}{\Gamma(\frac{n}{2}) \Gamma(\frac{m}{2})} n^{n/2} m^{m/2} x^{n/2 -1} (m+nx)^{-(n+m)/2} \f]
223 
224  for x>=0. For detailed description see
225  <A HREF="http://mathworld.wolfram.com/F-Distribution.html">
226  Mathworld</A>.
227 
228  @ingroup PdfFunc
229 
230  */
231 
232 
233  double fdistribution_pdf(double x, double n, double m, double x0 = 0);
234 
235 
236 
237 
238  /**
239 
240  Probability density function of the gamma distribution.
241 
242  \f[ p(x) = {1 \over \Gamma(\alpha) \theta^{\alpha}} x^{\alpha-1} e^{-x/\theta} \f]
243 
244  for x>0. For detailed description see
245  <A HREF="http://mathworld.wolfram.com/GammaDistribution.html">
246  Mathworld</A>.
247 
248  @ingroup PdfFunc
249 
250  */
251 
252  double gamma_pdf(double x, double alpha, double theta, double x0 = 0);
253 
254 
255 
256 
257  /**
258 
259  Probability density function of the normal (Gaussian) distribution.
260 
261  \f[ p(x) = {1 \over \sqrt{2 \pi \sigma^2}} e^{-x^2 / 2\sigma^2} \f]
262 
263  For detailed description see
264  <A HREF="http://mathworld.wolfram.com/NormalDistribution.html">
265  Mathworld</A>. It can also be evaluated using #normal_pdf which will
266  call the same implementation.
267 
268  @ingroup PdfFunc
269 
270  */
271 
272  double gaussian_pdf(double x, double sigma = 1, double x0 = 0);
273 
274  /**
275 
276  Probability density function of the bi-dimensional (Gaussian) distribution.
277 
278  \f[ p(x) = {1 \over 2 \pi \sigma_x \sigma_y \sqrt{1-\rho^2}} \exp (-(x^2/\sigma_x^2 + y^2/\sigma_y^2 - 2 \rho x y/(\sigma_x\sigma_y))/2(1-\rho^2)) \f]
279 
280  For detailed description see
281  <A HREF="http://mathworld.wolfram.com/BivariateNormalDistribution.html">
282  Mathworld</A>. It can also be evaluated using #normal_pdf which will
283  call the same implementation.
284 
285  @param rho correlation , must be between -1,1
286 
287  @ingroup PdfFunc
288 
289  */
290 
291  double bigaussian_pdf(double x, double y, double sigmax = 1, double sigmay = 1, double rho = 0, double x0 = 0, double y0 = 0);
292 
293  /**
294 
295  Probability density function of the Landau distribution:
296  \f[ p(x) = \frac{1}{\xi} \phi (\lambda) \f]
297  with
298  \f[ \phi(\lambda) = \frac{1}{2 \pi i}\int_{c-i\infty}^{c+i\infty} e^{\lambda s + s \log{s}} ds\f]
299  where \f$\lambda = (x-x_0)/\xi\f$. For a detailed description see
300  K.S. K&ouml;lbig and B. Schorr, A program package for the Landau distribution,
301  <A HREF="http://dx.doi.org/10.1016/0010-4655(84)90085-7">Computer Phys. Comm. 31 (1984) 97-111</A>
302  <A HREF="http://dx.doi.org/10.1016/j.cpc.2008.03.002">[Erratum-ibid. 178 (2008) 972]</A>.
303  The same algorithms as in
304  <A HREF="https://cern-tex.web.cern.ch/cern-tex/shortwrupsdir/g110/top.html">
305  CERNLIB</A> (DENLAN) is used
306 
307  @param x The argument \f$x\f$
308  @param xi The width parameter \f$\xi\f$
309  @param x0 The location parameter \f$x_0\f$
310 
311  @ingroup PdfFunc
312 
313  */
314 
315  double landau_pdf(double x, double xi = 1, double x0 = 0);
316 
317 
318 
319  /**
320 
321  Probability density function of the lognormal distribution.
322 
323  \f[ p(x) = {1 \over x \sqrt{2 \pi s^2} } e^{-(\ln{x} - m)^2/2 s^2} \f]
324 
325  for x>0. For detailed description see
326  <A HREF="http://mathworld.wolfram.com/LogNormalDistribution.html">
327  Mathworld</A>.
328  @param s scale parameter (not the sigma of the distribution which is not even defined)
329  @param x0 location parameter, corresponds approximately to the most probable value. For x0 = 0, sigma = 1, the x_mpv = -0.22278
330 
331  @ingroup PdfFunc
332 
333  */
334 
335  double lognormal_pdf(double x, double m, double s, double x0 = 0);
336 
337 
338 
339 
340  /**
341 
342  Probability density function of the normal (Gaussian) distribution.
343 
344  \f[ p(x) = {1 \over \sqrt{2 \pi \sigma^2}} e^{-x^2 / 2\sigma^2} \f]
345 
346  For detailed description see
347  <A HREF="http://mathworld.wolfram.com/NormalDistribution.html">
348  Mathworld</A>. It can also be evaluated using #gaussian_pdf which will call the same
349  implementation.
350 
351  @ingroup PdfFunc
352 
353  */
354 
355  double normal_pdf(double x, double sigma =1, double x0 = 0);
356 
357 
358  /**
359 
360  Probability density function of the Poisson distribution.
361 
362  \f[ p(n) = \frac{\mu^n}{n!} e^{- \mu} \f]
363 
364  For detailed description see
365  <A HREF="http://mathworld.wolfram.com/PoissonDistribution.html">
366  Mathworld</A>.
367 
368  @ingroup PdfFunc
369 
370  */
371 
372  double poisson_pdf(unsigned int n, double mu);
373 
374 
375 
376 
377  /**
378 
379  Probability density function of Student's t-distribution.
380 
381  \f[ p_{r}(x) = \frac{\Gamma(\frac{r+1}{2})}{\sqrt{r \pi}\Gamma(\frac{r}{2})} \left( 1+\frac{x^2}{r}\right)^{-(r+1)/2} \f]
382 
383  for \f$k \geq 0\f$. For detailed description see
384  <A HREF="http://mathworld.wolfram.com/Studentst-Distribution.html">
385  Mathworld</A>.
386 
387  @ingroup PdfFunc
388 
389  */
390 
391  double tdistribution_pdf(double x, double r, double x0 = 0);
392 
393 
394 
395 
396  /**
397 
398  Probability density function of the uniform (flat) distribution.
399 
400  \f[ p(x) = {1 \over (b-a)} \f]
401 
402  if \f$a \leq x<b\f$ and 0 otherwise. For detailed description see
403  <A HREF="http://mathworld.wolfram.com/UniformDistribution.html">
404  Mathworld</A>.
405 
406  @ingroup PdfFunc
407 
408  */
409 
410  double uniform_pdf(double x, double a, double b, double x0 = 0);
411 
412 
413 
414 } // namespace Math
415 } // namespace ROOT
416 
417 
418 
419 #endif // ROOT_Math_PdfFunc
double lognormal_pdf(double x, double m, double s, double x0=0)
Probability density function of the lognormal distribution.
double tdistribution_pdf(double x, double r, double x0=0)
Probability density function of Student&#39;s t-distribution.
auto * m
Definition: textangle.C:8
double chisquared_pdf(double x, double r, double x0=0)
Probability density function of the distribution with degrees of freedom.
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
double beta_pdf(double x, double a, double b)
Probability density function of the beta distribution.
double bigaussian_pdf(double x, double y, double sigmax=1, double sigmay=1, double rho=0, double x0=0, double y0=0)
Probability density function of the bi-dimensional (Gaussian) distribution.
double exponential_pdf(double x, double lambda, double x0=0)
Probability density function of the exponential distribution.
double crystalball_function(double x, double alpha, double n, double sigma, double x0=0)
Crystal ball function.
double normal_pdf(double x, double sigma=1, double x0=0)
Probability density function of the normal (Gaussian) distribution.
Double_t x[n]
Definition: legend1.C:17
double landau_pdf(double x, double xi=1, double x0=0)
Probability density function of the Landau distribution: with where .
double gaussian_pdf(double x, double sigma=1, double x0=0)
Probability density function of the normal (Gaussian) distribution.
const Double_t sigma
double gamma_pdf(double x, double alpha, double theta, double x0=0)
Probability density function of the gamma distribution.
double breitwigner_pdf(double x, double gamma, double x0=0)
Probability density function of Breit-Wigner distribution, which is similar, just a different definit...
double negative_binomial_pdf(unsigned int k, double p, double n)
Probability density function of the negative binomial distribution.
double gamma(double x)
ROOT::R::TRInterface & r
Definition: Object.C:4
double binomial_pdf(unsigned int k, double p, unsigned int n)
Probability density function of the binomial distribution.
auto * a
Definition: textangle.C:12
double fdistribution_pdf(double x, double n, double m, double x0=0)
Probability density function of the F-distribution.
double cauchy_pdf(double x, double b=1, double x0=0)
Probability density function of the Cauchy distribution which is also called Lorentzian distribution...
Double_t y[n]
Definition: legend1.C:17
static constexpr double s
double poisson_pdf(unsigned int n, double mu)
Probability density function of the Poisson distribution.
Namespace for new Math classes and functions.
double uniform_pdf(double x, double a, double b, double x0=0)
Probability density function of the uniform (flat) distribution.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
double crystalball_pdf(double x, double alpha, double n, double sigma, double x0=0)
pdf definition of the crystal_ball which is defined only for n > 1 otherwise integral is diverging ...
const Int_t n
Definition: legend1.C:16