Ordinary kriging

Kriging implements local ordinary kriging. For each target, it combines nearby source values using the spatial correlation described by the fitted variogram. The weights give the best linear unbiased estimator (BLUE) under that model (Matheron, 1971; Cressie, 1993; Isaaks and Srivastava, 1989).

Setup

Given nn source points with values z1,…,znz_1, \dots, z_n, the estimate at a target x0x_0 is a weighted sum

z^(x0)=∑i=1nλi zi\hat{z}(x_0) = \sum_{i=1}^{n} \lambda_i \, z_i

The weights λi\lambda_i are chosen so that the estimator is:

  • Unbiased: ∑i=1nλi=1\sum_{i=1}^{n} \lambda_i = 1. In ordinary kriging, the process mean is unknown but treated as constant within the local neighborhood. This constraint accounts for that unknown mean.
  • Minimum variance: among all weights that satisfy the unbiasedness constraint, the chosen weights minimize the estimation variance Var⁡[z^(x0)−z(x0)]\operatorname{Var}[\hat{z}(x_0) - z(x_0)]. This variance is written in terms of the semivariance γ(h)\gamma(h), which describes how dissimilar values tend to be at separation hh.

The kriging system

Minimizing variance subject to a linear equality constraint is a Lagrange-multiplier problem. Introducing multiplier μ\mu for the unbiasedness constraint and solving the resulting stationarity conditions gives a linear system in the nn weights plus μ\mu:

[γ(d11)⋯γ(d1n)1⋮⋱⋮⋮γ(dn1)⋯γ(dnn)11⋯10][λ1⋮λnμ]=[γ(d10)⋮γ(dn0)1]\begin{bmatrix} \gamma(d_{11}) & \cdots & \gamma(d_{1n}) & 1 \\ \vdots & \ddots & \vdots & \vdots \\ \gamma(d_{n1}) & \cdots & \gamma(d_{nn}) & 1 \\ 1 & \cdots & 1 & 0 \end{bmatrix} \begin{bmatrix} \lambda_1 \\ \vdots \\ \lambda_n \\ \mu \end{bmatrix} = \begin{bmatrix} \gamma(d_{10}) \\ \vdots \\ \gamma(d_{n0}) \\ 1 \end{bmatrix}

where dijd_{ij} is the distance between source points ii and jj, and di0d_{i0} is the distance from source point ii to the target x0x_0. The (n+1)×(n+1)(n+1) \times (n+1) matrix on the left is symmetric. Its bottom row and right column (all ones, with a zero corner) enforce ∑λi=1\sum \lambda_i = 1.

Solving this system gives both the kriging weights λi\lambda_i and the kriging variance, an estimate of the uncertainty at x0x_0:

σK2(x0)=∑i=1nλi γ(di0)+μ\sigma_K^2(x_0) = \sum_{i=1}^{n} \lambda_i \, \gamma(d_{i0}) + \mu

APbase does not compute or return the kriging variance: Kriging.interpolate returns only the estimates.

Unlike IDW's fixed distance-decay weights, kriging accounts for redundancy between source points. Points clustered together carry partly redundant information, so kriging gives them less combined weight than the same number of points spread around the target at similar distances.

Local kriging

Solving the full system over every source point would become expensive as the dataset grows. Kriging instead builds and solves the system for each target using only the nearest max_neighbors source points within radius, with the same min_neighbors fallback as IDW.

Supplying a variogram directly

model_values lets you pass a precomputed variogram model instead of fitting one from x/y/z. This is useful when several interpolation runs should share exactly one model, as in apbase.cross_validate, which fits one variogram and uses it for the shared search radius and the kriging model.