[R] About 'choose' function

Martin Maechler maechler at stat.math.ethz.ch
Mon Nov 8 22:49:49 CET 2004


>>>>> "Ted" == Ted Harding <Ted.Harding at nessie.mcc.ac.uk>
>>>>>     on Mon, 08 Nov 2004 19:10:55 -0000 (GMT) writes:

    Ted> On 08-Nov-04 Duncan Murdoch wrote:
    >> On Mon, 08 Nov 2004 15:56:49 -0000 (GMT), (Ted Harding)
    >> <Ted.Harding at nessie.mcc.ac.uk> wrote :
    >> 
    >>> Further investigation indicates that there is an integer
    >>> truncation problem with 'choose':
    >>> 
    >>> > print(choose(60000000000,1),digits=20) [1]
    >>> 60001679906.00000 >
    >>> print(my.choose3(60000000000,1),digits=20) [1] 6e+10
    >>  Are you sure you're using the standard R choose()?  I
    >> get different results from you:
    >> 
    >>> print(choose(60000000000,1),digits=20)
    >> [1] 6e+10
    >> 
    >> What platform are you using?  I did this is Windows R
    >> 2.0.0, and get the same result in the beta of 2.0.1.

    Ted> Well, that's good to learn! As usual, I'm out of date,
    Ted> but this time it seems to matter:

    Ted>   R-1.8.0 on Linux

    Ted> (Yes, it was the standard R choose() from that
    Ted> version).

    Ted> Perhaps I'd better roll up my sleeves and finally
    Ted> upgrade (though I'm really waiting for the next release
    Ted> since the move to 2.0 seems to have needed a few things
    Ted> ironed out).

well, yes, but there are so many (mostly small) things that we
have ironed out in R since version 1.8.0....

The "NEWS" of 1.9.0 and 1.9.1 are already in file "ONEWS" (=
"Old News") and do contain

>>     BUG FIXES
>>
>>      .....
>> 
>>      o   [l]choose() use a more accurate formula which also slightly
>>          improves p- and qhyper(); choose(n, k) now returns 0 instead
>>          of NaN for k < 0 or > n.


    Ted> Thanks for the cross-check, Duncan.  
indeed!

Martin




More information about the R-help mailing list