Hi, I am very new to R and cannot seem to find how it generates random numbers. I am currently involved with a project that requires a random number generator and have developed one. I am, however, unsure of just how random it is and was wanting to compare my generator with that of R (as well as others). If anyone knows how the random numbers are generated or have any ideas on testing or where a true pseudo-random number generator can be found I would love to know. David dcum007 at ec.auckland.ac.nz
On 27 May 2003 at 8:45, dcum007 at ec.auckland.ac.nz wrote: Try ?RNGkind at the R prompt.> Hi, > I am very new to R and cannot seem to find how it generates random numbers. I > am currently involved with a project that requires a random number generator > and have developed one. I am, however, unsure of just how random it is and was > wanting to compare my generator with that of R (as well as others). > If anyone knows how the random numbers are generated or have any ideas on > testing or where a true pseudo-random number generator can be found I would > love to know.What is a TRUE pseudo-random generator? Kjetil Halvorsen> David > dcum007 at ec.auckland.ac.nz > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
What kind of random numbers (what distributions) do you want? You have a choice of specifying distributions of the random numbers. For example: rnorm() for Normal Random Numbers runif() for Uniform Random Numbers etc On Tue, 27 May 2003 dcum007 at ec.auckland.ac.nz wrote:> Date: Tue, 27 May 2003 08:45:44 +1200 > From: dcum007 at ec.auckland.ac.nz > To: "R-help at lists.R-project.org" <R-help at stat.math.ethz.ch> > Subject: [R] Randomness > > Hi, > I am very new to R and cannot seem to find how it generates random numbers. I > am currently involved with a project that requires a random number generator > and have developed one. I am, however, unsure of just how random it is and was > wanting to compare my generator with that of R (as well as others). > If anyone knows how the random numbers are generated or have any ideas on > testing or where a true pseudo-random number generator can be found I would > love to know. > David > dcum007 at ec.auckland.ac.nz > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- Cheers, Kevin ------------------------------------------------------------------------------ "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." -- Charles Babbage (1791-1871) ---- From Computer Stupidities: http://rinkworks.com/stupid/ -- Ko-Kang Kevin Wang Master of Science (MSc) Student SLC Tutor and Lab Demonstrator Department of Statistics University of Auckland New Zealand Homepage: http://www.stat.auckland.ac.nz/~kwan022 Ph: 373-7599 x88475 (City) x88480 (Tamaki)
"?.Random.seed" should answer your immediate questions about how the random numbers were generated. Articles appeared in The American Statistician a few years ago on the accuracy of statistical computations in S-Plus that said that S-Plus was one bit away from the best known algorathm at that time. I suspect that the R developers have fixed that minor problem. This R help page cites several articles and provides alternative methods of random number generation, so it is probably among the best available. There is a standard naming convention in R / S for functions associated with probability distributions. An initial letter "r" = random numbers, "d" = density", "p" = cumulative probability distribution function (cdf), "q" = quantile function = inverse cdf. Succeeding letters specify the distribution, so "runif" = uniform, "rnorm" = normal, "rt" = Student's t, etc. hth. spencer graves dcum007 at ec.auckland.ac.nz wrote:> Hi, > I am very new to R and cannot seem to find how it generates random numbers. I > am currently involved with a project that requires a random number generator > and have developed one. I am, however, unsure of just how random it is and was > wanting to compare my generator with that of R (as well as others). > If anyone knows how the random numbers are generated or have any ideas on > testing or where a true pseudo-random number generator can be found I would > love to know. > David > dcum007 at ec.auckland.ac.nz > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
?RNG comes with copious references, and the sources are in src/main/RNG.c. On Tue, 27 May 2003 dcum007 at ec.auckland.ac.nz wrote:> Hi, > I am very new to R and cannot seem to find how it generates random numbers. I > am currently involved with a project that requires a random number generator > and have developed one. I am, however, unsure of just how random it is and was > wanting to compare my generator with that of R (as well as others). > If anyone knows how the random numbers are generated or have any ideas on > testing or where a true pseudo-random number generator can be found I would > love to know.Well, there is a very extensive literature, and you don't give your background. I would suggest starting with either my 1987 book `Stochastic Simulation' or Knuth's TAOCP. The principles were worked out long ago, and the world is in no need of yet another PRNG. (There are far too many that have been heavily promoted and a few years later discredited.) -- 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
On Tue, 27 May 2003 dcum007 at ec.auckland.ac.nz wrote:> Hi, > I am very new to R and cannot seem to find how it generates random numbers. I > am currently involved with a project that requires a random number generator > and have developed one. I am, however, unsure of just how random it is and was > wanting to compare my generator with that of R (as well as others).The one addition I would make to Brian Ripley's reply is that R does not generate cryptographically secure random numbers. If your project needs random encryption keys or nonces or whatever, you should read something from the computer security literature. In this situation the arguments against making up your own generator are even stronger. -thomas