
G'day Ralf. Quoting "Ralf M." <rm@amitrader.com>:
the binomial coefficients are usually used with integers, but it is also possible to get the binomial coefficient of real values (cf. http://en.wikipedia.org/wiki/Binomial_coefficient ).
Maybe this could be added to the boost math library. Here's a sample implementation using standard g++:
template <class T> T Choose(T n, T k) { return exp(lgamma(n + 1.0) - lgamma(k + 1.0) - lgamma(n - k + 1.0)); }
Boost.Math almost has it: #include <boost/math/special_functions/beta.hpp> template<typename RealType> RealType binomial(RealType n, RealType k) { return 1.0 / ((n+1) * boost::math::beta(n - k + 1, k + 1)); } There is also binomial_distribution and beta_distribution if that's what you're really after. Cheers, Andrew Bromage