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> 59 template <
typename T_N,
typename T_n>
60 inline typename boost::math::tools::promote_args<T_N, T_n>::type
64 const double CUTOFF = 1000;
69 typename boost::math::tools::promote_args<T_N, T_n>::type N_minus_n
71 double one_twelfth = 1.0 / 12;
72 return n *
log(N_minus_n)
73 + (N + 0.5) *
log(N / N_minus_n)
76 - one_twelfth / N_minus_n
fvar< T > binomial_coefficient_log(const fvar< T > &x1, const fvar< T > &x2)
fvar< T > lgamma(const fvar< T > &x)
Return the natural logarithm of the gamma function applied to the specified argument.
fvar< T > log(const fvar< T > &x)