Upload
kayla-salisbury
View
216
Download
0
Tags:
Embed Size (px)
Citation preview
R_SimuSTAT_2
Prof. Ke-Sheng Cheng
Dept. of Bioenvironmental Systems Eng.
National Taiwan University
• Outline– Density and CDF plots– Plot the empirical cumulative distribution function
(ECDF) of a set of random numbers. – Simulation of discrete and continuous random
variables– Correlation
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
2
• A random variable is associated with its probability density function (PDF) and cumulative distribution function (CDF).
• Each probability density function has one or more parameters which characterize the location and shape of the PDF.
• We can observe how changes in parameters can affect the shape of PDF and CDF by plotting the PDF and CDF of different parameter settings.
• Plotting of PDF and CDF can be done using the plot and lines functions in R.
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
3
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
4
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
5
• Suppose that a random variable X is defined on the sample space of a random experiment. The random experiment is conducted n times and yields a set of n random numbers, say {x1, x2, …, xn}. This set of random numbers is called a random sample of size n of the random variable.
• Although the random variable X is associated with a (theoretical) CDF, an empirical CDF (ECDF) of the random sample can be considered as a sample of the theoretical CDF and can constructed by
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
6
– Sort the random sample {x1, x2, …, xn} in ascending order such that { y1=min(x1, x2, …, xn), …, yn=max(x1, x2, …, xn ) }
– Let
– Construct the plot of y vs Fn(y).
• The plot.ecdf function yields an ECDF plot.• Alternatively, the ecdf function can also be used
to establish an ECDF plot.04/10/23
Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
7
. toequalor an smaller th are which nsobservatio ofnumber )( yym n
ymyFn
)()(
yyyF
niyyyn
iyF
yyyF
nn
iin
n
,1)(
1,,2,1;,)(
0)(
1
1
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
8
plot.ecdf(x)
To be continued
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
9
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
10
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
11
• Correlation between detrended cumulative-sum series.
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
12
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
13
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
14
04/10/23Laboratory for Remote Sensing Hydrology and Spatial Modeling, Dept of Bioenvironmental Systems Engineering, National Taiwan Univ.
15