def f_c_v2(M):
    return M / M.sum(1).reshape((M.shape[0], 1))
  1. Row Summation
  2. Reshaping for Broadcasting
  3. Element-wise Division
  4. Return the Normalised Matrix

Why This is Compact

Hence, this function succinctly normalises each row of the matrix to sum to 1, showcasing a classic and powerful use of numpy broadcasting.