#Simulate a Gaussian random field with an exponential covariance function,
#range parameter = 2.0 and the domain is [0,5]X [0,5] evaluating the
#field at a 100X100 grid.
grid<- list( x= seq( 0,5,,100), y= seq(0,5,,100))
obj<- circulantEmbeddingSetup( grid, Covariance="Exponential", aRange=.5)
set.seed( 223)
look<- circulantEmbedding( obj)
# Now simulate another ...
look2<- circulantEmbedding( obj)
# take a look at first two
set.panel(2,1)
image.plot( grid[[1]], grid[[2]], look)
title("simulated gaussian fields")
image.plot( grid[[1]], grid[[2]], look2)
title("another realization ...")
# Suppose one requires an exponential, range = 2
# but marginal variance = 10 ( sigma in fields notation)
look3<- sqrt( 10)*circulantEmbedding( obj)
if (FALSE) {
# an interesting 3D field
grid<- list( 1:40, 1:40, 1:16 )
obj<- circulantEmbeddingSetup( grid,
cov.args=list( Covariance="Matern", aRange=2, smoothness=1.0)
)
# NOTE: choice of aRange is close to giving a negative weight array
set.seed( 122)
look<- circulantEmbedding( obj )
# look at slices in the 3rd dimension
set.panel( 4,4)
zr<- range( look)
par( mar=c(1,1,0,0))
for( k in 1:16){
image( grid[[1]], grid[[2]], look[,,k], zlim= zr, col=tim.colors(256),
axes=FALSE, xlab="", ylab="")
}
}
# same as first example using the older sim.rf
grid<- list( x= seq( 0,10,length.out=100) , y= seq( 0,10,length.out=100) )
obj<-Exp.image.cov( grid=grid, aRange=.75, setup=TRUE)
set.seed( 223)
look<- sim.rf( obj)
# Now simulate another ...
look2<- sim.rf( obj)
Run the code above in your browser using DataLab