1 / 18

An Introduction to R Pseudo Random Number Generation (PRNG)

An Introduction to R Pseudo Random Number Generation (PRNG). Prof. Ke-Sheng Cheng Dept. of Bioenvironmental Systems Eng. National Taiwan University. Pseudo Random Number Generator (PRNG).

kiley
Download Presentation

An Introduction to R Pseudo Random Number Generation (PRNG)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Introduction to RPseudo Random Number Generation (PRNG) Prof. Ke-Sheng Cheng Dept. of Bioenvironmental Systems Eng. National Taiwan University

  2. Pseudo Random Number Generator (PRNG) • Computer simulation of random variables is the task of using computers to generate many random numbers that are independent and identically distributed. It is also known as random number generation (RNG). • In fact, these computer-generated random numbers form a deterministicsequence, and the same list of numbers will be cycled over and over again. This cycle can be made to be so long that the lack of true independence is unimportant.

  3. Therefore, such computer codes are often termed pseudo-random number generators (PRNG). • There exist mathematical transformation methods to obtain other distributions from uniform variates. For this reason, most PRNGs found in software libraries produce uniform random numbers in the unit interval (0, 1).

  4. Linear Congruential Generator • Generation of random samples of various probability densities is based random samples of the uniform density U[0,1). Therefore, the algorithm of generating random numbers of U[0,1) is essential. This can be achieved by the Linear Congruential Generator (LCG) described below.

  5. Let a sequence of numbers xn be defined by modulo m where a, c, and m are given positive integers. The above equation means that is divided by m and the remainder is taken as the value of . The quantity is then taken as an approximation to the value of a U[0,1) random variable. When c = 0, the algorithm is also called a pure multiplicative generator.

  6. A guideline for selection of a and m (c =0) is that m be chosen to be a large prime number that can be fitted to the computer word size. For a 32-bit word computer, m = and a = result in desired properties. • For small computers without a random number generator, the following a, c, and m are found to be satisfactory when the LCG algorithm is used: and

  7. PROBABILITY INTEGRAL TRANSFORMATION • The PIT method is based on the property that a random variable X with CDF can be transformed into a random variable U with uniform distribution over the interval (0,1) by defining • Conversely, if U is uniformly distributed over the interval (0,1), then has cumulative distribution function .

  8. Demonstration of the Probability Integration Transformation through stochastic simulation

  9. For random variables whose cumulative distribution function cannot be expressed by a close form the probability integral transformation technique cannot be used for generating random numbers of these random variables. • The normal distribution is one such random variable.

  10. The Acceptance/Rejection Method • This method uses an auxiliary density for generation of random quantities from another distribution. This method is particularly useful for generating random numbers of random variables whose cumulative distribution functions cannot be expressed in closed form.

  11. Suppose that we want to generate random numbers of a random variable X with density f(X). • An auxiliary density g(X) which we know how to generate random samples is identified and cg(X) is everywhere no less than f(X) for some constant c, i.e.,

  12. cg(X) f(X) X

  13. Generate a random number x of density g(X), • Generate a random number u from the density U[0,cg(x)), • Reject x if u > f(x); otherwise, x is accepted as a random number form f(X), • Repeat the above steps until the desired number of random numbers are obtained.

More Related