runifS               package:accuracy               R Documentation

_F_u_n_c_t_i_o_n _t_o _r_e_t_u_r_n _T_R_U_E (_n_o_t _p_s_e_u_d_o) _r_a_n_d_o_m _n_u_m_b_e_r_s, _b_a_s_e_d _o_n _s_y_s_t_e_m _a_n_d _n_e_t_w_o_r_k_e_d _e_n_t_r_o_p_y _c_o_l_l_e_c_t_i_o_n.

_D_e_s_c_r_i_p_t_i_o_n:

     This function makes use of hardware-generated entropy to supply 
     true random numbers. Entropy collection is slow, so its primary
     use to provide random numbers for cryptographic key generation and
     for setting  the seed value for subsequent PRNG generation.

_U_s_a_g_e:

             runifT(n,min=0,max=1,maxTries=10,silent=TRUE)
             runifS(n,...,period=10000,maxTries=10,silent=TRUE)
             rnormS(n,...,period=10000,maxTries=10,silent=TRUE)
             rstarMix(n,...,period=10000,maxTries=10,silent=TRUE,rfunc="runif")
             resetSeed(maxTries=10,silent=TRUE,kind=NULL,normal.kind=NULL)

_A_r_g_u_m_e_n_t_s:

       n: number of observations. If 'length(n) > 1', the length is
          taken to be the number required. 

 min,max: lower and upper limits of the distribution 

     ...: pass on to runif

  period: number of random numbers to generate before reseeding

maxTries: number of times to attempt to contact entropy source before
          giving yp

  silent: whether to report failures of entropy source generators

   rfunc: random deviate function to use

    kind: sets the kind of random number generator as per 'set.seed'

normal.kind: sets the kind of random number generator as per 'set.seed'

_D_e_t_a_i_l_s:

     'runifS' returns uniform pseudo-random numbers, reseeding with a
     true random number every period draws. 'rnormS' returns normal
     pseudo-random numbers, reseeding with a true random number every
     period draws. 'rstarMix' returns random numbers from any specified
     random number deviant generating function, reseeding with a true
     random number every period draws. 'rnormS' and 'runifS' are simply
     wrappers around this function 'resetSeed' resets R's own PRNG
     seed, 'set.seed', supplying a true random number

     'runifT' returns true random numbers in a uniform distribution.
     This can easily exhaust entropy sources, so for larger samples,
     'runifS' is usually preferred.

     These routines  provides true random numbers by accessing external
     entropy collectors. Currently entropy can be retrieved from two
     different sources. (1) The "Hotbits" server <URL:
     http://www.fourmilab.ch/hotbits/> supplies random bytes based on
     radioactive decay. (2) The bit server on random.org, and (3) On
     Unix systems, the the  kernel gathers environmental noise from
     device drivers and other sources into an entropy  pool, which can
     be accessed through '/dev/random'.

     Entropy is retrieved in blocks from the sources (each source
     having a different preferred block size). If the sources do not
     return a block within the R timeout value (see
     'options("timeout")' entropy requests will be repeated up to
     maxTries times per source. If no entropy is available, pseudo
     random numbers will be returned using 'runif()' (or a seed will be
     set based on 'Sys.time', for 'resetSeed', and a warning issued.

_V_a_l_u_e:

     'runifS,runifT'    Returns a vector of uniformly distributed true
     random numbers. 'resetSeed' returns the status of 'set.seed()'

_A_u_t_h_o_r(_s):

     Micah Altman Micah_Altman@harvard.edu <URL:
     http://www.hmdc.harvard.edu/micah_altman/>

_R_e_f_e_r_e_n_c_e_s:

     Altman, M., J. Gill and M. P. McDonald.  2003.  _Numerical Issues
     in Statistical Computing for the Social Scientist_.  John Wiley &
     Sons. <URL: http://www.hmdc.harvard.edu/numerical_issues/>

_S_e_e _A_l_s_o:

     See Also  'runif', 'options', '.Random.seed',

_E_x_a_m_p_l_e_s:

     # note, if you are using Windows, you must be on-line
     # to get to entropy generator, will fall-back to pseudo-random
     # numbers when off-line



     # reset the seed for runif() based on a true random value

     resetSeed()
     y=runif(100000)
     ty= table(trunc(5*y))
     print(ty)
     if (is.R()) {
       chisq.test(ty)
     } else {
       chisq.test(t(cbind(as.numeric(names(ty)),as.matrix(ty))))
     }

     ## Not run: 
     # generate true random values directly (may block for long periods if 
     # if entropy pool is empty)
     y=runifS(100000)
     ty= table(trunc(5*y))
     print(ty)
     if (is.R()) {
       chisq.test(ty)
     } else {
       chisq.test(t(cbind(as.numeric(names(ty)),as.matrix(ty))))
     }

     y=runifT(100)
     ty= table(trunc(5*y))
     print(ty);
     chisq.test(ty)
     ## End(Not run)

