Skip to content

How to extract the covariance matrix of a defined model #327

Answered by MuellerSeb
Miorat asked this question in Q&A
Discussion options

You must be logged in to vote

Hey there,

my assumption is, you mean the covariance matrix used in simple-kriging (or any other kriging routine).

I really though it was implemented there, but it seems, that this attribute is missing in the kriging classes.

A temporary workaround to calculate cov_mat could look like this:

import gstools as gs
from scipy.spatial.distance import pdist, squareform

# 2D x-y pos pairs for unstructured data
pos = ([2,3,4], [1,3,5])
model = gs.Gaussian(dim=2, nugget=0.5)
iso_pos = model.isometrize(pos)

cov_mat = model.cov_nugget(squareform(pdist(iso_pos.T)))
print(cov_mat)

Maybe this helps in the meantime.

Cheers, Sebastian

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by MuellerSeb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants