BayesianAnalysisToolkit  0.9.3
BCMath.h
Go to the documentation of this file.
1 #ifndef __BCMATH__H
2 #define __BCMATH__H
3 
17 /*
18  * Copyright (C) 2007-2013, the BAT core developer team
19  * All rights reserved.
20  *
21  * For the licensing terms see doc/COPYING.
22  * For documentation see http://mpp.mpg.de/bat
23  */
24 
25 // ---------------------------------------------------------
26 
27 #define BCMATH_NFACT_ALIMIT 20
28 
29 // ---------------------------------------------------------
30 #include <stdexcept>
31 #include <vector>
32 
33 class TH1D;
34 
35 namespace BCMath
36 {
37 
44  double LogGaus(double x, double mean = 0, double sigma = 1, bool norm = false);
45 
49  double LogPoisson(double x, double par);
50 
56  double ApproxBinomial(int n, int k, double p);
57 
64  double LogApproxBinomial(int n, int k, double p);
65 
73  double LogBinomFactor(int n, int k);
74 
82  double ApproxLogFact(double x);
83 
87  double LogNoverK(int n, int k);
88 
92  double LogFact(int n);
93 
97  int Nint(double x);
98 
103  double LogBreitWignerNonRel(double x, double mean, double Gamma, bool norm = false);
104  double LogBreitWignerRel(double x, double mean, double Gamma);
105 
110  double LogChi2(double x, int n);
111 
125  double LogVoigtian(double x, double sigma, double gamma);
126 
130  double LogGammaPDF(double x, double alpha, double beta);
131 
135  double LogLogNormal(double x, double mean = 0, double sigma = 1);
136 
141  void RandomChi2(std::vector<double> &randoms, int K);
142 
152  TH1D* ECDF(const std::vector<double>& data);
153 
161  std::vector<int> longestRuns(const std::vector<bool>& bitStream);
162 
173  std::vector<double> longestRunsChi2(const std::vector<double>& yMeasured,
174  const std::vector<double>& yExpected, const std::vector<double>& sigma);
175 
188  double longestRunFrequency(unsigned int longestObserved, unsigned int nTrials);
189 
198  double SplitGaussian(double* x, double* par);
199 
202  void CacheFactorial(unsigned int n);
203 
217  double Rvalue(const std::vector<double> & chain_means, const std::vector<double> & chain_variances,
218  const unsigned & chain_length, const bool & strict = true) throw (std::invalid_argument, std::domain_error);
219 
231  double CorrectPValue(const double & pvalue, const unsigned & npar, const unsigned & nobservations) throw (std::domain_error);
232 
243  double FastPValue(const std::vector<unsigned> & observed, const std::vector<double> & expected,
244  unsigned nIterations = 1e5, unsigned seed = 0) throw (std::invalid_argument);
245 
247 }
248 
249 // ---------------------------------------------------------
250 
251 #endif
252