0
$\begingroup$

I have a 3*3 Adjacency matrix and I'm trying to sum the elements of each column and divide each column element by that sum to get the transition matrix. Can you please help me code this part? Thanks in advance.

$\endgroup$

1 Answer 1

1
$\begingroup$

Considering a is your adjacency matrix 2D numpy array :

a / a.sum(axis=0)

Should do the trick (divide all elements by columns sum)

$\endgroup$
1
  • 1
    $\begingroup$ As suggested, the function a/a.sum(axis=0) works perfectly fine to meet my needs. $\endgroup$
    – VishwaV
    Aug 27, 2019 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.