Logo ROOT   6.08/07
Reference Guide
Vavilov.cxx
Go to the documentation of this file.
1 // @(#)root/mathmore:$Id$
2 // Authors: B. List 29.4.2010
3 
4 
5  /**********************************************************************
6  * *
7  * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT *
8  * *
9  * This library is free software; you can redistribute it and/or *
10  * modify it under the terms of the GNU General Public License *
11  * as published by the Free Software Foundation; either version 2 *
12  * of the License, or (at your option) any later version. *
13  * *
14  * This library is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
17  * General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this library (see file COPYING); if not, write *
21  * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
22  * 330, Boston, MA 02111-1307 USA, or contact the author. *
23  * *
24  **********************************************************************/
25 
26 // Implementation file for class Vavilov
27 //
28 // Created by: blist at Thu Apr 29 11:19:00 2010
29 //
30 // Last update: Thu Apr 29 11:19:00 2010
31 //
32 
33 
34 #include "Math/Vavilov.h"
35 #include "Math/VavilovAccurate.h"
36 #include "Math/SpecFuncMathCore.h"
37 #include "Math/SpecFuncMathMore.h"
38 
39 #include <cassert>
40 #include <iostream>
41 #include <cmath>
42 #include <iomanip>
43 #include <cmath>
44 #include <cstdlib>
45 #include <string>
46 #include <sstream>
47 
48 
49 namespace ROOT {
50 namespace Math {
51 
52 static const double eu = 0.577215664901532860606; // Euler's constant
53 
55 {
56 }
57 
59 {
60  // desctructor (clean up resources)
61 }
62 
63 
64 double Vavilov::Mode() const {
65  double x = -4.22784335098467134e-01-std::log(GetKappa())-GetBeta2();
66  if (x>-0.223172) x = -0.223172;
67  double eps = 0.01;
68  double dx;
69 
70  do {
71  double p0 = Pdf (x - eps);
72  double p1 = Pdf (x);
73  double p2 = Pdf (x + eps);
74  double y1 = 0.5*(p2-p0)/eps;
75  double y2 = (p2-2*p1+p0)/(eps*eps);
76  dx = - y1/y2;
77  x += dx;
78  if (fabs(dx) < eps) eps = 0.1*fabs(dx);
79  } while (fabs(dx) > 1E-5);
80  return x;
81 }
82 
83 double Vavilov::Mode(double kappa, double beta2) {
84  SetKappaBeta2 (kappa, beta2);
85  return Mode();
86 }
87 
88 double Vavilov::Mean() const {
89  return Mean (GetKappa(), GetBeta2());
90 }
91 
92 double Vavilov::Mean(double kappa, double beta2) {
93  return eu-1-std::log(kappa)-beta2;
94 }
95 
96 double Vavilov::Variance() const {
97  return Variance (GetKappa(), GetBeta2());
98 }
99 
100 double Vavilov::Variance(double kappa, double beta2) {
101  return (1-0.5*beta2)/kappa;
102 }
103 
104 double Vavilov::Skewness() const {
105  return Skewness (GetKappa(), GetBeta2());
106 }
107 
108 double Vavilov::Skewness(double kappa, double beta2) {
109  return (0.5-beta2/3)/(kappa*kappa) * std::pow ((1-0.5*beta2)/kappa, -1.5);
110 }
111 
112 
113 double Vavilov::Kurtosis() const {
114  return Kurtosis (GetKappa(), GetBeta2());
115 }
116 
117 double Vavilov::Kurtosis(double kappa, double beta2) {
118  return (1./3-0.25*beta2)*pow (1-0.5*beta2, -2)/kappa;
119 }
120 
121 
122 } // namespace Math
123 } // namespace ROOT
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
virtual double Variance() const
Return the theoretical variance .
Definition: Vavilov.cxx:96
virtual double Pdf(double x) const =0
Evaluate the Vavilov probability density function.
Double_t x[n]
Definition: legend1.C:17
Vavilov()
Default constructor.
Definition: Vavilov.cxx:54
static double p2(double t, double a, double b, double c)
double pow(double, double)
virtual double Kurtosis() const
Return the theoretical kurtosis .
Definition: Vavilov.cxx:113
virtual ~Vavilov()
Destructor.
Definition: Vavilov.cxx:58
virtual double Skewness() const
Return the theoretical skewness .
Definition: Vavilov.cxx:104
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Double_t E()
Definition: TMath.h:54
virtual double Mode() const
Return the value of where the pdf is maximal.
Definition: Vavilov.cxx:64
virtual double GetBeta2() const =0
Return the current value of .
static double p1(double t, double a, double b)
static const double eu
Definition: Vavilov.cxx:52
Namespace for new Math classes and functions.
virtual void SetKappaBeta2(double kappa, double beta2)=0
Change and and recalculate coefficients if necessary.
virtual double GetKappa() const =0
Return the current value of .
double log(double)
virtual double Mean() const
Return the theoretical mean , where is Euler&#39;s constant.
Definition: Vavilov.cxx:88