def f_c_v1(M):
    arySum = M.sum(1)
    return M / arySum.reshape((M.shape[0], 1))
  1. Compute the Row Sums:
  2. Reshape for Broadcasting:
  3. Divide Element-Wise:
  4. Return the Normalised Matrix:

Example Illustration

Suppose you have the following matrix:

1.0 3.0 1.0
2.0 4.0 4.0
6.0 3.0 6.0
4.0 7.0 9.0
  1. Row sums:

  2. Reshaping:

  3. Normalisation:


Why This Version is Shorter