Normalizing a vector to sum to one does not work?

The result is due to floating point inaccuracies. The following holds:

A = rand(100,4)

A = A./sum(A, dims = 2)

@assert sum(sum(A, dims =2) .≈ 1) == 100

Alternate name for is isapprox.

3 Likes