[R] choose(n, k) as n approaches k

Wright, Erik Scott ESWRIGHT @end|ng |rom p|tt@edu
Tue Jan 14 00:33:57 CET 2020


This struck me as incorrect:

> choose(3.999999, 4)
[1] 0.9999979
> choose(3.9999999, 4)
[1] 0
> choose(4, 4)
[1] 1
> choose(4.0000001, 4)
[1] 4
> choose(4.000001, 4)
[1] 1.000002

Should base::choose(n, k) check whether n is within machine precision of k and return 1?

Thanks,
Erik

***
sessionInfo()
R version 3.6.0 beta (2019-04-15 r76395)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

	[[alternative HTML version deleted]]



More information about the R-help mailing list