Download presentation

Presentation is loading. Please wait.

Published byNicholas McElroy Modified over 4 years ago

1
RSLAB-NTU Lab for Remote Sensing Hydrology and Spatial Modeling 1 An Introduction to R Pseudo Random Number Generation (PRNG) Prof. Ke-Sheng Cheng Dept. of Bioenvironmental Systems Eng. National Taiwan University

2
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 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 deterministic sequence, 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
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 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
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 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
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 5 Let a sequence of numbers x n 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
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 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
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 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
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 8

9
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 9 Demonstration of the Probability Integration Transformation through stochastic simulation

10
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 10

11
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 11

12
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 12

13
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 13

14
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 14 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.

15
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 15 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.

16
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 16 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.,

17
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 17 cg(X) f(X)f(X) X

18
Lab for Remote Sensing Hydrology and Spatial Modeling RSLAB-NTU 18 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.

Similar presentations

Presentation is loading. Please wait....

OK

Random Processes Introduction (2)

Random Processes Introduction (2)

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google