[R] R: simulation

Petr Pikal petr.pikal at precheza.cz
Fri Mar 4 13:26:53 CET 2005



On 4 Mar 2005 at 13:07, Clark Allan wrote:

> hi all
> 
> a simple question
> 
> i want to run simulations in r. i however want the experiments to be
> repeated at a later time with exactly the same numbers by other users.
> can i set the random number seed for rnorm in some way?

See ?set.seed
It is called once before rnorm generator

> set.seed(1)
> rnorm(10)
 [1] -0.6264538  0.1836433 -0.8356286  1.5952808  0.3295078 -
0.8204684  0.4874291  0.7383247  0.5757814 -0.3053884

> set.seed(10)
> rnorm(10)
 [1]  0.01874617 -0.18425254 -1.37133055 -0.59916772  0.29454513  
0.38979430 -1.20807618 -0.36367602 -1.62667268 -0.25647839

> set.seed(1)
> rnorm(10)
 [1] -0.6264538  0.1836433 -0.8356286  1.5952808  0.3295078 -
0.8204684  0.4874291  0.7383247  0.5757814 -0.3053884
>

Cheers.
Petr


> 
> e.g. is there some arguement that goes with rnorm?
> 
> please supply an example
> 
> regards
> Allan

Petr Pikal
petr.pikal at precheza.cz




More information about the R-help mailing list