Displaying 20 results from an estimated 1000 matches similar to: "random number generation issues with r and compiled C code"
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
2008 Jul 03
1
GetRNGstate and PutRNGstate
Hi,
I've got a simulation function, written in C and called from R, that
uses the R random number functions. It's not a very complicated
simulation - 280 lines total, with the main function (the one called
with .C) repeatedly calling another function, with multiple calls to
unif_rand() in both functions. At the beginning of the main function I
call GetRNGstate(), and the last thing I do
2012 Jan 27
2
The following code (using rgamma) hangs
Hi,
I'm seeing something that may be a bug in R's standalone math library,
which is packaged by Debian as r-mathlib. I reported it to the Debian BTS
as http://bugs.debian.org/657573
I'm using Debian squeeze, and the code was tested with r-mathlib 2.11.1-6
(default on stable) and 2.14.1-1 (from testing/unstable).
I summarize this report below. The following code with the R math
2003 Dec 14
1
compile error with C code and standalone R math C library
Dear People,
I just went back to an old piece of C code. On trying to compile it with
the R math standalone C library I got the following error. Can anyone
enlighten me what I am doing wrong, if anything? C file (rr-sa.c) follows.
I'm on Debian sarge. I'm running R version 1.8.1. Gcc is version
3.3.1.
Thanks in advance.
Faheem.
2011 Aug 04
1
How to seed the R random number generator in C (standalone) with an instance of .Random.seed
hello all,
I use the R standalone math library in my own C program, and the default R
random number generator can be seeded with
set_seed(const unsigned int, const unsigned int).
How could I seed the RNG with an instance of .Random.seed ?
I would need this or a similar workaround for debugging purposes.
More precisely, I use the default R random number generator to sample from
various
2009 Nov 13
2
random numbers in C
I need some random numbers in my C program. Here a small example:
////////////////////////////////////////////////////////////////////////////////
#include <R.h>
void rand (int* n)
{
int len = *n;
for (int i = 0; i < len; i++)
Rprintf("%1.5f ", unif_rand());
}
dyn.load("rand.dll")
.C("rand", as.integer(10))
dyn.unload("rand.dll")
2010 Jan 28
1
Problem with R math library.
Hello.
I've been working on my OCaml-R binding, and I quite pleased to see that
it is functional, though far from being perfect or polished. You can
find the gitweb webpage and the interface documentation at
http://yziquel.homelinux.org/gitweb/?p=ocaml-r.git;a=tree
http://yziquel.homelinux.org/topos/api/ocaml-r/index.html
I'm having unexpected trouble with the math library, though.
2006 Mar 03
1
Fwd: Re: calling R's library using C
Sorry, forgot to switch the header to the R group....
--- Globe Trotter <itsme_410 at yahoo.com> wrote:
> Date: Thu, 2 Mar 2006 19:35:21 -0800 (PST)
> From: Globe Trotter <itsme_410 at yahoo.com>
> Subject: Re: [R] calling R's library using C
> To: Dirk Eddelbuettel <edd at debian.org>
>
> Hi, Dirk:
>
> Thanks for all the help. I thought I would
2001 Oct 21
3
generating a gamma random variable
Dear R People,
This question has nothing to do with R directly, but it is a simulation
question. I need to generate a random variable distributed as
gamma(\alpha,\beta), with the additional proviso that it must be a
function of random variable(s) which do not depend on \alpha, \beta. In
this case, I have \alpha = (T-1)/2, where T is a positive integer.
So, it seems reasonable to first simulate
2023 Feb 16
0
User-defined RNG with the standalone Rmath library
I have two questions about using a user-defined random number generator (RNG) with the standalone Rmath library. The default RNG with the standalone Rmath library is the Marsaglia-multicarry generator, which has poor properties. The "R Installation and Administration" manual, in the section "The standalone Rmath library", states that:
```
A little care is needed to use the
2008 Aug 06
1
error in installing R packages
Hello,
I am trying to install R packages under linux, some of the packages can
not be installed and I got the following error, could anybody give me
suggestion on where the problem is and how to fix it? Thanks-e
> .libPaths()
[1] "/usr/lib64/R/library"
[2] "/usr/share/R/library"
[3]
2015 Apr 21
2
shlib problems with Intel compiler
Hi,
I'm encountering trouble compiling caTools_1.17.1.tar.gz and e1071_1.6-4.tar.gz on a Linux system using the Intel compiler suite. 14 other packages I generally use installed without any trouble. I notice both of these trouble packages have a C++ component, so I wonder if that might be the issue. Below, there's information on my platform, compiler, and some diagnostic output showing
2006 Jun 08
1
Problems Building R-2.3.1 on Alpha server ES40 running Tru64 V5.1B PK#5
R Listers,
One of the list contributors suggested I abandon attempts to build
R-1.9.1 and focus on building R-2.3.1. I believe the main set of
packages have been built properly (with some changes to the code) -
however, when building the Recommended packages, the build fails.
CODE CHANGES:
=============
1. My C compiler requires a ";" on line 589 of
..../src/main/printutils.c. Here
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 Mar 03
1
generating normal numbers: GetRNGstate, PutRNGstate
Hi
I'd like to generate thousands of normal numbers from my C function using
the C API functions provided R. I have two options:
1. double norm_rand(); (page 61 of R extension 1.8.1)
2. double rnorm(double mu, double sigma); (page 58 of R extension 1.8.1)
If my understanding of R-exts is correct, then I only need to call
GetRNGstate once, and then call 1000 norm_rand, and then call
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;
2015 Apr 22
1
shlib problems with Intel compiler
Hi Martyn,
Thanks for your insight, that seems pretty direct. Unfortunately, I did not compile this version of R (it's on a large supercomputer system and this version of R was installed by the admins). Using "R CMD config", I see the following relevant settings:
DYLIB_LD = icc -std=gnu99
DYLIB_LDFLAGS = -shared -openmp
LDFLAGS = -L/opt/compilers/intel/cce/9.1.039/lib
2002 Jul 24
1
loading compiled C++ code as shared library
Dear People,
Over the last few days I've been writing C++ to compile as a shared
library (previously I have always used C). Not entirely to my surprise, I
am getting errors. Specifically, when I try to load the shared library, I
get
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
"/home/faheem/research/thesis/sim/ms/ms.so":
2005 Jun 28
1
GetRNGstate() crashes in Windows
Hi,
Has anyone managed to successfully call GetRNGstate() / PutRNGstate()
without crashing in a Windows environment (spec. XP)? I've compiled
successfully using both the latest Cygwin, latest Mingw, and the version
of Mingw suggested in "Building R for Windows" website, but when the
executable runs, it crashes; the functions themselves can run when I omit
2001 Feb 24
5
testing for integer
Dear People,
Consider the following fragment of R code
choose <- function(n,r)
{
if( is.integer(n) && is.integer(r) && n > 0 && r >= 0 )
{
.C("choose",as.double(n),as.double(r),comb = double(1))$comb
}
else stop("n must be a positive integer and r a non-negative integer.")
}
This is a practice function (n choose r), which I