Skip to content

Commit 08d9079

Browse files
committed
update init with cokrige and documentation with math environment
1 parent 0ff71a3 commit 08d9079

File tree

3 files changed

+61
-17
lines changed

3 files changed

+61
-17
lines changed

src/gstools/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
field
2020
variogram
2121
krige
22+
cokriging
2223
random
2324
tools
2425
transform
@@ -149,6 +150,7 @@
149150
covmodel,
150151
field,
151152
krige,
153+
cokriging,
152154
normalizer,
153155
random,
154156
tools,
@@ -210,7 +212,7 @@
210212
__version__ = "0.0.0.dev0"
211213

212214
__all__ = ["__version__"]
213-
__all__ += ["covmodel", "field", "variogram", "krige", "random", "tools"]
215+
__all__ += ["covmodel", "field", "variogram", "krige", "cokriging", "random", "tools"]
214216
__all__ += ["transform", "normalizer", "config"]
215217
__all__ += [
216218
"CovModel",

src/gstools/cokriging/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"""
1616

1717
from gstools.cokriging.base import CollocatedCokriging
18-
from gstools.cokriging.methods import SimpleCollocated, IntrinsicCollocated
18+
from gstools.cokriging.methods import IntrinsicCollocated, SimpleCollocated
1919

2020
__all__ = ["CollocatedCokriging", "SimpleCollocated", "IntrinsicCollocated"]

src/gstools/cokriging/methods.py

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
IntrinsicCollocated
1111
"""
1212

13-
import numpy as np
1413
from gstools.cokriging.base import CollocatedCokriging
1514

1615
__all__ = ["SimpleCollocated", "IntrinsicCollocated"]
@@ -25,20 +24,43 @@ class SimpleCollocated(CollocatedCokriging):
2524
2625
**Markov Model I (MM1) Assumption:**
2726
28-
Assumes C_YZ(h) = ρ_YZ(0)·√(C_Z(h)·C_Y(h)) under MM1 where ρ_Y(h) = ρ_Z(h),
29-
meaning both variables share the same spatial correlation structure. This
30-
requires similar spatial correlation patterns between primary and secondary variables.
27+
Assumes the cross-covariance follows the Markov Model I:
28+
29+
.. math::
30+
C_{YZ}(h) = \\rho_{YZ}(0) \\cdot \\sqrt{C_Z(h) \\cdot C_Y(h)}
31+
32+
where :math:`\\rho_Y(h) = \\rho_Z(h)`, meaning both variables share the same
33+
spatial correlation structure. This requires similar spatial correlation
34+
patterns between primary and secondary variables.
3135
3236
**Known Limitation:**
3337
34-
MM1 can produce variance inflation where σ²_SCCK > σ²_SK in some cases.
35-
For accurate variance estimation, use IntrinsicCollocated instead.
38+
MM1 can produce variance inflation :math:`\\sigma^2_{\\text{SCCK}} > \\sigma^2_{\\text{SK}}`
39+
in some cases. For accurate variance estimation, use :any:`IntrinsicCollocated` instead.
3640
3741
**Estimator:**
3842
39-
Z*_SCCK = Z*_SK·(1-k·λ_Y0) + λ_Y0·(Y(u0)-m_Y) + k·λ_Y0·m_Z
43+
The SCCK estimator is:
44+
45+
.. math::
46+
Z^*_{\\text{SCCK}}(u_0) = Z^*_{\\text{SK}}(u_0) \\cdot (1 - k \\cdot \\lambda_{Y0})
47+
+ \\lambda_{Y0} \\cdot (Y(u_0) - m_Y) + k \\cdot \\lambda_{Y0} \\cdot m_Z
48+
49+
where:
50+
51+
.. math::
52+
k = \\frac{C_{YZ}(0)}{C_Z(0)}
53+
54+
and the collocated weight :math:`\\lambda_{Y0}` is location-dependent:
55+
56+
.. math::
57+
\\lambda_{Y0}(u_0) = \\frac{k \\cdot \\sigma^2_{\\text{SK}}(u_0)}
58+
{C_Y(0) - k^2(C_Z(0) - \\sigma^2_{\\text{SK}}(u_0))}
59+
60+
**Variance:**
4061
41-
where k = C_YZ(0)/C_Z(0) and λ_Y0 is computed from the MM1 formula.
62+
.. math::
63+
\\sigma^2_{\\text{SCCK}}(u_0) = \\sigma^2_{\\text{SK}}(u_0) \\cdot (1 - \\lambda_{Y0}(u_0) \\cdot k)
4264
4365
Parameters
4466
----------
@@ -162,25 +184,45 @@ class IntrinsicCollocated(CollocatedCokriging):
162184
163185
**Markov Model I (MM1) Assumption:**
164186
165-
Like SimpleCollocated, assumes C_YZ(h) = ρ_YZ(0)·√(C_Z(h)·C_Y(h)).
187+
Like :any:`SimpleCollocated`, assumes the cross-covariance follows:
188+
189+
.. math::
190+
C_{YZ}(h) = \\rho_{YZ}(0) \\cdot \\sqrt{C_Z(h) \\cdot C_Y(h)}
166191
167192
**Advantage over SimpleCollocated:**
168193
169194
Uses improved variance formula that eliminates MM1 variance inflation:
170-
σ²_ICCK = (1-ρ₀²)·σ²_SK ≤ σ²_SK
171195
172-
where ρ₀² = C²_YZ(0)/(C_Y(0)·C_Z(0)) is the squared correlation at zero lag.
196+
.. math::
197+
\\sigma^2_{\\text{ICCK}}(u_0) = (1 - \\rho_0^2) \\cdot \\sigma^2_{\\text{SK}}(u_0)
198+
\\leq \\sigma^2_{\\text{SK}}(u_0)
199+
200+
where:
201+
202+
.. math::
203+
\\rho_0^2 = \\frac{C_{YZ}^2(0)}{C_Y(0) \\cdot C_Z(0)}
204+
205+
is the squared correlation at zero lag.
173206
174207
**Trade-off:**
175208
176209
Requires secondary data at all primary locations (not just at estimation point).
177-
Matrix size nearly doubles compared to SimpleCollocated.
210+
The kriging system is effectively doubled in size compared to :any:`SimpleCollocated`.
211+
212+
**Estimator:**
213+
214+
The ICCK estimator combines primary and secondary data:
215+
216+
.. math::
217+
Z^*_{\\text{ICCK}}(u_0) = \\sum_{i=1}^{n} \\lambda_i Z(u_i)
218+
+ \\sum_{i=1}^{n} \\mu_i Y(u_i) + \\lambda_{Y0} Y(u_0) + \\text{(mean terms)}
178219
179220
**ICCK Weights:**
180221
181-
- λ = λ_SK (Simple Kriging weights for primaries)
182-
- μ = -(C_YZ(0)/C_Y(0))·λ_SK (secondary-at-primary adjustment)
183-
- λ_Y0 = C_YZ(0)/C_Y(0) (collocated weight)
222+
.. math::
223+
\\lambda_i &= \\lambda^{\\text{SK}}_i \\quad \\text{(Simple Kriging weights for primaries)} \\\\
224+
\\mu_i &= -\\frac{C_{YZ}(0)}{C_Y(0)} \\cdot \\lambda^{\\text{SK}}_i \\quad \\text{(secondary-at-primary adjustment)} \\\\
225+
\\lambda_{Y0} &= \\frac{C_{YZ}(0)}{C_Y(0)} \\quad \\text{(collocated weight)}
184226
185227
Parameters
186228
----------

0 commit comments

Comments
 (0)