[R] SOM random seed

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jun 10 17:00:35 CEST 2003


First, *which* SOM routine, from which package?
Credit where credit is due and all that ....

If you mean the one in class(VR), it uses the standard R random number
generation.  You don't need to `pass the random-seed as an argument
somehow', just set the seed as you would anyway (e.g. via set.seed).

For example

     library(MASS)
     lcrabs <- log(crabs[, 4:8])
     crabs.grp <- factor(c("B", "b", "O", "o")[rep(1:4, rep(50,4))])
     gr <- somgrid(topo = "hexagonal")
     old.seed <- .Random.seed  ## save old seed if you want to
     set.seed(123)
     crabs.som <- SOM(lcrabs, gr)
     .Random.seed <- old.seed  ## restore the seed

On Tue, 10 Jun 2003, Jonck van der Kogel wrote:

> I have a question about the SOM routine. You can either supply the 
> initial representatives for the lattice yourself or else they are 
> chosen randomly from the dataset. Is it possible to pass the 
> random-seed as an argument somehow, when choosing the random 
> initialisation of the lattice?
> As it is now, each time I run a SOM on a dataset with the same settings 
> the resulting SOM will still be slightly different due to the random 
> initialisation.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list