1#ifndef STAN_MATH_PRIM_FUN_CHOOSE_HPP
2#define STAN_MATH_PRIM_FUN_CHOOSE_HPP
7#include <boost/math/special_functions/binomial.hpp>
35 const double choices = boost::math::binomial_coefficient<double>(n, k);
37 std::numeric_limits<int>::max());
38 return static_cast<int>(std::round(choices));
51template <
typename T1,
typename T2, require_any_container_t<T1, T2>* =
nullptr>
54 [](
auto&& c,
auto&& d) {
55 return choose(std::forward<
decltype(c)>(c),
56 std::forward<
decltype(d)>(d));
58 std::forward<T1>(a), std::forward<T2>(b));
void check_less_or_equal(const char *function, const char *name, const T_y &y, const T_high &high, Idxs... idxs)
Throw an exception if y is not less than high.
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
auto apply_scalar_binary(F &&f, T1 &&x, T2 &&y)
Base template function for vectorization of binary scalar functions defined by applying a functor to ...
int choose(int n, int k)
Return the binomial coefficient for the specified integer arguments.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...