# Load FieldSim library
library(FieldSim)
# Example 1: Fractional Brownian Field
R<-function(x,H=0.9){1/2*((x[1]^2+x[2]^2)^(H)+(x[3]^2+x[4]^2)^(H)-((x[1]-x[3])^2+(x[2]-x[4])^2)^(H))}
res<- fieldsim(R,Elevel=1,Rlevel=5,nbNeighbor=4)
x <- res$Zrow
y <- res$Zcol
z <- res$Z
persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue")
# Example 2: Multifractional Brownian Field
F<-function(y){0.4*y+0.5}
R<-function(x,Fun=F){
H1<-Fun(x[1])
H2<-Fun(x[3])
alpha<-1/2*(H1+H2)
C2D(alpha)^2/(2*C2D(H1)*C2D(H2))*((x[1]^2+x[2]^2)^(alpha)+(x[3]^2+x[4]^2)^(alpha)-((x[1]-x[3])^2+(x[2]-x[4])^2)^(alpha))
}
res<- fieldsim(R,Elevel=1,Rlevel=5,nbNeighbor=4)
x <- res$Zrow
y <- res$Zcol
z <- res$Z
persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue")
Run the code above in your browser using DataLab