Skip to content

Commit

Permalink
Fix simple CoKriging with non-zero mean
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Feb 22, 2025
1 parent b1f518f commit fb8a0d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/krig/simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ function krigmean(fitted::FittedKriging{<:SimpleKriging}, weights::KrigingWeight

cols = Tables.columns(values(d))
@inbounds map(1:k) do j
sum(1:k) do p
μ[j] + sum(1:k) do p
λₚ = @view λ[p:k:end, j]
zₚ = Tables.getcolumn(cols, vars[p])
μ[p] + sum(i -> λₚ[i] ⦿ (zₚ[i] - μ[p]), eachindex(λₚ, zₚ))
sum(i -> λₚ[i] ⦿ (zₚ[i] - μ[p]), eachindex(λₚ, zₚ))
end
end
end
7 changes: 7 additions & 0 deletions test/krig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@
@test all((0), var(okdist))
@test all((0), var(ukdist))
@test all((0), var(dkdist))

# simple CoKriging with non-zero mean
sk = GeoStatsModels.fit(SK(γ, [0.7, 0.2, 0.1]), data)
for i in 1:3
pred = GeoStatsModels.predict(sk, (:a, :b, :c), pset[i])
@test pred [j == i for j in 1:3]
end
end

@testset "Transiogram" begin
Expand Down

0 comments on commit fb8a0d2

Please sign in to comment.