On 06/09/2012 2:09 PM, Shayne Hodge wrote:
Hello,

(Apologies for length, wanted to get all the relevant detail in that I know
of).

I've been having a lot of trouble with some code for an inventory analysis
problem I was doing, and finally came to the conclusion that it appears
that choose() is returning incorrect values. Specifically:

-------------

Browse[1]> nn
[1] 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3
Browse[1]> Q1
[1] 3
Browse[1]> choose(Q1,3)
[1] 0

That's easy to reproduce, with correct behaviour:

> Q1 <- 3 - 1e-10
> Q1
[1] 3
> choose(Q1, 3)
[1] 0

My guess is your code (which is tl;dr) computes Q1 with some rounding error, and you're seeing something like this.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to