Displaying 3 results from an estimated 3 matches for "oldseed".
Did you mean:
oldpred
2008 Feb 13
3
Best way to reset random seed when using set.seed() in a function?
...seed' in the
global environment as following example illustrates? I'm not too kind
of having function modifying the global environment, if not really
necessary.
foo <- function(n) {
# Pop random seed
if (!exists(".Random.seed", mode="numeric"))
sample(NA);
oldSeed <- .Random.seed;
# Fixed seed to get reproducible samples here
set.seed(0xbeef);
x <- sample(5);
# Proof of concept: 'x' should be the same all the time
stopifnot(identical( x, as.integer(c(4,2,5,1,3)) ));
# Push random seed to old state
assign(".Random.seed"...
2011 Dec 10
0
clusterSetRNGStream() question
...GStream(cl)
> RNGkind()
[1] "L'Ecuyer-CMRG" "Inversion"
> stopCluster(cl)
Is it intentional that clusterSetRNGStream() changes the RNG kind in
the master process? The code of clusterSetRNGStream() suggests that
it is not: the old random number seed is saved in 'oldseed' and then
assigned to '.Random.seed':
.Random.seed <- oldseed
(https://svn.r-project.org/R/trunk/src/library/parallel/R/RngStream.R,
line 45). However, if the intent is to restore the old seed then
this assignment should be made in the global environment, e.g. via
assign(&q...
2019 Jun 07
1
Parallel number stream: clusterSetRNGStream
Dear All,
Is the following expected behaviour?
set.seed(1)
library(parallel)
cl = makeCluster(5)
clusterSetRNGStream(cl, iseed = NULL)
parSapply(cl, 1:5, function(i) sample(1:10, 1))
# 7 4 2 10 10
clusterSetRNGStream(cl, iseed = NULL)
# 7 4 2 10 10
parSapply(cl, 1:5, function(i) sample(1:10, 1))
stopCluster(cl)
The documentation could be read either way, e.g.
* iseed: An integer to be