+ All Categories
Home > Documents > STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng...

STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng...

Date post: 13-Jan-2016
Category:
Upload: collin-rich
View: 231 times
Download: 2 times
Share this document with a friend
Popular Tags:
62
STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National Taiwan University
Transcript
Page 1: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

STOCHASTIC HYDROLOGY Stochastic Simulation (I)

Univariate simulation

Professor Ke-Sheng ChengDepartment of Bioenvironmental Systems Engineering

National Taiwan University

Page 2: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Stochastic Hydrology• Hydrological processes exhibit variations in

both space and time. As hydrological models are simplified versions of reality, they produce predictions or estimates of hydrological variables (e.g. runoff, hydraulic head, concentration) that are inherently erroneous.

• Stochastic hydrology is mainly concerned with the assessment of uncertainty in hydrological analysis, modeling and forecasting.

04/21/23Lab for Remote Sensing Hydrology and Spatial Modeling

Dept of Bioenvironmental Systems Engineering, NTU2

Page 3: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• In stochastic hydrology, the assessment of uncertainty is an integral part of hydrological analysis and modeling, being as important as the predictions themselves.

• Assessment of uncertainties is achieved by using “stochastic models”, which are models consisting of random components. These random components characterize the part of reality that is not explained by the deterministic components in our model.

04/21/23Lab for Remote Sensing Hydrology and Spatial Modeling

Dept of Bioenvironmental Systems Engineering, NTU3

Page 4: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• Errors in hydrological model prediction can occur because – the model concept is wrong, or

– due to errors in parameters, boundary and initial conditions.

• We may choose to ignore these errors and accept our model predictions at face value.

04/21/23Lab for Remote Sensing Hydrology and Spatial Modeling

Dept of Bioenvironmental Systems Engineering, NTU4

Model uncertainty

Parameter uncertainty

Page 5: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• However, in operational hydrology, when actual decisions have to be made based on hydrological model predictions (sometimes involving human life such as in flood control), it is imperative that uncertainty is taken into account in the decision-making process.– Government policy decision-making is a

complicated process. (Holistic decision making)

– An inappropriate decision may result in significant losses of life or over/under-investments in public infrastructures.

Unintended consequences of government policy

04/21/23Lab for Remote Sensing Hydrology and Spatial Modeling

Dept of Bioenvironmental Systems Engineering, NTU5

Page 6: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

What does a prediction really represent?

• Example of a linear regression model

04/21/23Lab for Remote Sensing Hydrology and Spatial Modeling

Dept of Bioenvironmental Systems Engineering, NTU6

Page 7: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

What does a prediction really represent?

• Example of a linear regression model.

04/21/23Lab for Remote Sensing Hydrology and Spatial Modeling

Dept of Bioenvironmental Systems Engineering, NTU7

Page 8: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• Predictions of data-driven models.

• Predictions of deterministic models.

• Properties of the predictand variable– Unbiased ?

– Confidence interval ?

– Efficient ?

04/21/23Lab for Remote Sensing Hydrology and Spatial Modeling

Dept of Bioenvironmental Systems Engineering, NTU8

For parameter estimation, we are concerned about the above properties of our estimators, but why not the predictions?

Page 9: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• The objectives of this course are– To demonstrate the stochastic nature of many

hydrological processes,

– To facilitate students with a stochastic perspective of hydrological modeling and forecasting, and

– To introduce techniques of stochastic simulation which will enable students to explore a wide range of applications.

04/21/23Lab for Remote Sensing Hydrology and Spatial Modeling

Dept of Bioenvironmental Systems Engineering, NTU9

Page 10: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Univariate Simulation

• Pseudo random number generation

• Probability integral transformation

• Rejection method

• Frequency-factor based generation

• Random number generation using R

04/21/23Lab for Remote Sensing Hydrology and Spatial Modeling

Dept of Bioenvironmental Systems Engineering, NTU10

Page 11: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

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

04/21/23 11Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 12: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

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

04/21/23 12Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 13: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

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.

