I am trying to create a transition matrix for a network. In order to do this, I need to sum down the column (the out degree), and then divide the column by the out degree in order to normalize it.
I am able to sum down the column. What I am unable to figure out how to do efficiently and easily is to divide the column by the sum.
L = {{0, 1, 0, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0},
{1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 1, 0}};
Answer
If you need to do this with all columns, then:
Transpose[#/Total[#] & /@ Transpose[L]]
Comments
Post a Comment