search for: sample_int

Displaying 2 results from an estimated 2 matches for "sample_int".

2018 Sep 21
1
Bias in R's random integers?
...onvenience, but I have tried to keep the C++ low. Interesting results: The results for "simple" sampling are the same. > set.seed(42) > sample.int(6, 10, replace = TRUE) [1] 6 6 2 5 4 4 5 1 4 5 > sample.int(100, 10) [1] 46 72 92 25 45 90 98 11 44 51 > set.seed(42) > sample_int(6, 10, replace = TRUE) [1] 6 6 2 5 4 4 5 1 4 5 > sample_int(100, 10) [1] 46 72 92 25 45 90 98 11 44 51 But there is no bias with the alternative method: > m <- ceiling((2/5)*2^32) > set.seed(42) > x <- sample.int(m, 1000000, replace = TRUE) > table(x %% 2) 0...
2018 Sep 20
5
Bias in R's random integers?
On 9/20/18 1:43 AM, Carl Boettiger wrote: > For a well-tested C algorithm, based on my reading of Lemire, the unbiased > "algorithm 3" in https://arxiv.org/abs/1805.10941 is part already of the C > standard library in OpenBSD and macOS (as arc4random_uniform), and in the > GNU standard library. Lemire also provides C++ code in the appendix of his > piece for both this and