# How to create the/an integer 'seed' for set.seed() from a given .Random.seed? Classic List Threaded 1 message Reply | Threaded
Open this post in threaded view
|

## How to create the/an integer 'seed' for set.seed() from a given .Random.seed?

 Hi, 1) Given .Random.seed, how can one compute *the* integer 'seed' such that set.seed(seed) generates .Random.seed? 2) If 1) is not possible, how can one compute *an* integer 'seed' from a given .Random.seed such that different .Random.seed's are guaranteed to give different integers 'seed' (or at least with a very high probability)? In other words, how can one construct an injective function from .Random.seed objects to an integer? (In an ideal world, this would work for all kinds of random number generators). What I found out (... is not very much so far): ./src/main/names.c -> do_setseed() -> RNG.c -> RNG_Init() leads to (at least for the Mersenne Twister)... for(j = 0; j < RNG_Table[kind].n_seed; j++) {     seed = (69069 * seed + 1);     RNG_Table[kind].i_seed[j] = seed; } FixupSeeds(kind, 1); ... which gives some hope that the first entry in RNG_Table can be used to access 'seed' (which could be the 3rd value of .Random.seed in this case, but I'm not sure...). Background (or 'why on earth would you...'): I have a function myRNG of the following form (body explains the non-minimal problem): myRNG <- function(n, method, ...) {       if(method = "A") {                 } else {                 } } Thanks & cheers, Marius ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.