04/21/23 13Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 14: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

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

][ 1 caxx nn

caxn 1

nx mxn /

04/21/23 14Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 15: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• 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

1231 57

13849,25173 ca .65536m

04/21/23 15Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 16: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

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 .

)(XF

)(XFU X

)(1 UFX X)(XF

04/21/23 16Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 17: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 17Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 18: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 18Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 19: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

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

04/21/23 19Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 20: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

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.

04/21/23 20Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 21: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

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

xxcgxf )()(

04/21/23 21Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 22: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

cg(X)

f(X)

X

04/21/23 22Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 23: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

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

04/21/23 23Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 24: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Frequency-factor-based generation

• An advantage of the method is that it does not require CDF inversion and frequency factors of the five commonly used distributions involves only the standard normal and the uniform deviates.

04/21/23 24Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 25: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

GENERAL EQUATION FOR

HYDROLOGICAL FREQUENCY ANALYSIS A random variable X has cumulative distribution function with mean and standard deviation . The magnitude of X corresponding to return period T, denoted by , is defined as

Chow (1951) proposed the following general equation for hydrologic frequency analysis:

where , the frequency factor, is a function of T and is distribution-specific.

)(XF

Tx TxXP T

1

TT Kx

TK

04/21/23 25Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 26: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• Apparently, if X is normally distributed, the frequency factor corresponds to the standard normal deviate with exceedence probability 1/T.

• Frequency factors of distributions commonly used in hydrologic frequency analysis have been developed (Kite, 1988).

TK

04/21/23 26Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 27: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 27Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 28: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 28Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 29: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 29Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 30: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 30Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 31: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

TEST AND VALIDATION • In order to demonstrate the applicability of

the FQFT approach, random numbers of normal, log-normal, extreme value type I (EV1), Pearson type III (PT3) and Log-Pearson type III (LPT3) distributions were generated and tested.

04/21/23 31Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 32: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• For each type of distribution N random samples, each of size n, were generated and used in subsequent analysis.

• In this study the sample size n was set to vary from 50 to 500 at increment of 50 and number of random samples N was set to 1,000 and 10,000.

04/21/23 32Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 33: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• Three means were adopted to test the validity of the generated random numbers: –Graphical comparison of CDF and

empirical CDF (ECDF) derived from generated data,

–Properties of estimated parameters, and –Type-I-error of goodness-of-fit (GOF) test.

04/21/23 33Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 34: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Graphical comparison of CDF and ECDF

• Figure 2 graphically illustrates the closeness of CDF and ECDF with regard to sample size of 50 and 500. Each ECDF in Figure 2 is based on one single random sample of size 50 or 500 and it may change when another random sample is used.

• It can be seen that even at sample size of 50 the ECDF is fairly close to CDF of the designated distribution. At sample size of 500, all ECDFs become almost indistinguishable from their corresponding CDFs.

04/21/23 34Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 35: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 35Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 36: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 36Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 37: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Properties of parameter estimators • From each of the N generated random

samples, distribution parameters including mean, standard deviation and coefficient of skewness can be estimated.

• Furthermore, from a total of N random samples, the sample mean and standard deviation of the above estimated parameters were calculated, with respect to sample size n ranging from 50 to 500.

04/21/23 37Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 38: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Uncertainty in estimation of mean reduces as sample size increases.

04/21/23 38Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 39: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Uncertainty in estimation of standard deviation reduces as sample size n increases.

04/21/23 39Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 40: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Uncertainty in estimation of skewness coefficient reduces as sample size n increases.

04/21/23 40Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 41: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• With 1,000 and 10,000 random samples (N=1000 or 10,000), sample means (the center line) of the estimated parameters (including mean, standard deviation and coefficient of skewness) are very close to the theoretical values designated for random number generation.

04/21/23 41Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 42: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• It is also seen clearly that standard deviations of all parameter estimators decrease with increase of the sample size n, indicating the unbiasedness of the estimator and reduction of uncertainty in parameter estimation. Such characteristics of parameter estimators suggest the generated random samples are indeed from the desired distributions.

04/21/23 42Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 43: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Type-I-Error of goodness-of-fit test

• Each random sample of size n is generated from a theoretical distribution with designated parameters and GOF test can be applied to test whether the random sample is drawn from the theoretical distribution. The widely applied Chi-square GOF test is adopted in this study.

04/21/23 43Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 44: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 44Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 45: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 45Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 46: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 46Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 47: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 47Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 48: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 48Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 49: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 49Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 50: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 50Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 51: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 51Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 52: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Generating random samples of normal distribution • The Box-Muller method

04/21/23 52Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 53: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• The Central Limit Theorem

04/21/23 53Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 54: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• Acceptance/Rejection Method – The cumulative distribution function of the

exponential density and its inverse function can be easily derived, and therefore, random samples of the exponential distribution can be generated with the probability integral transformation method.

04/21/23 54Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 55: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 55Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 56: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 56Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 57: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

04/21/23 57Lab for Remote Sensing Hydrology and Spatial Modeling Dept of Bioenvironmental Systems Engineering, NTU

Page 58: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Random number generation in R• R commands for stochastic simulation (for

normal distribution – pnorm – cumulative probability– qnorm – quantile function– rnorm – generating a random sample of a specific

sample size– dnorm – probability density function

For other distributions, simply change the distribution names. For examples, (punif, qunif, runif, and dunif) for uniform distribution and (ppois, qpois, rpois, and dpois) for Poisson distribution.

04/21/23 58Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.

Page 59: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

Generating random numbers of discrete distribution using R

• Discrete uniform distribution– R does not provide default functions for random

number generation for the discrete uniform distribution.

– However, the following functions can be used for discrete uniform distribution between 1 and k.• rdu<-function(n,k) sample(1:k,n,replace=T) # random number• ddu<-function(x,k) ifelse(x>=1 & x<=k & round(x)==x,1/k,0) # density• pdu<-function(x,k) ifelse(x<1,0,ifelse(x<=k,floor(x)/k,1)) # CDF• qdu <- function(p, k) ifelse(p <= 0 | p > 1, return("undefined"),

ceiling(p*k)) # quantile

04/21/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.

59

Page 60: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

– Similar, yet more flexible, functions are defined as follows• dunifdisc<-function(x, min=0, max=1) ifelse(x>=min & x<=max &

round(x)==x, 1/(max-min+1), 0)>dunifdisc(23,21,40)>dunifdisc(c(0,1))

• punifdisc<-function(q, min=0, max=1) ifelse(q<min, 0, ifelse(q>max, 1, floor(q-min+1)/(max-min+1)))>punifdisc(0.2)>punifdisc(5,2,19)

• qunifdisc<-function(p, min=0, max=1) floor(p*(max-min+1))+min>qunifdisc(0.2222222,2,19)>qunifdisc(0.2)

• runifdisc<-function(n, min=0, max=1) sample(min:max, n, replace=T)>runifdisc(30,2,19)>runifdisc(30)

04/21/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.

60

Page 61: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• Binomial distribution

04/21/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.

61

Page 62: STOCHASTIC HYDROLOGY Stochastic Simulation (I) Univariate simulation Professor Ke-Sheng Cheng Department of Bioenvironmental Systems Engineering National.

• Poisson distribution

04/21/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.

62


Recommended