Created
November 1, 2019 16:43
-
-
Save jaklinger/d778d46737bcdbac68e5bce8997e56e4 to your computer and use it in GitHub Desktop.
Asymmetry measurement of a square matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def assym(a): | |
return 1 - (np.linalg.det(0.5*(a + a.T)) / np.linalg.det(a)) | |
for a in ([[10,123,0],[123,10,0],[0,0,10]], [[10,123,0],[121,10,0],[0,0,10]], | |
[[10,123,0],[50,10,0],[0,0,10]], [[10,123,0],[0,10,0],[23,0,10]], | |
[[10,123,0],[-123,10,0],[5422,0,10]]): | |
a = np.matrix(a) | |
print(a) | |
print(assym(a)) | |
print() | |
>>> [[ 10 123 0] | |
>>> [123 10 0] | |
>>> [ 0 0 10]] | |
>>> 0.0 | |
>>> | |
>>> [[ 10 123 0] | |
>>> [121 10 0] | |
>>> [ 0 0 10]] | |
>>> -6.764526821045891e-05 | |
>>> | |
>>> [[ 10 123 0] | |
>>> [ 50 10 0] | |
>>> [ 0 0 10]] | |
>>> -0.2202066115702468 | |
>>> | |
>>> [[ 10 123 0] | |
>>> [ 0 10 0] | |
>>> [ 23 0 10]] | |
>>> 39.145000000000046 | |
>>> | |
>>> [[ 10 123 0] | |
>>> [-123 10 0] | |
>>> [5422 0 10]] | |
>>> 483.59380130015165 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment