From savicky at cs.cas.cz  Tue Feb  2 13:37:46 2010
From: savicky at cs.cas.cz (Petr Savicky)
Date: Tue, 2 Feb 2010 13:37:46 +0100
Subject: [Rd] choose(n,k) when n is almost integer
In-Reply-To: <20091223224223.GA3057@cs.cas.cz>
References: <19239.19864.396771.484772@lynne.math.ethz.ch>
	<20091215095243.GA14388@cs.cas.cz>
	<19239.38154.219034.206322@lynne.math.ethz.ch>
	<19242.15337.267242.128687@lynne.math.ethz.ch>
	<20091217231449.GA23480@cs.cas.cz>
	<19245.16249.290239.986122@cmath-6.math.ethz.ch>
	<20091222215843.GA9120@cs.cas.cz> <20091223224223.GA3057@cs.cas.cz>
Message-ID: <20100202123746.GA27184@cs.cas.cz>

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.



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