ABSTRACT

Facilities are provided in both packages to work with random numbers following various probability distributions, and to calculate probability densities and cumulative probabilities. When performing stochastic simulations, or any calculations involving random numbers, it is sometimes essential to be able to reproduce particular results. This can be done by using a given seed value to set the random number generator back to a known state, so that the sequence of random numbers subsequently produced will be reproducible by using the same seed again. By default, R seeds the random number generator based on the current time and process ID the first time people generate a random value. MATLAB begins with the same seed each time; they can reset the random number seed back to this initial state via the command rng. In R, the various functions to generate random values all begin with the letter “r.” Each command generates w independent, identically distributed values from the given probability distribution.