[Rd] RFC: lchoose() vs lfactorial() etc

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Tue, 15 Dec 2009 09:49:28 +0100


lgamma(x) and lfactorial(x) are defined to return

 ln|Gamma(x)| {= log(abs(gamma(x)))} or ln|Gamma(x+1)| respectively.

Unfortunately, we haven't chosen the analogous definition for lchoose().

So, currently

> lchoose(1/2, 1:10)

   [1] -0.6931472 -2.0794415        NaN -3.2425924        NaN -3.8869494
   [7]        NaN -4.3357508        NaN -4.6805913
  Warning message:
  In lchoose(n, k) : NaNs produced
>

which (the NaN's) is not particularly useful. (I have use case where I really have to workaround those NaNs.)

I herebey propose to *amend* the definition of lchoose() such that it behaves analogously to lgamma() and lfactorial(), i.e., to return

   log(abs(choose(.,.))

Your comments are welcome.
Martin Maechler, ETH Zurich



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 15 Dec 2009 - 08:52:40 GMT

This archive was generated by hypermail 2.2.0 : Tue 15 Dec 2009 - 10:21:34 GMT