[Rd] RNG stuck via Fortran call

From: Gilles GUILLOT <gilles.guillot_at_inapg.inra.fr>
Date: Wed 30 Nov 2005 - 15:06:33 GMT

Having not much success with my previous question I try to reformulate it:

I'm simulating a Markow chain in Fortran interfaced with R. Each loop of my Fortran calls various functions of the R RNG through the wrapper given below.

In a run of 100 iterations of the Markov kernel,  after 20 iterations, the RNG seems like frozen.

For example, the first call to the RNG in my loop is:

 rpostlamb = ggrgam(dble(m),1.d0)
 write(*,*) 'rpostlamb=',rpostlamb

after the 20th iteration, it will return the same value rpostlamb= 1.24634557

for all the following interations.

Is there any suggestion of explanation for this strange fact ?

Thanks in advance


R Version 2.2.0 compiled under Mandrake 10.1

#include <R.h>
#include <Rmath.h>


/* random numbers */

void F77_SUB(rndstart)(void)
{ GetRNGstate(); }

void F77_SUB(rndend)(void)
{ PutRNGstate(); }

double F77_SUB(ggrnorm)(double *mu, double *sigma)
{ return rnorm(*mu, *sigma); }

double F77_SUB(ggrexp)(double *scale)
{return rexp(*scale);}

double F77_SUB(ggrgam)(double *a, double *scale)
{return rgamma(*a, *scale);}

double F77_SUB(ggrunif)(double *a, double *b)
{return runif(*a, *b);}

double F77_SUB(ggrbinom)(double *n, double *p)
{return rbinom(*n, *p);}

double F77_SUB(ggrpois)(double *lambda)
{return rpois(*lambda);}

R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Dec 01 03:00:42 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:34 GMT