From maechler at stat.math.ethz.ch  Tue Dec 15 09:49:28 2009
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue, 15 Dec 2009 09:49:28 +0100
Subject: [Rd] RFC: lchoose() vs lfactorial() etc
Message-ID: <19239.19864.396771.484772@lynne.math.ethz.ch>

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



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