rdunif unexpected output #211
Closed
Labels
Comments
Closed
Passing a vector doesn't work in general because |
Ah I missed that! You don't need my suggestion, but I then I suppose this would work rdunif2 <- function(n, b, a = 1) {
if(a == b) return(rep(a, n))
vec <- a:b
sample(vec, n, replace = TRUE)
} Can make a pull req if you want. Apologies if I'm distracting you from the important stuff. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When
rdunif
has an upper boundb
less than the lower bounda
, it outputsb
n
times.A solution is to pass a vector of integers into
sample
I've benchmarked them and
rdunif2
is slightly slower.But maybe acceptably so?
The text was updated successfully, but these errors were encountered: