Re: [Rd] Problem with rnorm ?

From: Petr Savicky <savicky_at_cs.cas.cz>
Date: Sat, 12 May 2007 09:20:23 +0200

> #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.



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat 12 May 2007 - 07:22:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 May 2007 - 15:03:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.