Vavilov.cxx

Go to the documentation of this file.
00001 // @(#)root/mathmore:$Id: Vavilov.cxx 34123 2010-06-25 08:21:13Z moneta $
00002 // Authors: B. List 29.4.2010
00003  
00004 
00005  /**********************************************************************
00006   *                                                                    *
00007   * Copyright (c) 2004 ROOT Foundation,  CERN/PH-SFT                   *
00008   *                                                                    *
00009   * This library is free software; you can redistribute it and/or      *
00010   * modify it under the terms of the GNU General Public License        *
00011   * as published by the Free Software Foundation; either version 2     *
00012   * of the License, or (at your option) any later version.             *
00013   *                                                                    *
00014   * This library is distributed in the hope that it will be useful,    *
00015   * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00016   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00017   * General Public License for more details.                           *
00018   *                                                                    *
00019   * You should have received a copy of the GNU General Public License  *
00020   * along with this library (see file COPYING); if not, write          *
00021   * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
00022   * 330, Boston, MA 02111-1307 USA, or contact the author.             *
00023   *                                                                    *
00024   **********************************************************************/
00025 
00026 // Implementation file for class Vavilov
00027 // 
00028 // Created by: blist  at Thu Apr 29 11:19:00 2010
00029 // 
00030 // Last update: Thu Apr 29 11:19:00 2010
00031 // 
00032 
00033 
00034 #include "Math/Vavilov.h"
00035 #include "Math/VavilovAccurate.h"
00036 #include "Math/SpecFuncMathCore.h"
00037 #include "Math/SpecFuncMathMore.h"
00038 
00039 #include <cassert>
00040 #include <iostream>
00041 #include <cmath>
00042 #include <iomanip>
00043 #include <cmath>
00044 #include <cstdlib>
00045 #include <string>
00046 #include <sstream>
00047 
00048 
00049 namespace ROOT {
00050 namespace Math {
00051 
00052 static const double eu = 0.577215664901532860606;      // Euler's constant
00053 
00054 Vavilov::Vavilov()
00055 {
00056 }
00057 
00058 Vavilov::~Vavilov() 
00059 {
00060    // desctructor (clean up resources)
00061 }
00062 
00063 
00064 double Vavilov::Mode() const {
00065    double x = -4.22784335098467134e-01-std::log(GetKappa())-GetBeta2();
00066    if (x>-0.223172) x = -0.223172;
00067    double eps = 0.01;
00068    double dx;
00069   
00070    do {
00071       double p0 = Pdf (x - eps);
00072       double p1 = Pdf (x);
00073       double p2 = Pdf (x + eps);
00074       double y1 = 0.5*(p2-p0)/eps;
00075       double y2 = (p2-2*p1+p0)/(eps*eps);
00076       dx = - y1/y2;
00077       x += dx;
00078       if (fabs(dx) < eps) eps = 0.1*fabs(dx);
00079    } while (fabs(dx) > 1E-5);
00080    return x;
00081 }
00082 
00083 double Vavilov::Mode(double kappa, double beta2) {
00084    SetKappaBeta2 (kappa, beta2);
00085    return Mode();
00086 }
00087 
00088 double Vavilov::Mean() const {
00089    return Mean (GetKappa(), GetBeta2());
00090 }
00091  
00092 double Vavilov::Mean(double kappa, double beta2) {
00093    return eu-1-std::log(kappa)-beta2;
00094 }
00095 
00096 double Vavilov::Variance() const {
00097    return Variance (GetKappa(), GetBeta2());
00098 }
00099  
00100 double Vavilov::Variance(double kappa, double beta2) {
00101    return (1-0.5*beta2)/kappa;
00102 }
00103 
00104 double Vavilov::Skewness() const {
00105    return Skewness (GetKappa(), GetBeta2());
00106 }
00107  
00108 double Vavilov::Skewness(double kappa, double beta2) {
00109    return (0.5-beta2/3)/(kappa*kappa) * std::pow ((1-0.5*beta2)/kappa, -1.5);
00110 }
00111 
00112 
00113 double Vavilov::Kurtosis() const {
00114    return Kurtosis (GetKappa(), GetBeta2());
00115 }
00116  
00117 double Vavilov::Kurtosis(double kappa, double beta2) {
00118    return (1./3-0.25*beta2)*pow (1-0.5*beta2, -2)/kappa;
00119 }
00120 
00121 
00122 } // namespace Math
00123 } // namespace ROOT

Generated on Tue Jul 5 14:34:57 2011 for ROOT_528-00b_version by  doxygen 1.5.1