Tell me more ×  How do you normalize a M*N vector, such that the
sum of all its elements is now equal to 1. I browsed online a
little, and nothing seems to quite match what I need. Thanks!
share|improve this question Have you tried to find the sum of
all elements and divide each element by that sum? –  Vladimir
Apr 10 '12 at 19:57 Little note: The sum of all entries of a
vector is only a norm if all entries are non-negative. In
general you probably want the sum of the absolute values of your
entries to equal 1. –  Anthales Apr 10 '12 at 20:11 Yes, I have
negative values too... –  Eddie Apr 10 '12 at 20:14 add comment
1 Answer  up vote 1 down vote accepted  You add up all the
elements, then divide each element by the sum.  Obviously, the
division (at least) needs to be in floating point. Since that
indicates a floating point matrix, doing the summing while
maintaining maximum accuracy will be non-trivial.  Just for
example, if you have one large element, and a lot of small
elements, you'll probably get a mor