Hi, I have some trouble with the result of a fortran function calling the R binomial RNG: The C function rbinom is wrapped as in the file attached. My main fortran program starts as call rndstart() and ends as call rndend() I happen to call the binomial RNG within a loop as b = ggrbinom(1.d0,0.5d0) write(*,*) 'b=',b In certain cases, after a few iterations in the loop, b get stuck at 1 Any hint to explain that would help. Gilles -- ??????????????????????????????????????????????????????????????????? Gilles Guillot INRA - MIA Paris Currently working from G?teborg Stochastic Centre Eklandagatan 86 - Rum1439 Chalmers University of Technology SE 412-96 G?teborg Sweden Phone +46 31 772 3514 / Fax +46 31772 3508 www.inapg.inra.fr/ens_rech/mathinfo/personnel/guillot/welcome.html ???????????????????????????????????????????????????????????????????
wrapper now attached -- ??????????????????????????????????????????????????????????????????? Gilles Guillot INRA - MIA Paris Currently working from G?teborg Stochastic Centre Eklandagatan 86 - Rum1439 Chalmers University of Technology SE 412-96 G?teborg Sweden Phone +46 31 772 3514 / Fax +46 31772 3508 www.inapg.inra.fr/ens_rech/mathinfo/personnel/guillot/welcome.html ???????????????????????????????????????????????????????????????????
wrapper now as part as the message,
sorry about previous mail
#include <R.h>
#include <Rmath.h>
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);}