You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implemented, and "check under what conditions" is the substantive part of the answer.
r, C =covariance(result, variance) # C(r) = C(0) − D(r)/2
Σ =covariance_matrix(points, r, C) # C(‖xᵢ − xⱼ‖), positive-definiteness checked
The condition is second-order stationarity. A structure function is twice the variogram, so D(r) = 2[C(0) − C(r)] and C(r) = C(0) − D(r)/2. A field that is merely intrinsically stationary has a variogram but need not have a finite variance — and then no covariance exists to compute, whatever number is supplied. Documented on the function rather than left implicit.
variance is required and cannot be recovered from D. This is the exact complement of the spectral transform, where a variance argument would be wrong to accept: the k ≠ 0 spectrum follows from D(r) alone (verified to 2.3e-16 — adding a constant offset of 137 to a field leaves D unchanged to 4.6e-14 and the recovered spectrum unchanged to 1.3e-12), and only the k = 0 mode is lost. Same blindness, opposite consequence.
Positive-definiteness is checked, not assumed — and measuring it changed the design. The first test asserted "a Gaussian kernel is positive definite, so the matrix is", and it failed: interpolating a positive-definite kernel does not preserve positive-definiteness.
samples of C(r) over [0,6]
spacing
most negative eigenvalue
60
0.102
−1.2e−03
1 000
0.006
−3.8e−07
5 000
0.0012
+8.0e−08
the kernel itself, uninterpolated
—
+1.6e−09
an oscillating function (no kernel at all)
—
−9.7
Error falls as the square of the spacing and turns positive once resolved, while an invalid kernel is off by the scale of the matrix itself — nine orders apart. The error message therefore distinguishes the two causes, because "sampled too coarsely" and "not a covariance kernel" need different fixes. Tripping on a coarse C is useful output, not a nuisance.
Activity
jbphyswx commentedon Sep 6, 2026
Implemented, and "check under what conditions" is the substantive part of the answer.
The condition is second-order stationarity. A structure function is twice the variogram, so
D(r) = 2[C(0) − C(r)]andC(r) = C(0) − D(r)/2. A field that is merely intrinsically stationary has a variogram but need not have a finite variance — and then no covariance exists to compute, whatever number is supplied. Documented on the function rather than left implicit.varianceis required and cannot be recovered fromD. This is the exact complement of the spectral transform, where a variance argument would be wrong to accept: thek ≠ 0spectrum follows fromD(r)alone (verified to 2.3e-16 — adding a constant offset of 137 to a field leavesDunchanged to 4.6e-14 and the recovered spectrum unchanged to 1.3e-12), and only thek = 0mode is lost. Same blindness, opposite consequence.Positive-definiteness is checked, not assumed — and measuring it changed the design. The first test asserted "a Gaussian kernel is positive definite, so the matrix is", and it failed: interpolating a positive-definite kernel does not preserve positive-definiteness.
Error falls as the square of the spacing and turns positive once resolved, while an invalid kernel is off by the scale of the matrix itself — nine orders apart. The error message therefore distinguishes the two causes, because "sampled too coarsely" and "not a covariance kernel" need different fixes. Tripping on a coarse
Cis useful output, not a nuisance.