x
and
y
with
user supplied covariance function.
rfsim(x, y, covfun, z=rnorm(length(x)), nc=1000, ...)
x
can be a matrix with at least two columns or a list
with at least two components.
The first column or component contains
the
x
location and the second contains the
y
locations.
x
.
covfun(0, ...)
should give the variance of the random field.
x
and
y
.
These will be transformed to have covariance
covfun
.
covfun
, typically
the parameters for the covariance function.
covfun
.
z
is not supplied, the value of the data set
.Random.seed
is updated if it already exists, otherwise
.Random.seed
is created.
The covariance matrix as a function of distance is formed.
The
z
vector is then multipled by the Cholesky decomposition of
this matrix to obtain the result.
Linear interpolation over the fixed
nh
values of distance and
cov.fun
is used in computing the covariance matrix.
Although the covariance matrix is formed in C code and only the upper
triangular is actually formed, it can require large amounts of
memory. A 100 x 100 grid of locations will require
((100 * 100) * (100 * 100) + 1) / 2 * 8 bytes / value = 400040000 bytes
or about 400 Mb of memory.
# Simulate a Gaussian random field on a 12 x 12 grid with exponential # covariance function x12 <- expand.grid(x=1:12,y=1:12) z <- rfsim(x12,covfun=exp.cov,range=3)