There is a simple way to normalize a ndarray (every values between 0.0, 1.0)?
For example, I have a matrix like:
a = [[1., 2., 3.],
[4., 5., 6.],
[7., 8., 9.]]
Until now I'm getting the max value with
max(max(p[1:]) for p in a)
a / p
Besides I think numpy may have a method to this in one line, this doesn't work if my data is something like this:
b = [[-1., -2., -3.],
[-4., -5., -6.],
[-7., -8., 0.]]
Which gives an error caused by zero division.
What I'm trying to do is that the max value became 1. So, I would like to do a translation such that 9 becomes 1 (in positive case just dividing the values by it max value), and 0 (when it is the max value) becomes 1 (with translation method, e.g), which I know hot to do, but I guess numpy may have a solution for do this thing in its package.
How can I perform this nicely with numpy?
Thank you in advance.