spheresimgrid
yields discretization of sample path of a
Gaussian spherical field following the
procedure described in Brouste et al. (2009).spheresimgrid(R,Ne=100,Nr=100,nbNeighbor=4,S)
nbNeighbor
must be between 1 and 32.
nbNeighbor
is the number of neighbors to use in the second step
of the algorithm.N
columns. (S
[1,n],S
[2,n],S
[3,n])
is the point where the field must be simulated.N
columns. (S
[1,n],S
[2,n],S
[3,n])
is the point where the field has been simulated.N
containing the value of the simulated field at point
(S
[1,n],S
[2,n],S
[3,n])spheresimgrid
yields discretization of sample path of a
Gaussian spherical field associated with the covariance function given by R
and at
each point of the grid given by S
.spheresim
# load FieldSim library
library(FieldSim)
## Define the grid
n <- 30
phi <- pi/n*(1:(n-1))
theta <- 2*pi/n*(1:(n-1))
S <- numeric(0)
for (kk in 1:(n-1)){
S <- cbind(S,rbind(cos(theta[kk])*sin(phi),sin(theta[kk])*sin(phi),cos(phi)))
}
## Define the autocovariance function
d<-function(x){
u <- x[1]*x[4]+x[2]*x[5]+x[3]*x[6]
if (u<(-1))
u<- -1
if (u>1)
u<-1
acos(u)
}
R<-function(x){
H<-0.1
1/2*(d(c(1,0,0,x[1:3]))^{2*H}+d(c(1,0,0,x[4:6]))^{2*H}-d(x)^{2*H})
}
##Simulate the path
Wg <- spheresimgrid(R,Ne=50,Nr=50,nbNeighbor=4,S)$Wg
Run the code above in your browser using DataLab