1 #ifndef STAN_MATH_PRIM_SCAL_FUN_BINOMIAL_COEFFICIENT_LOG_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_BINOMIAL_COEFFICIENT_LOG_HPP
4 #include <boost/math/special_functions/gamma.hpp>
5 #include <boost/math/tools/promotion.hpp>
61 template <
typename T_N,
typename T_n>
62 inline typename boost::math::tools::promote_args<T_N, T_n>::type
67 const double cutoff = 1000;
68 if ((N < cutoff) || (N - n < cutoff)) {
71 return n *
log(N - n) + (N + 0.5) *
log(N/(N-n))
72 + 1/(12*N) - n - 1/(12*(N-n)) -
lgamma(n + 1.0);
fvar< T > binomial_coefficient_log(const fvar< T > &x1, const fvar< T > &x2)
fvar< T > lgamma(const fvar< T > &x)
fvar< T > log(const fvar< T > &x)