> Martin Maechler
> on Thu, 20 Sep 2018 09:20:46 +0200 writes:
> Wolfgang Huber
> on Thu, 20 Sep 2018 08:47:47 +0200 writes:
>> FWIW, I suspect this is related to the function
>> R_unif_index that was introduced in src/main/RNG.c around
>> revision 72356, or
Yup, that is a bug, at least in the documentation. Probably a clearer example
is
x <- seq(2.001, 2.999, length.out=999)
threes <- sapply(x, function(y) table(sample(y, 1, replace=TRUE))[3])
plot(threes, type="l")
curve(1*(x-2)/x, add=TRUE, col="red")
which is entirely consistent with wh
To be more clear: I do NOT state that the function "round" is used. I read
the documentation as "non integer positive numerical values will be
replaced by the next smallest integer", the important part being the NEXT
smallest integer, i.e. how ceiling() does it. So that's exactly what I
would expec
But do we handle it as an error in what sample does, or how the documentation
is?
I think what is done now would be best described as "ceilinged", i.e. what
ceiling() does. But is there an English word to describe this?
Or just use "converted to the next smallest integer"?
But then again, what h
Although it seems to be pretty weird to enter a numeric vector of length one
that is not an integer as the first argument to sample(), the results do not
seem to match what is documented in the manual. In addition, the results below
do not support the use of round rather than truncate in the doc
: [Rd] A different error in sample()
Good day,
The use of "rounding" also doesn't make sense. If The number is halfway between
two integers, it is rounded to the nearest even integer.
> round(2.5)
[1] 2
--
Dario Strbenac
University of Syd
> Wolfgang Huber
> on Thu, 20 Sep 2018 08:47:47 +0200 writes:
> FWIW, I suspect this is related to the function
> R_unif_index that was introduced in src/main/RNG.c around
> revision 72356, or the way this function is used in
> do_sample in src/main/random.c.
Yes, it
FWIW, I suspect this is related to the function R_unif_index that was
introduced in src/main/RNG.c around revision 72356, or the way this
function is used in do_sample in src/main/random.c.
20.9.18 08:19, Wolfgang Huber scripsit:
Besides wording of the documentation re truncating vs rounding, t
Besides wording of the documentation re truncating vs rounding, there
is something peculiar going on with the fractional part of n:
> table(sample.int(2.5, 1e6, replace = TRUE))
1 2 3
399051 401035 199914
> table(sample.int(3, 1e6, replace = TRUE))
1 2 3
332956 3
Good day,
The use of "rounding" also doesn't make sense. If The number is halfway between
two integers, it is rounded to the nearest even integer.
> round(2.5)
[1] 2
--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
I believe the word "truncated" is causing the confusion. 3 is "the next
smallest integer" following 2.5. But it is not the truncation done by
trunc(). Rewording to "rounding the next smallest integer" would get rid of
that confusion imho.
Cheers
Joris
On Wed, Sep 19, 2018 at 7:57 PM Duncan Murdoc
This may be a doc error or a coding bug.
The help page for sample says:
"Non-integer positive numerical values of n or x will be truncated to
the next smallest integer, which has to be no larger than
.Machine$integer.max."
This is not true:
> table(sample(2.5, 100, replace = TRUE))
12 matches
Mail list logo