def f_b_v3(M):
    return M / M.sum(0)
  1. M.sum(0):
  2. Division (Broadcasting):
  3. Result:

How is this different from Version 2?

Overall, Version 3 is a minimalistic one-liner that leverages numpy’s broadcasting to achieve the same result: each element of M is divided by the sum of its column.