Basically, I have an array that can change between any two numbers, and I want to save the distribution, limiting it [0,1]. The function for this is very simple. I usually write it as:
def to01(array): array -= array.min() array /= array.max() return array
Of course, it can and should be more difficult to take into account many situations, such as all values ββbeing the same (divide by zero) and swim against integer division (use np.subtract and np.divide instead of operators). But this is the most basic.
The problem is that I do this very often in the materials of my project, and it seems like a fairly standard mathematical operation. Is there a built-in function that does this in NumPy?
source share