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.

Slides:



Advertisements
Similar presentations
Random Processes Introduction (2)
Advertisements

STATISTICS Joint and Conditional Distributions
STATISTICS Linear Statistical Models
STATISTICS Sampling and Sampling Distributions
Flood Risk Analysis – the USACE Approach
STATISTICS HYPOTHESES TEST (III) Nonparametric Goodness-of-fit (GOF) tests Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering.
STATISTICS HYPOTHESES TEST (I)
STATISTICS INTERVAL ESTIMATION Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National Taiwan University.
Random Processes Introduction
Professor Ke-Sheng Cheng Dept. of Bioenvironmental Systems Engineering
Applied Hydrology Design Storm Hyetographs
STATISTICS HYPOTHESES TEST (II) One-sample tests on the mean and variance Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.
STATISTICS POINT ESTIMATION Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National Taiwan University.
Detection of Hydrological Changes – Nonparametric Approaches
Dept of Bioenvironmental Systems Engineering National Taiwan University Lab for Remote Sensing Hydrology and Spatial Modeling STATISTICS Hypotheses Test.
Hyetograph Models Professor Ke-Sheng Cheng
Flood Routing & Detention Basin Design
STATISTICS Univariate Distributions
STATISTICS Joint and Conditional Distributions
Dept of Bioenvironmental Systems Engineering National Taiwan University Lab for Remote Sensing Hydrology and Spatial Modeling STATISTICS Hypotheses Test.
R_SimuSTAT_1 Prof. Ke-Sheng Cheng Dept. of Bioenvironmental Systems Eng. National Taiwan University.
R_SimuSTAT_2 Prof. Ke-Sheng Cheng Dept. of Bioenvironmental Systems Eng. National Taiwan University.
STATISTICS Random Variables and Distribution Functions
0 - 0.
Addition Facts
PARALLEL RANDOM NUMBER GENERATION
Addition 1’s to 20.
Test B, 100 Subtraction Facts
9. Two Functions of Two Random Variables
Generating Random Numbers
Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
Random number generation Algorithms and Transforms to Univariate Distributions.
Random Number Generators. Why do we need random variables? random components in simulation → need for a method which generates numbers that are random.
1 Random Number Generation H Plan: –Introduce basics of RN generation –Define concepts and terminology –Introduce RNG methods u Linear Congruential Generator.
Evaluating Hypotheses
Random Number Generation
ETM 607 – Random Number and Random Variates
Fundamental Graphics in R Prof. Ke-Sheng Cheng Dept. of Bioenvironmental Systems Eng. National Taiwan University.
Dept of Bioenvironmental Systems Engineering National Taiwan University Lab for Remote Sensing Hydrology and Spatial Modeling STATISTICS Random Variables.
CS433 Modeling and Simulation Lecture 15 Random Number Generator Dr. Anis Koubâa 24 May 2009 Al-Imam Mohammad Ibn Saud Islamic University College Computer.
Module 1: Statistical Issues in Micro simulation Paul Sousa.
Basic Concepts in Number Theory Background for Random Number Generation 1.For any pair of integers n and m, m  0, there exists a unique pair of integers.
Random Number Generators 1. Random number generation is a method of producing a sequence of numbers that lack any discernible pattern. Random Number Generators.
Chapter 5.6 From DeGroot & Schervish. Uniform Distribution.
APPENDIX D R ANDOM N UMBER G ENERATION Organization of chapter in ISSO* – General description and linear congruential generators Criteria for “good” random.
STATISTICS INTERVAL ESTIMATION Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National Taiwan University.
Dept of Bioenvironmental Systems Engineering National Taiwan University Lab for Remote Sensing Hydrology and Spatial Modeling STATISTICS Interval Estimation.
STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.
STATISTICS Univariate Distributions Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National Taiwan University.
Dept of Bioenvironmental Systems Engineering National Taiwan University Lab for Remote Sensing Hydrology and Spatial Modeling STATISTICS Linear Statistical.
STATISTICS Joint and Conditional Distributions Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National Taiwan University.
STOCHASTIC HYDROLOGY Stochastic Simulation of Bivariate Distributions Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.
Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering National Taiwan University 1/45 GEOSTATISTICS INTRODUCTION.
Stochastic Hydrology Random Field Simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National Taiwan University.
1.  How does the computer generate observations from various distributions specified after input analysis?  There are two main components to the generation.
STATISTICS HYPOTHESES TEST (I)
STATISTICS POINT ESTIMATION
STATISTICS Joint and Conditional Distributions
STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation
STATISTICS Random Variables and Distribution Functions
STATISTICS Univariate Distributions
Stochastic Hydrology Hydrological Frequency Analysis (II) LMRD-based GOF tests Prof. Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering.
Stochastic Hydrology Random Field Simulation
STATISTICS INTERVAL ESTIMATION
Lecture 2 – Monte Carlo method in finance
Stochastic Hydrology Hydrological Frequency Analysis (I) Fundamentals of HFA Prof. Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering.
Fundamental Graphics in R
STOCHASTIC HYDROLOGY Random Processes
STATISTICS Univariate Distributions
Presentation transcript:

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

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.

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).

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.

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.

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

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.

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

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

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

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

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

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

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.

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.

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.,

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

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.