0

I am implementing a page rank algorithm the calculation goes as such:

v = 0.8 * nodes * v + ((1 - 0.8) * e/9

v & e or one dimensional matricies and nodes is a matrix. When I define v & e as 1 dimensional matrices manually the end result is a 1 dimensional matrix as it should be. here is code to generate v & e manually:

v = np.matrix([[1/9], [1/9], [1/9], [1/9], [1/9], [1/9], [1/9], [1/9], [1/9]])
e = np.matrix([[1], [1], [1], [1], [1], [1], [1], [1], [1]]) 

However when I generate it as so I receive a matrix as a result. any one know why that might be?

v = np.zeros((9,1))
for i in range(0,9):
    v[i,0] = 1/9
e = np.ones((9,1))
CNorlander
  • 327
  • 3
  • 12
  • Your question is pretty unclear at the moment. Do you want a matrix or vector? – iz_ Dec 05 '18 at 02:45
  • `np.matrix` tries to propagate itself through calculations. Also `np.matrix` is always 2d. Your `v` and `e` have shape (9,1). But we discourage the use of `np.matrix`. Why not use `v=np.ones(9)/9 `and `e=np.ones(9)`. In your calculation is `*` elementwise multiplication, or matrix (dot) multiplication? – hpaulj Dec 05 '18 at 07:01

0 Answers0