From savicky at cs.cas.cz  Sat May 12 09:20:23 2007
From: savicky at cs.cas.cz (Petr Savicky)
Date: Sat, 12 May 2007 09:20:23 +0200
Subject: [Rd] Problem with rnorm ?
In-Reply-To: <dc69f8e3bca.4644a5a3@usc.edu>
References: <dc69f8e3bca.4644a5a3@usc.edu>
Message-ID: <20070512072022.GA25989@cs.cas.cz>

> #include <stdio.h>
> #include <Rmath.h>
> 
> int main(void){
>   double x[3];
>   for(int i=0;i<3;i++)  x[i]=rnorm(0,1);
>   printf("%lf,%lf,%lf",x[0],x[1],x[2]);
>   return 0;
> }
> 
> output :   -8.773321,-8.773321,-8.773321

You probably have to call GetRNGstate() before rnorm and PutRNGstate() after.
At least for extension packages, this is necessary, see section 6.3 in R-exts.pdf.

Petr.



[Rd] Problem with rnorm ?
Petr Savicky