Displaying 20 results from an estimated 10000 matches similar to: "About function "unif_rand()""
2018 Sep 20
4
Bias in R's random integers?
Hello,
On Thursday, September 20, 2018 11:15:04 AM EDT Duncan Murdoch wrote:
> On 20/09/2018 6:59 AM, Ralf Stubner wrote:
> > 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
2002 Nov 24
1
unif_rand() and exp_rand()
Dear R-users:
Recently I found my simulation run into an apparently infinite loop.
After a few days of tracing and chasing, I believe it is caused by
the built-in unif_rand() and exp_rand() functions: unif_rand() can
produce a value of 0 which causes the following part of exp_rand()
running into an infinity loop
u = unif_rand();
for (;;) {
u += u;
if (u > 1.0)
break;
2002 Jan 24
2
random number generation issues with r and compiled C code
Dear People,
I have been writing a simulation routine that is currently entirely
written in c++. I've been using the R standalone math library to give me
random number generation for this. However, I have had to set the seed
myself, and I am using
set_seed(time(NULL), clock)
for every call to unif_rand().
However, this works really badly. The random numbers aren't uniform at
all. Does
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
2004 Mar 23
1
R equivilant to RAND_MAX in C
Hello,
I have some C code that I'm interfacing to R using the .C calling
interface. Currently the C code uses the rand() function from the GNU C
library to generate random numbers. Since I need the random numbers in a
range from 0 to a (where a is an integer) I use the RAND_MAX macro as
(int)(rand() * (float)(*nobs-1) / (RAND_MAX+1.0))
(taken from the rand() manpage)
However, since I have
2018 Sep 19
4
Bias in R's random integers?
Hi Duncan--
Nice simulation!
The absolute difference in probabilities is small, but the maximum relative
difference grows from something negligible to almost 2 as m approaches
2**31.
Because the L_1 distance between the uniform distribution on {1, ..., m}
and what you actually get is large, there have to be test functions whose
expectations are quite different under the two distributions.
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
2005 Jan 05
2
How to connect R with a C code which includes Atlas
Hello, everybody,
Happy New Year!
I am a graduate student from Concordia University. I meet a problem when I am
working on my thesis. I hope I will get help from you.
I have a mathematical model which was already implemented by using R language.
However, part of this model includes fixed point iteration algorithm and
calculation of large linear equations which n will get to 5000. Because of
2005 Mar 09
2
How to use a R package with C code
Hello, everybody,
I created a R package which includes C code. But I load this package, and carry
out the R function in it. It shows C function is not in load table as follows.
Would you tell me what is the problem? Where do I make mistake?
Maggie
[Previously saved workspace restored]
> library(var)
Attaching package 'var':
The following object(s) are masked _by_
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
2005 Jan 25
2
about R CMD check
hello,
I create a package which includes C code and Lapack. But when I run " R CMD
check ". an error message, "/usr/bin/ld: cannot find -lfrtbegin " occurs. could
you tell me what is the problem?
the detailed message is as follows:
[credsim@confsys ~/src]$ R CMD check var
* checking for working latex ... OK
* using log directory '/home/credsim/src/var.Rcheck'
*
2002 Jan 14
1
trouble using R Mathlib as standalone
Dear People,
I am trying to use R's Math library as standalone, as documented in
/src/nmath/standalone. I am using C++ in Debian testing, and the versions
are as follows:
ii g++-3.0 3.0.3-1 The GNU C++ compiler.
ii r-mathlib 1.4.0-1 `GNU S' - Standalone R math library
I have a file (rand.cc) as follows. I don't think that lattice.hh or mh.hh
are very
2018 Sep 20
0
Bias in R's random integers?
On 20/09/2018 6:59 AM, Ralf Stubner wrote:
> 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
2018 Sep 21
0
Bias in R's random integers?
Hello,
Top posting. Several people have asked about the code to replicate my
results. I have cleaned up the code to remove an x/y coordinate bias for
displaying the results directly on a 640 x 480 VGA adapter. You can find the
code here:
http://people.redhat.com/sgrubb/files/vseq.c
To collect R samples:
X <- runif(10000, min = 0, max = 65535)
write.table(X, file =
2018 Sep 19
2
Bias in R's random integers?
It doesn't seem too hard to come up with plausible ways in which this could
give bad results. Suppose I sample rows from a large dataset, maybe for
bootstrapping. Suppose the rows are non-randomly ordered, e.g. odd rows are
males, even rows are females. Oops! Very non-representative sample,
bootstrap p values are garbage.
David
On Wed, 19 Sep 2018 at 21:20, Duncan Murdoch <murdoch.duncan
2003 Apr 25
4
Kinderman-Ramage (PR#2846)
Hi,
Our department has detected a bug in the implementation of the
Kinderman-Ramage generator for normal random variates in version
1.7.0, which can be seen from the below R session.
(Consecutive calls for chisq.test(...) always gives p-values very
close to 0.)
We have already encountered this bug in version 1.6.2
The error is in file
R-1.7.0/src/nmath/snorm.c
Here is a patch for this file to
2004 Apr 22
2
Urgent:again question about nmath/standalone
Hello, all,
I have the same question as the last mail I sent. I have installed libRmath in
my system. But I still can not link Rmath through -lRmath. The whole process
is as follow.Is there anybody who is so kind to help me find out the problem?
I will appreciate very much.
[credsim at confsys ~]$ cd /usr/lib
[credsim at confsys lib]$ ls -l libR*
-rw------- 1 bcdesai bcdesai 237828 Apr
2017 Oct 18
1
uniform sampling without replacement algorithm
> From: "Pavel S. Ruzankin" <ruzankin at math.nsc.ru>
> Let us consider the current uniform sampling without replacement
> algorithm. It resides in function do_sample in
> https://svn.r-project.org/R/trunk/src/main/random.c
> Its complexity is obviously O(n), where the sample is selected from
> 1...n, since the algorithm has to create a vector of length n. So
2003 Jan 09
1
RNG.c: unif_rand, MARSAGLIA_MULTICARRY (PR#2437)
Full_Name: Richard Simard
Version:
OS: Linux
Submission from: (NULL) (132.204.25.139)
In the random number generator MARSAGLIA_MULTICARRY, your algorithm is
different than the one in the original reference that you give in the R manual:
Marsaglia in his post to the mailing list {\it sci.stat.math} on September 29,
1997.
The last line in the R program has a ^
while Marsaglia's algorithm has
2005 Jan 21
1
How to use a C code in R
hello,
I have a c code which uses clapack. I want to integrate R with this code. It
said that I create a R package including my c code. Then build it with putting
PKG_LIBS = $(LAPACK_LIBS). I want to know the interface LAPACK_LIBS is Fortran
or C? If it is written in Fortran, how can I build them together? If I can
build them together, I still use the function in cLapack or the function in