Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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"
38
39#include <cmath>
40
41namespace ROOT {
42namespace Math {
43
44static const double eu = 0.577215664901532860606; // Euler's constant
45
47{
48}
49
51{
52 // desctructor (clean up resources)
53}
54
55
56double Vavilov::Mode() const {
57 double x = -4.22784335098467134e-01-std::log(GetKappa())-GetBeta2();
58 if (x>-0.223172) x = -0.223172;
59 double eps = 0.01;
60 double dx;
61
62 do {
63 double p0 = Pdf (x - eps);
64 double p1 = Pdf (x);
65 double p2 = Pdf (x + eps);
66 double y1 = 0.5*(p2-p0)/eps;
67 double y2 = (p2-2*p1+p0)/(eps*eps);
68 dx = - y1/y2;
69 x += dx;
70 if (fabs(dx) < eps) eps = 0.1*fabs(dx);
71 } while (fabs(dx) > 1E-5);
72 return x;
73}
74
75double Vavilov::Mode(double kappa, double beta2) {
76 SetKappaBeta2 (kappa, beta2);
77 return Mode();
78}
79
80double Vavilov::Mean() const {
81 return Mean (GetKappa(), GetBeta2());
82}
83
84double Vavilov::Mean(double kappa, double beta2) {
85 return eu-1-std::log(kappa)-beta2;
86}
87
88double Vavilov::Variance() const {
89 return Variance (GetKappa(), GetBeta2());
90}
91
92double Vavilov::Variance(double kappa, double beta2) {
93 return (1-0.5*beta2)/kappa;
94}
95
96double Vavilov::Skewness() const {
97 return Skewness (GetKappa(), GetBeta2());
98}
99
100double Vavilov::Skewness(double kappa, double beta2) {
101 return (0.5-beta2/3)/(kappa*kappa) * std::pow ((1-0.5*beta2)/kappa, -1.5);
102}
103
104
105double Vavilov::Kurtosis() const {
106 return Kurtosis (GetKappa(), GetBeta2());
107}
108
109double Vavilov::Kurtosis(double kappa, double beta2) {
110 return (1./3-0.25*beta2)*pow (1-0.5*beta2, -2)/kappa;
111}
112
113
114} // namespace Math
115} // namespace ROOT
virtual double Pdf(double x) const =0
Evaluate the Vavilov probability density function.
virtual ~Vavilov()
Destructor.
Definition Vavilov.cxx:50
virtual double GetKappa() const =0
Return the current value of .
virtual double Variance() const
Return the theoretical variance .
Definition Vavilov.cxx:88
virtual double GetBeta2() const =0
Return the current value of .
virtual void SetKappaBeta2(double kappa, double beta2)=0
Change and and recalculate coefficients if necessary.
virtual double Mode() const
Return the value of where the pdf is maximal.
Definition Vavilov.cxx:56
virtual double Mean() const
Return the theoretical mean , where is Euler's constant.
Definition Vavilov.cxx:80
virtual double Skewness() const
Return the theoretical skewness .
Definition Vavilov.cxx:96
virtual double Kurtosis() const
Return the theoretical kurtosis .
Definition Vavilov.cxx:105
Vavilov()
Default constructor.
Definition Vavilov.cxx:46
Double_t x[n]
Definition legend1.C:17
Namespace for new Math classes and functions.
static const double eu
Definition Vavilov.cxx:44
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...