Displaying 7 results from an estimated 7 matches for "dqsample".
2018 Sep 20
5
Bias in R's random integers?
...it is of course possible. After reading about Lemire's work [1], I
had planned to integrate such an unbiased sampling scheme into the dqrng
package, which I have now started. [2]
Using Duncan's example, the results look much better:
> library(dqrng)
> m <- (2/5)*2^32
> y <- dqsample(m, 1000000, replace = TRUE)
> table(y %% 2)
0 1
500252 499748
Currently I am taking the other interpretation of "truncated":
> table(dqsample(2.5, 1000000, replace = TRUE))
0 1
499894 500106
I will adjust this to whatever is decided for base R.
However, th...
2018 Sep 20
0
Bias in R's random integers?
...ng about Lemire's work [1], I
> had planned to integrate such an unbiased sampling scheme into the dqrng
> package, which I have now started. [2]
>
> Using Duncan's example, the results look much better:
>
>> library(dqrng)
>> m <- (2/5)*2^32
>> y <- dqsample(m, 1000000, replace = TRUE)
>> table(y %% 2)
>
> 0 1
> 500252 499748
Another useful diagnostic is
plot(density(y[y %% 2 == 0]))
Obviously that should give a more or less uniform density, but for
values near m, the default sample() gives some nice pretty pictures of...
2018 Sep 20
4
Bias in R's random integers?
...], I
> > had planned to integrate such an unbiased sampling scheme into the dqrng
> > package, which I have now started. [2]
> >
> > Using Duncan's example, the results look much better:
> >> library(dqrng)
> >> m <- (2/5)*2^32
> >> y <- dqsample(m, 1000000, replace = TRUE)
> >> table(y %% 2)
> >>
> > 0 1
> >
> > 500252 499748
>
> Another useful diagnostic is
>
> plot(density(y[y %% 2 == 0]))
>
> Obviously that should give a more or less uniform density, but for
> v...
2018 Sep 21
0
Bias in R's random integers?
...an unbiased sampling scheme into the
> > > dqrng
> > > package, which I have now started. [2]
> > >
> > > Using Duncan's example, the results look much better:
> > >> library(dqrng)
> > >> m <- (2/5)*2^32
> > >> y <- dqsample(m, 1000000, replace = TRUE)
> > >> table(y %% 2)
> > >>
> > > 0 1
> > >
> > > 500252 499748
> >
> > Another useful diagnostic is
> >
> > plot(density(y[y %% 2 == 0]))
> >
> > Obviously that sho...
2018 Sep 21
1
Bias in R's random integers?
On 9/20/18 5:15 PM, Duncan Murdoch wrote:
> On 20/09/2018 6:59 AM, Ralf Stubner wrote:
>> It is difficult to do this in a package, since R does not provide access
>> to the random bits generated by the RNG. Only a float in (0,1) is
>> available via unif_rand().
>
> I believe it is safe to multiply the unif_rand() value by 2^32, and take
> the whole number part as an
2018 Sep 19
2
Bias in R's random integers?
A quick point of order here: arguing with Duncan in this forum is
helpful to expose ideas, but probably neither side will convince the
other; eventually, if you want this adopted in core R, you'll need to
convince an R-core member to pursue this fix.
In the meantime, a good, well-tested implementation in a
user-contributed package (presumably written in C for speed) would be
enormously
2018 Sep 21
3
Bias in R's random integers?
...ampling scheme into the
>>>> dqrng
>>>> package, which I have now started. [2]
>>>>
>>>> Using Duncan's example, the results look much better:
>>>>> library(dqrng)
>>>>> m <- (2/5)*2^32
>>>>> y <- dqsample(m, 1000000, replace = TRUE)
>>>>> table(y %% 2)
>>>>>
>>>> 0 1
>>>>
>>>> 500252 499748
>>>
>>> Another useful diagnostic is
>>>
>>> plot(density(y[y %% 2 == 0]))
>>>
>>...