Go to the documentation of this file.00001 #ifndef __BCMATH__H
00002 #define __BCMATH__H
00003
00024
00025
00026 #define BCMATH_NFACT_ALIMIT 20
00027
00028
00029 #include <stdexcept>
00030 #include <vector>
00031
00032 class TH1D;
00033
00034 namespace BCMath
00035 {
00036
00043 double LogGaus(double x, double mean = 0, double sigma = 1, bool norm = false);
00044
00048 double LogPoisson(double x, double par);
00049
00055 double ApproxBinomial(int n, int k, double p);
00056
00063 double LogApproxBinomial(int n, int k, double p);
00064
00072 double LogBinomFactor(int n, int k);
00073
00081 double ApproxLogFact(double x);
00082
00086 double LogNoverK(int n, int k);
00087
00091 double LogFact(int n);
00092
00096 inline int Max(int x, int y)
00097 { return x >= y ? x : y; }
00098
00099 inline int Max(unsigned int x, unsigned int y)
00100 { return x >= y ? x : y; }
00101
00102 inline double Max(double x, double y)
00103 { return x >= y ? x : y; }
00104
00105 inline double Max(float x, float y)
00106 { return x >= y ? x : y; }
00107
00111 inline int Min(int x, int y)
00112 { return x <= y ? x : y; }
00113
00114 inline int Min(unsigned int x, unsigned int y)
00115 { return x <= y ? x : y; }
00116
00117 inline double Min(double x, double y)
00118 { return x <= y ? x : y; }
00119
00120 inline double Min(float x, float y)
00121 { return x <= y ? x : y; }
00122
00126 int Nint(double x);
00127
00131 double rms(int n, const double * a);
00132
00137 double LogBreitWignerNonRel(double x, double mean, double Gamma, bool norm = false);
00138 double LogBreitWignerRel(double x, double mean, double Gamma);
00139
00144 double LogChi2(double x, int n);
00145
00159 double LogVoigtian(double x, double sigma, double gamma);
00160
00165 void RandomChi2(std::vector<double> &randoms, int K);
00166
00167
00177 TH1D* ECDF(const std::vector<double>& data);
00178
00186 std::vector<int> longestRuns(const std::vector<bool>& bitStream);
00187
00198 std::vector<double> longestRunsChi2(const std::vector<double>& yMeasured,
00199 const std::vector<double>& yExpected, const std::vector<double>& sigma);
00200
00213 double longestRunFrequency(unsigned int longestObserved, unsigned int nTrials);
00214
00215
00216 double SplitGaussian(double* x, double* par);
00217
00218
00221 void CacheFactorial(unsigned int n);
00222
00236 double Rvalue(const std::vector<double> & chain_means, const std::vector<double> & chain_variances,
00237 const unsigned & chain_length, const bool & strict = true) throw (std::invalid_argument, std::domain_error);
00238 }
00239
00240
00241
00242 #endif
00243