Skip to content

Instantly share code, notes, and snippets.

@jaekwon
Created November 25, 2014 03:13
Show Gist options
  • Save jaekwon/fa6fca0b0d6602f88c73 to your computer and use it in GitHub Desktop.
Save jaekwon/fa6fca0b0d6602f88c73 to your computer and use it in GitHub Desktop.
Testing the effect of Sybil columns on eigenvectors
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