search for: r_unif_index

Displaying 20 results from an estimated 22 matches for "r_unif_index".

2019 Mar 22
1
Status of R_unif_index
Dear List, section "6.3 Random number generation" of WRE [1] lists unif_rand(), norm_rand() and exp_rand() as the interface to R's RNG. Now R_ext/Random.h also has double R_unif_index(double); Can this be also treated as an official API function that may be called from a package? Thanks Ralf [1] https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Random-numbers -- Ralf Stubner Senior Software Engineer / Trainer daqana GmbH Dortustra?e 48 14467 Potsdam T: +49 331...
2019 Feb 19
2
bias issue in sample() (PR 17494)
...<- sample(m, 1000000, replace = TRUE) table(x %% 2, x > m / 2) ## ## FALSE TRUE ## 0 300620 198792 ## 1 200196 300392 table(sample(2/7 * 2^32, 1000000, replace = TRUE) %% 2) ## ## 0 1 ## 429054 570946 I committed a modification to R_unif_index to address this by generating random bits (blocks of 16) and rejection sampling, but for now this is only enabled if the environment variable R_NEW_SAMPLE is set before the first call. Some things still needed: - someone to look over the change and see if there are any issues - adjustment of RNGk...
2019 Feb 26
2
bias issue in sample() (PR 17494)
...## FALSE TRUE >> ## 0 300620 198792 >> ## 1 200196 300392 >> >> table(sample(2/7 * 2^32, 1000000, replace = TRUE) %% 2) >> ## >> ## 0 1 >> ## 429054 570946 >> >> I committed a modification to R_unif_index to address this by >> generating random bits (blocks of 16) and rejection sampling, but for >> now this is only enabled if the environment variable R_NEW_SAMPLE is >> set before the first call. >> >> Some things still needed: >> >> - someone to look over th...
2018 Sep 20
2
A different error in sample()
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, there is > something peculiar going on with the fracti...
2019 Feb 26
1
bias issue in sample() (PR 17494)
...gt; ????? ## 1 200196 300392 >>>> >>>> ????? table(sample(2/7 * 2^32, 1000000, replace = TRUE) %% 2) >>>> ????? ## >>>> ????? ##????? 0????? 1 >>>> ????? ## 429054 570946 >>>> >>>> I committed a modification to R_unif_index to address this by >>>> generating random bits (blocks of 16) and rejection sampling, but for >>>> now this is only enabled if the environment variable R_NEW_SAMPLE is >>>> set before the first call. >>>> >>>> Some things still needed: &gt...
2019 Feb 20
0
bias issue in sample() (PR 17494)
...x %% 2, x > m / 2) > ## > ## FALSE TRUE > ## 0 300620 198792 > ## 1 200196 300392 > > table(sample(2/7 * 2^32, 1000000, replace = TRUE) %% 2) > ## > ## 0 1 > ## 429054 570946 > > I committed a modification to R_unif_index to address this by > generating random bits (blocks of 16) and rejection sampling, but for > now this is only enabled if the environment variable R_NEW_SAMPLE is > set before the first call. > > Some things still needed: > > - someone to look over the change and see if there ar...
2019 Feb 26
0
bias issue in sample() (PR 17494)
...???? ## 0 300620 198792 >>> ????? ## 1 200196 300392 >>> >>> ????? table(sample(2/7 * 2^32, 1000000, replace = TRUE) %% 2) >>> ????? ## >>> ????? ##????? 0????? 1 >>> ????? ## 429054 570946 >>> >>> I committed a modification to R_unif_index to address this by >>> generating random bits (blocks of 16) and rejection sampling, but for >>> now this is only enabled if the environment variable R_NEW_SAMPLE is >>> set before the first call. >>> >>> Some things still needed: >>> >>&g...
2018 Sep 19
3
A different error in sample()
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 documentation. Consider the code below. The first sentence in the details section says: "If x has
2018 Sep 19
2
Bias in R's random integers?
No, the 2nd call only happens when m > 2**31. Here's the code: (RNG.c, lines 793ff) double R_unif_index(double dn) { double cut = INT_MAX; switch(RNG_kind) { case KNUTH_TAOCP: case USER_UNIF: case KNUTH_TAOCP2: cut = 33554431.0; /* 2^25 - 1 */ break; default: break; } double u = dn > cut ? ru() : unif_rand(); return floor(dn * u); } On Wed, Sep 19, 2018 at...
2018 Sep 20
0
A different error in sample()
>>>>> 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 is just the use of 'dn' instead of 'n' - a one letter thinko I'd say. But *no*, it's much older than revision 72356; e...
2018 Sep 20
3
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 Sydney Camperdown NSW 2050 Australia
2018 Sep 19
4
Bias in R's random integers?
...#39;m still not convinced that there has ever been a simulation run with > detectable bias compared to Monte Carlo error unless it (like this one) > was designed specifically to show the problem. > > Duncan Murdoch > > > > > (RNG.c, lines 793ff) > > > > double R_unif_index(double dn) > > { > > double cut = INT_MAX; > > > > switch(RNG_kind) { > > case KNUTH_TAOCP: > > case USER_UNIF: > > case KNUTH_TAOCP2: > > cut = 33554431.0; /* 2^25 - 1 */ > > break; > > default: > > bre...
2018 Sep 19
0
Bias in R's random integers?
...he first person to have done this.) I'm still not convinced that there has ever been a simulation run with detectable bias compared to Monte Carlo error unless it (like this one) was designed specifically to show the problem. Duncan Murdoch > > (RNG.c, lines 793ff) > > double R_unif_index(double dn) > { > ? ? double cut = INT_MAX; > > ? ? switch(RNG_kind) { > ? ? case KNUTH_TAOCP: > ? ? case USER_UNIF: > ? ? case KNUTH_TAOCP2: > cut = 33554431.0; /* 2^25 - 1 */ > break; > ? ? default: > break; > ? ?} > > ? ? double u = dn > cut...
2018 Sep 19
2
Bias in R's random integers?
...detectable bias compared to Monte Carlo error unless it (like this > one) > > was designed specifically to show the problem. > > > > Duncan Murdoch > > > > > > > > (RNG.c, lines 793ff) > > > > > > double R_unif_index(double dn) > > > { > > > double cut = INT_MAX; > > > > > > switch(RNG_kind) { > > > case KNUTH_TAOCP: > > > case USER_UNIF: > > > case KNUTH_TAOCP2: > > > cut = 3...
2018 Sep 19
2
Bias in R's random integers?
...> ??? detectable bias compared to Monte Carlo error unless it (like this >> one) >> ??? was designed specifically to show the problem. >> >> ??? Duncan Murdoch >> >> ???? > >> ???? > (RNG.c, lines 793ff) >> ???? > >> ???? > double R_unif_index(double dn) >> ???? > { >> ???? >? ? ? double cut = INT_MAX; >> ???? > >> ???? >? ? ? switch(RNG_kind) { >> ???? >? ? ? case KNUTH_TAOCP: >> ???? >? ? ? case USER_UNIF: >> ???? >? ? ? case KNUTH_TAOCP2: >> ???? > cut = 33554431....
2018 Sep 19
0
Bias in R's random integers?
...re has ever been a simulation run with > detectable bias compared to Monte Carlo error unless it (like this one) > was designed specifically to show the problem. > > Duncan Murdoch > > > > > (RNG.c, lines 793ff) > > > > double R_unif_index(double dn) > > { > >? ? ? double cut = INT_MAX; > > > >? ? ? switch(RNG_kind) { > >? ? ? case KNUTH_TAOCP: > >? ? ? case USER_UNIF: > >? ? ? case KNUTH_TAOCP2: > > cut = 33554431.0; /* 2^25 - 1 */ > >...
2018 Sep 19
0
Bias in R's random integers?
...rlo error unless it (like this > >> one) > >> was designed specifically to show the problem. > >> > >> Duncan Murdoch > >> > >> > > >> > (RNG.c, lines 793ff) > >> > > >> > double R_unif_index(double dn) > >> > { > >> > double cut = INT_MAX; > >> > > >> > switch(RNG_kind) { > >> > case KNUTH_TAOCP: > >> > case USER_UNIF: > >> > case KNUTH_TAOCP2:...
2018 Sep 19
0
Bias in R's random integers?
...error unless it (like > this one) > >? ? ?was designed specifically to show the problem. > > > >? ? ?Duncan Murdoch > > > >? ? ? > > >? ? ? > (RNG.c, lines 793ff) > >? ? ? > > >? ? ? > double R_unif_index(double dn) > >? ? ? > { > >? ? ? >? ? ? double cut = INT_MAX; > >? ? ? > > >? ? ? >? ? ? switch(RNG_kind) { > >? ? ? >? ? ? case KNUTH_TAOCP: > >? ? ? >? ? ? case USER_UNIF: > >? ? ? >? ? ? case KNUTH_...
2018 Sep 19
2
Bias in R's random integers?
The 53 bits only encode at most 2^{32} possible values, because the source of the float is the output of a 32-bit PRNG (the obsolete version of MT). 53 bits isn't the relevant number here. The selection ratios can get close to 2. Computer scientists don't do it the way R does, for a reason. Regards, Philip On Wed, Sep 19, 2018 at 9:05 AM Duncan Murdoch <murdoch.duncan at
2019 Apr 26
0
R 3.6.0 is released
...PROTECT_WITH_INDEX). Intended for use in parsers only. * NAMEDMAX has been raised to 7 to allow further protection of intermediate results from (usually ill-advised) assignments in arguments to BUILTIN functions. Properly written package code should not be affected. * R_unif_index is now considered to be part of the C API. * R_GetCurrentEnv() allows C code to retrieve the current environment. DEPRECATED AND DEFUNCT: * Argument compressed of untar() is deprecated - it is only used for external tar commands which increasingly for extraction auto-...