Variogram fitting
Kriging, IDW, and SpatialFilter use a fitted variogram when no radius is
provided. A variogram describes how dissimilar values become as the distance
between points increases. Variogram builds it in two steps: estimate the
pattern from the data, then fit a theoretical model to that estimate.
Empirical semivariogram
For every pair of source points separated by distance , the squared half-difference is a noisy sample of how dissimilar values tend to be at that separation. Averaging these over all pairs whose distance falls in a lag bin around gives the classical (Matheron) empirical semivariogram estimator (Matheron, 1971; Cressie, 1993):
where is the set of point pairs whose separation falls in the lag
bin centered on . n_lags controls how many such bins the pairwise
distance range is divided into; max_pairs bounds how many point pairs
are sampled when there are more than that available; max_distance
bounds the maximum separation considered.
Theoretical models
The empirical estimate is a scatter of noisy points, one per
lag bin, rather than a function that can be evaluated at any distance.
Variogram fits three candidate theoretical models to it, each parameterized by a nugget
(discontinuity at , representing measurement noise or
sub-lag-scale variability), a partial sill (additional variance
contributed by spatial structure), and a range (the distance
beyond which points are treated as spatially uncorrelated). Writing
:
Spherical
Exponential
Gaussian
The factor of 3 in the exponential and gaussian models is the practical
range convention. It rescales so the model reaches about 95% of the sill
at , matching the spherical model's behavior of reaching the sill
exactly at (Isaaks and Srivastava, 1989). This keeps range comparable across
the three models.
Fitting and model selection
For each candidate model, , , and are chosen to minimize the
(weighted) squared error between the model curve and the binned
empirical estimate . Variogram.fit returns the spherical,
exponential, or gaussian model with the lowest fitting error, so the caller
does not need to choose one first.
Variogram.evaluate(distances) returns the fitted model's semivariance at
arbitrary distances. These values feed directly into the
kriging linear system.