CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

BetaDistribution.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: 
00003 
00004 #include "CLHEP/GenericFunctions/BetaDistribution.hh"
00005 #include <assert.h>
00006 #include <cmath>
00007 using namespace std;
00008 
00009 namespace Genfun {
00010 FUNCTION_OBJECT_IMP(BetaDistribution)
00011 
00012 
00013 BetaDistribution::BetaDistribution():
00014   _alpha("a",    1.0, 0.0, 100),
00015   _beta ("beta", 1.0, 0.0, 100)
00016 {}
00017 
00018 BetaDistribution::BetaDistribution(const BetaDistribution & right):
00019 _alpha(right._alpha),
00020 _beta (right._beta) 
00021 {
00022 }
00023 
00024 BetaDistribution::~BetaDistribution() {
00025 }
00026 
00027 double BetaDistribution::operator() (double x) const {
00028   double a = _alpha.getValue(),b=_beta.getValue();
00029   return pow(x,a-1)*pow((1-x),b-1)*
00030     exp(_logGamma(a+b)-_logGamma(a)-_logGamma(b));
00031   
00032 }
00033 
00034 Parameter & BetaDistribution::alpha() {
00035   return _alpha;
00036 }
00037 
00038 
00039 Parameter & BetaDistribution::beta() {
00040   return _beta;
00041 }
00042 
00043 
00044 
00045 } // namespace Genfun