In my experiment, I have a large 2D np.ndarray X of type float64 of dimensions 25x431080. I want to calculate the element-wise median across the 0-axis to get an array of dimensions 1x431080. Assume that I distort a row of the original array such that the median should not be affected, e.g., assign it to a value out of the range of the original elements. My problem is that the median computation won't return the exact same array as before.
I am wondering whether this is a typical precision issue. Is there is any way around it perhaps with another type or function?
I am attaching here a randomly generated example s.t. one can reproduce the issue
import numpy as np
x = np.random.uniform(-1,1,(25,431080))
med1 = np.median(x, axis = 0)
x[13,:] = -100*np.ones(x.shape[1]) # distort one row to -100
med2 = np.median(x, axis = 0)
np.array_equal(med1, med2) # returns False
Note: re-computation of the median on the same array gives exactly the same result so there is no precision loss or any other change across different runs of the program.