Closed zkk960317 closed 3 months ago
# a test
cov = CovarianceFunction(2, Exponential(1.0,σ = 100))
pts = range(0, stop=10, length=101)
@time grf = GaussianRandomField(cov, CirculantEmbedding(), pts, pts, minpadding=201)
fem = sample(grf)
var = mean((fem.-mean(fem)).^2) #about 10000
In theory, the variance of a discrete field should be equal to the covariance when ρ = 0, and should also be equal to σ. But the variance of the test is about the square of σ, which should also be caused by the problem mentioned as the first comment.
I'm wondering if this is due to #45?
@PieterjanRobbe Thank you, I think I got it. The problem is that the description of function in the line 24 in exponential.jl
should also be modified to match the source code. The same problem exists with other covariance functions. The tutorial document should also be correct at section Tutorial -> Examples -> 1D Exponential Covariance Function
.
Thanks for pointing this out! I've updated the documentation and tutorial to reflect the changes.
First, why the apply function of exponential
apply(e::Exponential, x::Real) = e.σ * e.σ * exp(-x / e.λ)
has twoe.σ
multiplied, this is different from the original definition. Then, if I have a custom functionC(x, y) = σ * exp(-ρ / λ) + r
, the apply function should bee.σ * e.σ * exp(-x / e.λ) +e.r
ore.σ * (e.σ * exp(-x / e.λ) +e.r)
? Looking forward to your answer. @PieterjanRobbe