#############################################################
## Examples using the symmetric stable model, also called ##
## "powered exponential model" ##
#############################################################
PrintModelList() ## the complete list of implemented models
model <- "stable"
mean <- 0
variance <- 4
nugget <- 1
scale <- 10
alpha <- 1 ## see help("CovarianceFct") for additional
## parameters of the covariance functions
x <- seq(0, 20, 0.1)
y <- seq(0, 20, 0.1)
f <- GaussRF(x=x, y=y, model=model, grid=TRUE,
param=c(mean, variance, nugget, scale, alpha))
image(x, y, f)
#############################################################
## ... using gridtriple
x <- c(0, 20, 0.1) ## note: vectors of three values, not a
y <- c(0, 20, 0.1) ## sequence
f <- GaussRF(grid=TRUE, gridtriple=TRUE,
x=x ,y=y, model=model,
param=c(mean, variance, nugget, scale, alpha))
image(seq(x[1],x[2],x[3]), seq(y[1],y[2],y[3]), f)
#############################################################
## arbitrary points
x <- runif(100, max=20)
y <- runif(100, max=20)
z <- runif(100, max=20) # 100 points in 3 dimensional space
f <- GaussRF(grid=FALSE,
x=x, y=y, z=z, model=model,
param=c(mean, variance, nugget, scale, alpha))
f
#############################################################
## usage of a specific method
## -- the complete list can be obtained by PrintMethodList()
x <- runif(100, max=20) # arbitrary points
y <- runif(100, max=20)
f <- GaussRF(method="dir", # direct matrix decomposition
x=x, y=y, model=model, grid=FALSE,
param=c(mean, variance, nugget, scale, alpha))
f
#############################################################
## simulating several random fields at once
x <- seq(0, 20, 0.1) # grid
y <- seq(0, 20, 0.1)
f <- GaussRF(n=3, # three simulations at once
x=x, y=y, model=model, grid=TRUE,
param=c(mean, variance, nugget, scale, alpha))
image(x, y, f[,,1])
image(x, y, f[,,2])
image(x, y, f[,,3])
#############################################################
## This example shows the benefits from stored, ##
## intermediate results: in case of the circulant ##
## embedding method, the speed is doubled in the second ##
## simulation. ##
#############################################################
DeleteAllRegisters()
RFparameters(Storing=TRUE,PrintLevel=1)
y <- x <- seq(0, 50, 0.2)
(p <- c(runif(3), runif(1)+1))
ut <- unix.time(f <- GaussRF(x=x,y=y,grid=TRUE,model="exponen",
method="circ", param=p))
image(x, y, f)
hist(f)
c( mean(as.vector(f)), var(as.vector(f)) )
cat("unix time (first call)", format(ut,dig=3),"")
# second call with the *same* parameters is much faster:
ut <- unix.time(f <- GaussRF(x=x,y=y,grid=TRUE,model="exponen",
method="circ",param=p))
image(x, y, f)
hist(f)
c( mean(as.vector(f)), var(as.vector(f)) )
cat("unix time (second call)", format(ut,dig=3),"")
Run the code above in your browser using DataLab