I'm trying to find the index number of the outlier number. based on difference from median I'm able to get the correct high number, but whenever the low number is the outlier I only get the high number..
import numpy as np
def findoutlier(lis):
outliermax = np.absolute(np.max(lis) - np.median(lis))
outliermin = np.absolute(np.min(lis) - np.median(lis))
if outliermax > outliermin:
argmax = np.argmax(lis, axis = 1)
return argmax
else:
argmin = np.argmin(lis, axis = 1)
return argmin
def main():
Matx = np.array([[10,3,2],[1,2,6]])
print(findoutlier(Matx))
threeMatx = np.array([[1,10,2,8,5],[2,7,3,9,11],[19,2,1,1,5]])
print(findoutlier(threeMatx))
main()