A library for working with phylogenetic and population genetic data.
v0.32.0
binomial.cpp File Reference
#include "genesis/utils/math/binomial.hpp"
#include "genesis/utils/math/common.hpp"
#include <array>
#include <cassert>
#include <iostream>
#include <limits>
#include <sstream>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::utils
 

Functions

void binomial_coefficient_check_n_k_ (size_t n, size_t k)
 Local helper function to check that n and k are valid for a binomial coefficient. More...
 
size_t binomial_coefficient_int (size_t n, size_t k)
 Compute the binomial coefficient, that is n choose k, for two integer numbers. More...
 
double log_binomial_coefficient (size_t n, size_t k)
 Compute the logarithm (base e) of the binomial coefficient, that is n choose k, for two integer numbers, for large numbers. More...
 
double log_binomial_distribution (size_t k, size_t n, double p)
 Compute the logarithm (base e) of the probability mass function for a binomial distribution. More...
 
double log_factorial (size_t n)
 Return the logarithm (base e) of the factorial of n, that is log(n!). More...
 
std::vector< double > log_factorial_lookup_generator_ ()
 Helper function to generate above lookup table. More...
 

Variables

static const std::array< double, 1024 > log_factorial_lookup_
 Log-factorial log(x!) lookup table for fast computation of binomial coefficients. See binomial_coefficient_approx() for usage, and see log_factorial_lookup_generator_() for the generator function. More...