About 'choose' function
On 08-Nov-04 Ted Harding wrote:
[...]
> choose(60000000000,31)
[1] 1.612899e+300
[...]
my.choose3<-function(x,y){
if((x==y)||(y==0)) return(1);
m <- min(y,x-y)
prod(seq(x,(x-m+1),by=-1)/(seq(m,1,by=-1)))
}
when
my.choose3(60000000000,31)
[1] 1.613121e+300
which has a slight difference (0.014% greater) from the result of
'choose'.
Given the method of computation, I might feel inclined to trust
'my.choose3' rather than 'choose', but I'm not at sure of this
without studying the internal code of 'choose', and would welcome
comments!
I just did this calculation using 'bc' (which works to arbitrary decimal precision), getting (after rounding 59999999999.99...996, 1744 9's in all, to 60000000000): 16131211663389665874291103209859887097643782097733433535176164529013\ 93347758720756812586746724689691665340326913939172715147819303293449\ 54257506586926613288215108141984988883561331127046497391143349652601\ 81932350377398578090978006727056282867666693363201127636940304448887\ 82022049197129032260000000000 so the leading digits are 1613121..., agreeing with 'my.choose3' as above, rather than with 'choose'! Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 08-Nov-04 Time: 15:11:37 ------------------------------ XFMail ------------------------------