On Thu, Jun 09, 2011 at 10:14:48AM -0500, Soyeon Kim wrote:
> Dear All,
>
> This is hard to describe so I made a simple example.
> set.seed(1001)
> total <- 0
> data <- vector("list", 30)
> for(i in 1:30) {
> data[[i]] <- runif(50)
> }
> Let's call a data set runif(50).
> While the for loop is r
On 09.06.2011 18:09, R Help wrote:
That wouldn't work because the seed is for the first iteration.
Random numbers are generated by a seed, after which the seed changes
(I don't know the mechanism for changing the seed in R, but it's
static)
That means that, if you set the seed to 1001, and th
On 09/06/2011 11:48 AM, jim holtman wrote:
If you feel the need to go back and recreate a random series, then
same the seed (.Random.seed) and restore it:
This works in this example, but wouldn't work with all RNGs, because
some of them save state outside of .Random.seed. See ?.Random.seed fo
On 09/06/2011 11:48 AM, jim holtman wrote:
If you feel the need to go back and recreate a random series, then
same the seed (.Random.seed) and restore it:
This works in this example, but wouldn't work with all RNGs, because
some of them save state outside of .Random.seed. See ?.Random.seed fo
That wouldn't work because the seed is for the first iteration.
Random numbers are generated by a seed, after which the seed changes
(I don't know the mechanism for changing the seed in R, but it's
static)
That means that, if you set the seed to 1001, and then run runif
function 50 times, you'll
If you feel the need to go back and recreate a random series, then
same the seed (.Random.seed) and restore it:
> set.seed(1001)
> total <- 0
> data <- vector("list", 30)
> seeds <- vector("list", 30)
> for(i in 1:30) {
+ seeds[[i]] <- .Random.seed
+ data[[i]] <- runif(50)
+ }
>
> .Random.seed <
What about:
set.seed(1001)
total <- 0
data <- vector("list", 30)
for(i in 1:30) {
data[[i]] <- runif(50)
}
set.seed(1001)
data[[23]] <- runif(50)
HTH
Samuel
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Soyeon Kim
Sent: 09 June
On 09/06/2011 11:14 AM, Soyeon Kim wrote:
Dear All,
This is hard to describe so I made a simple example.
set.seed(1001)
total<- 0
data<- vector("list", 30)
for(i in 1:30) {
data[[i]]<- runif(50)
}
Let's call a data set runif(50).
While the for loop is running, 100 data sets are generated.
I
There are certainly people that would know how the random functions
work better than I, but I believe you would need to simulate 22
datasets and then get the 23rd dataset. So to restore the 23rd:
set.seed(1001)
for(i in 1:22){
garbage = runif(50)
}
data[[23]] = runif(50)
Hope that helps,
Sam
9 matches
Mail list logo