Learn R Programming

seeg (version 1.0)

Rain: Rain simulation

Description

Rain simulation calculations by Marked Poisson process and Markov processes

Usage

poisson.rain(rate=1, ndays=30, shape=1, scale=1, plot.out=T)
semimarkov.rain(P, Hk, Ha, tsim)
semimarkov(P, Hk, Ha, tsim, xinit)

Arguments

rate
parameter: rate of exponential
ndays
number of days to simulate
shape
parameter: shape of weibull
scale
parameter: scale of weibull
plot.out
logical variable to decide whether to plot
Ha
rates of holding times
Hk
order of holding times
tsim
simulation time
P
Markov matrix
xinit
intial state

Value

  • ydays in between rainy days, cumulative inter-event times, and amount of rain
  • zamount of rain in a day, matrix
  • xrainy day sequence
  • taudays in between rainy days
  • ttime

Details

Simulate rainfall for every day of a month. A rainy or wet day is decided upon a Poisson process, and the mark would the amount of rain for that day if it is a wet day. The frequency distribution of rainfall in rainy days at a site determine the amount of rain, once a day is selected as wet. Daily rainfall distribution is skewed towards low values and it varies month to month according to climatic records. We generate rainfall amount using the Weibull distribution. Function semimarkov simulates semi-Markov dynamics assuming Erlang densities for the holding times. It uses five arguments: the first three are the matrices and then the simulation time and initial state. It returns the state transitions, the holding times, and the simulation time.

References

Acevedo M.F. 2013a. "Simulation of Ecological and Environmental Models". CRC Press. Acevedo M.F. 2013b. "Data Analysis and Statistics for Geography, Environmental Science, and Engineering", CRC Press.

See Also

Weather functions of SEEM rain.day, markov.rain.seq, markov.rain,

Examples

Run this code
#marked poisson simulation 
ndays= 30;rate=0.5;shape=0.7; scale=0.4
# define array
zp <- array()
rainy <- poisson.rain(rate,ndays,shape,scale,plot.out=FALSE)
zp <- rainy$z[,2]; nwet <- length(rainy$y[,3])

P <- matrix(c(0.4,0.2,0.6,0.8), ncol=2, byrow=TRUE)
Ha <- matrix(c(1,1,1,1), ncol=2, byrow=TRUE)
ndays=365
# exponential
Hk <- matrix(c(1,1,1,1), ncol=2, byrow=TRUE)
# erlang 2
Hk <- matrix(c(1,3,3,1), ncol=2, byrow=TRUE)
y <- semimarkov.rain(P, Hk, Ha, ndays)
hist(y$tau)

# semimarkov
P <- matrix(c(0.5,0.4,0.0,0.0, 0.0,0.0,0.9,0.5, 0.5,0.6,0.0,0.0, 0.0,0.0,0.1,0.5), ncol=4, byrow=TRUE)
Ha <- matrix(c(0.025,0.0154,0.0,0.0, 0.0,0.0,0.04,0.02, 0.025,0.0154,0.0,0.0, 0.0,0.0,0.04,0.02), ncol=4, byrow=TRUE)
Hk <- matrix(c(2,2,0.0,0.0, 0.0,0.0,2,2, 2,2,0.0,0.0, 0.0,0.0,2,2), ncol=4, byrow=TRUE)
nruns=4; y <- list()
for(i in 1:nruns)
y[[i]] <- semimarkov(P, Hk,Ha, tsim=1000, xinit=3)

panel4(size=7)
for(i in 1:nruns)
plot(y[[i]]$t,y[[i]]$x,type="s",xlab="Years",ylab="State (Role)",ylim=c(1,4))

for(i in 1:nruns)
hist(y[[i]]$tau,xlab="Years",main="Hist of Holding time",cex.main=0.7)

Run the code above in your browser using DataLab