krigekit.variogram_fitting#

Generic weighted fitting for marginal nested variogram models.

Classes#

FitResult

Uniform result of a variogram fit at any level.

Functions#

fit_vgm(avgvgm[, x_col, y_col, sigma_col, weight_col, ...])

Least-squares fit of a (nested) variogram model to averaged data.

calc_fit_metrics(avgvgm, model[, x_col, y_col])

Calculate goodness-of-fit metrics for a VariogramModel against empirical data.

Module Contents#

class krigekit.variogram_fitting.FitResult#

Uniform result of a variogram fit at any level.

target is the fitted object (a VgmStructure, analysis model, or system). params is the flat fitted vector, cov its covariance when available, optimizer the SciPy result for joint/constrained fits, and metrics a goodness-of-fit dict. summary() returns a labelled parameter table using each component’s name/vtype.

property success#

True unless an optimizer reported failure.

summary()#

Return a labelled parameter table with variance and p-values.

Columns: structure, component, vtype, param, value, variance, std_err, p_value. variance/std_err come from the fit covariance (NaN when unavailable); p_value is a two-sided Wald test that the parameter differs from zero (Student-t when nobs is known, else normal). Treat p-values as heuristic – binned variogram points are not independent.

krigekit.variogram_fitting.fit_vgm(avgvgm, x_col=('distance', 'mean'), y_col=('variogram', 'mean'), sigma_col=None, weight_col=None, weights=None, models=('exponential',), p0=(), makeplot=False, maxfev=9999, ax=None, xlabel='Lag', ylabel='Semivariogram', bounds=None, return_model=False, return_metrics=False)#

Least-squares fit of a (nested) variogram model to averaged data.

models may be a sequence of model names, a sequence of VariogramModel.set_vgm-style dictionaries, or a VariogramModel template. String-only models preserve the legacy additive fitting path. Dictionary/model templates also preserve product=True flags, so product structures can be fitted and returned as a Python-side model.

p0 is the initial guess as sill0, range0, ..., [nugget]. sigma_col gives SciPy-style observation standard deviations. Use weights or weight_col for weighted least squares, where larger values carry more influence; internally these are converted to sigma = 1 / sqrt(weight). Returns (params, covariance) by default; when return_model=True the fitted VariogramModel is appended to the return tuple. When makeplot is true, the Matplotlib axis is also appended.

krigekit.variogram_fitting.calc_fit_metrics(avgvgm, model, x_col=('distance', 'mean'), y_col=('variogram', 'mean'))#

Calculate goodness-of-fit metrics for a VariogramModel against empirical data.