Created
November 25, 2014 03:13
-
-
Save jaekwon/fa6fca0b0d6602f88c73 to your computer and use it in GitHub Desktop.
Testing the effect of Sybil columns on eigenvectors
This file contains hidden or 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 | |
from numpy import linalg as LA | |
M = np.random.random((3,3)) | |
# Normalize columns | |
M_norms = np.apply_along_axis(LA.norm, 0, M) | |
M = M / M_norms | |
# Create a sybil column | |
# append rows of zeros (nobody in original M votes for it) | |
M2 = np.append(M, [[0,0,0]], 0) | |
# append sybil column | |
Vsybil = np.random.random((4,1)) | |
Vsybil /= LA.norm(Vsybil) | |
M2 = np.append(M2, Vsybil, 1) | |
w, v = LA.eig(M) | |
w2, v2 = LA.eig(M2) | |
# Compare eigenvectors before and after sybil | |
v | |
v2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment