CurrentStream            package:rlecuyer            R Documentation

_S_e_t/_u_n_s_e_t _t_h_e _c_u_r_r_e_n_t _s_t_r_e_a_m

_D_e_s_c_r_i_p_t_i_o_n:

     '.lec.CurrentStream' sets the current stream for usage with the
     standard R functions for generating random numbers such as 'runif'
     or 'rnorm'. '.lec.CurrentStreamEnd unsets it.'

_U_s_a_g_e:

     .lec.CurrentStream (name)
     .lec.CurrentStreamEnd (kind.old = c("Marsaglia-Multicarry",
                              "Kinderman-Ramage"))

_A_r_g_u_m_e_n_t_s:

    name: a character string giving the name of the stream.

kind.old: a length 2 character vector, the old rng kinds (possiblly
          returned by '.lec.CurrentStream').

_D_e_t_a_i_l_s:

     '.lec.CurrentStream' sets the RNGkind to user-defined. All
     succeeding calls of R built-in genertors  will generate random
     numbers from the stream 'name', until '.lec.CurrentStreamEnd' is
     called. '.lec.CurrentStreamEnd' updates the RNG state of the
     stream 'name' in the table '.lec.Random.seed.table' and  sets the
     RNGkind to 'kind.old'. These two functions are meant to be always
     used as a pair.  Thus, one can arbitrarily switch generating
     between different streams.

_V_a_l_u_e:

     '.lec.CurrentStream' returns a two-element character vector of the
     RNG and normal kinds in use before the call.
     '.lec.CurrentStreamEnd' returns a character string giving the name
     of the unset current stream.

_E_x_a_m_p_l_e_s:

     nstreams <- 10       # number of streams
     names <- paste("mystream",1:nstreams,sep="")
     .lec.CreateStream(names)
     for (i in 1:nstreams) {  # generate 10 RNs from each stream
        .lec.CurrentStream(names[i])
        print(paste("stream no.",i))
        print(runif(10))
        .lec.CurrentStreamEnd()
     }

