[R] further to my last email

Prof Brian D Ripley ripley at stats.ox.ac.uk
Fri Dec 14 07:15:30 CET 2001

On Fri, 14 Dec 2001, Cowpertwait, Paul wrote:

> .. the round function seems to get round it (excuse the pun):
> > round(gamma(21)/(gamma(6)*gamma(16))) == round(choose(20,5))
> [1] TRUE
> So I presume the problem is related to gamma being a real function.
> However, I'm still not sure why there's a break from TRUE to FALSE for
> certain values.  Any comments would be appreciated!

It's rounding error:  == is *not* a sensible way to compare real numbers.
Use all.equal(), for example.

BTW, these numbers get large quite rapidly.  Use lgamma to do the
calculations on log scale is safer.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list