BCMath.h

Go to the documentation of this file.
00001 #ifndef __BCMATH__H
00002 #define __BCMATH__H
00003 
00016 /*
00017  * Copyright (C) 2008, Daniel Kollar and Kevin Kroeninger.
00018  * All rights reserved.
00019  *
00020  * For the licensing terms see doc/COPYING.
00021  */
00022 
00023 // ---------------------------------------------------------
00024 
00025 #define BCMATH_NFACT_ALIMIT 20
00026 
00027 // ---------------------------------------------------------
00028 //#include <cstring>
00029 #include <vector>
00030 
00031 namespace BCMath
00032 {
00033 
00040    double LogGaus(double x, double mean = 0, double sigma = 1, bool norm = false);
00041 
00045    double LogPoisson(double x, double par);
00046 
00052    double ApproxBinomial(int n, int k, double p);
00053 
00060    double LogApproxBinomial(int n, int k, double p);
00061 
00069    double LogBinomFactor(int n, int k);
00070 
00078    double ApproxLogFact(double x);
00079 
00083    double LogNoverK(int n, int k);
00084 
00088    double LogFact(int n);
00089 
00093    inline int Max(int x, int y)
00094       { return x >= y ? x : y; }
00095 
00096    inline double Max(double x, double y)
00097       { return x >= y ? x : y; }
00098 
00102    inline int Min(int x, int y)
00103       { return x <= y ? x : y; }
00104 
00105    inline double Min(double x, double y)
00106    { return x <= y ? x : y; }
00107 
00111    int Nint(double x);
00112 
00116    double rms(int n, const double * a);
00117 
00122    double LogBreitWignerNonRel(double x, double mean, double Gamma, bool norm = false);
00123    double LogBreitWignerRel(double x, double mean, double Gamma);
00124 
00129    double LogChi2(double x, int n);
00130 
00144    double LogVoigtian(double x, double sigma, double gamma);
00145 
00150    void RandomChi2(std::vector<double> &randoms, int K);
00151 
00152 // /**
00153 //  * Fill vector with N random numbers distributed according to
00154 //  * exponential distribution with rate lambda
00155 //  * P(x|lambda)=lambda exp(-lambda*x)
00156 //  * @param randoms will be filled with random exponentials
00157 //  * @param lambda the rate of the exp. distribution
00158 //  */
00159 // void RandomExponential(std::vector<double> &randoms, double lambda, unsigned int seed=0);
00160 
00161 }
00162 
00163 // ---------------------------------------------------------
00164 
00165 #endif
00166 

Generated on Thu Feb 11 11:29:30 2010 for BayesianAnalysisToolkit by  doxygen 1.5.1