rgrf.Rd
Fast and intuitive ways to draw from a Gaussian random field.
number of observations.
locations, the result of as.matrix(locs)
will be
used.
if no locations are specified, at least one of these to specify the grid dimension.
Domain, see ‘Details’.
perturbation degree, see ‘Details’.
covariance function name.
covariance parameter.
mean or vector for regression-type mean.
design matrix for regression-type mean.
based on Choleski factorization.
list of arguments that can be passed to the corresponding approach.
For "chol"
it can be, e.g., RStruct
, chol.args
, cov.args
.
small value, anything smaller is considered a collocation.
logical, if a single realization should be returned as a vector.
logical, if should attributes be passed back.
currently not used.
If no locations are given, the function constructs these
according a regular or a regular perturbed grid. The perturbation is
determined by tau
, which has to be greater than zero (no
perturbation) and strictly smaller than 1/2 (max perturbation).
The regular grid has spacing (here for x) dx=diff(xlim)/nx
and runs
from xlim[1]+dx/2
to xlim[2]-dx/2
.
The locations are at least (1/nx-2*tau*dx)
separated.
Currently, the only method implemented is a Cholesky factorization
routine, (much as in rmvnorm
).
The rdist()
from the fields
package is awefully
fast. Unless one has very sparse covariance matrices, a sparse
approach is not bringing a lot of improvements.
The methods may use different covariance construction approaches and
thus the nesting of cov.args
in method.args
.
require(fields)
#> Loading required package: fields
#> Loading required package: viridisLite
#>
#> Try help(fields) to get started.
# Regular grid with constant mean:
nx <- 10
field <- rgrf(1, nx=nx, Covariance="cov.wend2", theta=c(.5, 1), beta=5)
quilt.plot(cbind(attr(field,"locs"),z=field), nx=nx, ny=nx)
points(attr(field,"locs"))
# Irregluar grid:
field <- rgrf(1, nx=10, tau=0.3, Covariance="cov.mat", theta=c(.2, 1, 1.5))
fields::quilt.plot(attr(field,"locs"), field)