[Rd] choose(n,k) when n is almost integer

Petr Savicky savicky at cs.cas.cz
Tue Feb 2 13:37:46 CET 2010


I would like to add some more information concerning the patch C
to the function choose() proposed in the email
  https://stat.ethz.ch/pipermail/r-devel/2009-December/056177.html

The patch uses transformations of choose(n, k), which are described in
  http://www.cs.cas.cz/~savicky/R-devel/formulas_choose.pdf

The accuracy of the modified function choose(n, k) may be verified
on randomly generated examples using Rmpfr package
  http://cran.at.r-project.org/web/packages/Rmpfr/index.html
and the script
  http://www.cs.cas.cz/~savicky/R-devel/test_choose_2.R

The output, which i obtained, is 

  > source("test_choose_2.R")
  k <= 9  max rel err = 9.41734e-16 
  k <= 19  max rel err = 2.084412e-15 
  k <= 29  max rel err = 3.170754e-15 
  k <= 39  max rel err = 4.99284e-14 
  k <= 49  max rel err = 5.927749e-14 
  k <= 59  max rel err = 6.526895e-14 
  k <= 69  max rel err = 6.526895e-14 
  k <= 79  max rel err = 8.783232e-14 
  k <= 89  max rel err = 1.051950e-13 
  k <= 99  max rel err = 1.051950e-13 
  k <= 109  max rel err = 1.072878e-13 
  k <= 119  max rel err = 1.072878e-13 
  k <= 129  max rel err = 1.179829e-13 
  k <= 139  max rel err = 1.247080e-13 
  k <= 149  max rel err = 1.247080e-13 
  k <= 159  max rel err = 1.255064e-13 
  k <= 169  max rel err = 1.255064e-13 
  k <= 179  max rel err = 1.267402e-13 
  k <= 189  max rel err = 1.311689e-13 
  k <= 199  max rel err = 1.573155e-13 
  k <= 209  max rel err = 1.844756e-13 

Patch C also passes make check-all in the current development
version 2.11.0 (2010-02-01).

I appreciate comments.

Petr Savicky.



More information about the R-devel mailing list