Debian Codegraph @

src/C++/Statistics/Binomial.cpp

raw
1 // Author: David Alexander
2
3 #include <ConsensusCore/Statistics/Binomial.hpp>
4
5 #include <boost/math/distributions/binomial.hpp>
6 #include <cmath>
7
8 using boost::math::binomial_distribution;
9 using boost::math::complement;
10 using boost::math::cdf;
11
12 namespace ConsensusCore {
13 double BinomialSurvival(int q, int size, double prob, bool asPhred)
14 {
15 binomial_distribution<double> dist(size, prob);
16 double tail = q < 0 ? 1 : cdf(complement(dist, q));
17 return asPhred ? -10. * log10(tail) : tail;
18 }
19 }