home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Educational / R-0.49-MI / R-0.49-I / help / base / Random < prev    next >
Encoding:
Text File  |  1997-04-23  |  1.7 KB  |  53 lines

  1.     
  2.     _R_a_n_d_o_m _N_u_m_b_e_r _G_e_n_e_r_a_t_i_o_n
  3.     
  4.     _D_e_s_c_r_i_p_t_i_o_n:
  5.     
  6.          the ``seed'' for all random number generation in R.
  7.          The Wichmann-Hill generator is used which has a cycle
  8.          length of 6.9536e12 (= prod(p-1)/4 where p is the
  9.          length 3 vector of primes, below), see p.123 of Applied
  10.          Statistics (1984) vol.33 which corrects the original
  11.          article.
  12.     
  13.     _V_a_l_u_e:
  14.     
  15.          and p = (30269, 30307, 30323).
  16.     
  17.     _R_e_f_e_r_e_n_c_e_s:
  18.     
  19.          B.A. Wichmann and I. D. Hill (1982).  Algorithm AS 183:
  20.          An Efficient and Portable Pseudo-random Number Genera-
  21.          tor, Applied Statistics, 31, 188-190; Remarks: 34,p.198
  22.          and 35, p.89.
  23.     
  24.          A. De Matteis and S. Pagnutti (1993). Long-range Corre-
  25.          lation Analysis of the Wichmann-Hill Random Number Gen-
  26.          erator, Statist. Comput., 3, 67-70.
  27.     
  28.     _N_o_t_e:
  29.     
  30.          Initially, there is no seed;  a new one is created,
  31.          using "Randomize".  Hence, student exercises will each
  32.          have different simulation results, by default.
  33.     
  34.     _S_e_e _A_l_s_o:
  35.     
  36.          runif, rnorm, ....
  37.     
  38.     _E_x_a_m_p_l_e_s:
  39.     
  40.          runif(1); .Random.seed; runif(1); .Random.seed
  41.          # If there is no seed,  a ``random'' new one is created:
  42.          rm(.Random.seed); runif(1); .Random.seed
  43.          p.WH <- c(30269, 30307, 30323)
  44.          a.WH <- c(171,   172,   170)
  45.          R.seed <- function(i.seed = .Random.seed) (a.WH * i.seed) %% p.WH
  46.          my.runif1 <- function(i.seed = .Random.seed)
  47.            { ns <- R.seed(i.seed); sum(ns / p.WH) %% 1 }
  48.     
  49.          ##- This shows how 'runif(.)' works, just using  R - functions :
  50.          rs <- .Random.seed
  51.          R.seed(rs); u <- runif(1); .Random.seed; c(u, my.runif1(rs))
  52.     
  53.