RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set
##                   RFoptions(seed=NA) to make them all random again
StartExample()
\dontrun{
#############################################################
##                                                         ##
## Example 1: Specification of simulation method           ##
##                                                         ##
#############################################################
 ## usage of a specific method
 ## -- the complete list is obtained by RFgetMethodNames()
 model <- RMstable(alpha=1.5)
 x <- runif(100, max=20) 
 y <- runif(100, max=20) # 100 points in 2 dimensional space
 simulated <- RFsimulate(model = RPdirect(model), x=x, y=y) # cholesky
 plot(simulated)
#############################################################
##                                                         ##
## Example 2: Turnung band with different number of lines  ##
##                                                         ##
#############################################################
model <- RMstable(alpha=1.5)
x <- seq(0, 10, 0.01)
z <- RFsimulate(model = RPtbm(model), x=x, y=x)
plot(z)
#############################################################
##                                                         ##
## Example 3: Shot noise fields (random coins)             ##
##                                                         ##
#############################################################
 x <- GridTopology(0, .1, 500)
 z <- RFsimulate(model=RPpoisson(RMgauss()), x=x, mpp.intensity = 100)
 plot(z)
 par(mfcol=c(2,1))
 plot(z@data[,1:min(length(z@data), 1000)], type="l")
 hist(z@data[,1])
 
 
 z <- RFsimulate(x=x, model=RPpoisson(RMball()), mpp.intensity = 0.1)
 
 plot(z)
 par(mfcol=c(2,1))
 plot(z@data[,1:min(length(z@data), 1000)], type="l")
 hist(z@data[,1])
 
 #############################################################
 ##                                                         ##
 ## Example 4: a 2d random field based on                   ##
 ## covariance functions valid in 1d only                   ##
 ##                                                         ##
 #############################################################
x <- seq(0, 2, 0.1)
model <- RMfbm(alpha=0.5, Aniso=matrix(nrow=1, c(1, 0))) + 
         RMfbm(alpha=0.9, Aniso=matrix(nrow=1, c(0, 1)))
z <- RFsimulate(x, x, model=model)
plot(z)
#############################################################
##                                                         ##
## Example 5 : Brownian sheet                              ##
## (using Stein's method)                                  ##
##                                                         ##
#############################################################
 
# 2d
step <- 0.3 ## nicer, but also time consuming if step = 0.1
x <- seq(0, 5, step)
alpha <- 1 # in [0,2)
z <- RFsimulate(x=x, y=x, model=RMfbm(alpha=alpha))
plot(z)
# 3d
z <- RFsimulate(x=x, y=x, z=x,
 model=RMfbm(alpha=alpha))
#############################################################
##                                                         ##
## Example 5 : Non-Geometric anisotropy                    ##
##                                                         ##
#############################################################
x <- seq(0.1, 6, 0.12)
Aniso <- R.c(R.p(1)^2, R.p(2)^1.5)
z <- RFsimulate(RMexp(Aniso = Aniso) + 10, x, x)
plot(z) 
}
FinalizeExample()Run the code above in your browser using DataLab