pypest / pyemu

python modules for model-independent uncertainty analyses, data-worth analyses, and interfacing with PEST(++)
BSD 3-Clause "New" or "Revised" License
176 stars 96 forks source link

Issue with calculating correlation coefficients from Covariance matrix #20

Closed Neilt100 closed 7 years ago

Neilt100 commented 7 years ago

Hi,

I've been trying to use the to_person method to convert a covariance matrix (from a jco file) to a correlation coefficient matrix, but I get an error: ''''assert not self.isdiagonal''''.

The covariance matrix I'm passing is diagonal (167 x 167). Are there some methods within pyemu to correctly convert the covariance matrix so that it can be used by the to_pearson method? Apologies if there is something obvious I'm missing that is explained elsewhere.

Thanks.

jtwhite79 commented 7 years ago

So the Pearson coef between any row-col pair in a covariance matrix is related to the covariate between the row col - the off diagonal value at index (row-1,col-1). Since your covariance matrix is diagonal, there no nonzero off diagonals...so nothing to calculate. Does that make sense?

Neilt100 commented 7 years ago

Yes, that does make sense. As I gradually understand it more, pyemu is becoming a much appreciated resource. Thanks.