To find outliers in a matrix


#1


I have a matrix of 17 columns and 2500 rows, and i want to find outliers in each of the cells. Can anyone help explain how i can write a function to loop through the cells to test for outliers?


#2

@blogjumper61199
Could you give a definition of outliers


#3

@leonhard.wettengmx.n, this is a subset of the matrix:

35.0 4.0 3.0 4.0 0.0 1350.0 1.0 0.0 2.0 16.0 4.0 185.0 1.0 330.0 1.0 3.0 0.0
30.0 4.0 1.0 4.0 0.0 1476.0 1.0 1.0 0.0 3.0 6.0 199.0 4.0 -1.0 0.0 1.0 0.0
59.0 8.0 1.0 2.0 0.0 0.0 1.0 0.0 0.0 5.0 5.0 226.0 1.0 -1.0 0.0 1.0 0.0
35.0 4.0 3.0 4.0 0.0 747.0 0.0 0.0 2.0 23.0 2.0 141.0 2.0 176.0 3.0 3.0 0.0
36.0 9.0 1.0 4.0 0.0 307.0 1.0 0.0 2.0 14.0 5.0 341.0 1.0 330.0 2.0 2.0 0.0
39.0 11.0 1.0 2.0 0.0 147.0 1.0 0.0 2.0 6.0 5.0 151.0 2.0 -1.0 0.0 1.0 0.0
41.0 6.0 1.0 4.0 0.0 221.0 1.0 0.0 0.0 14.0 5.0 57.0 2.0 -1.0 0.0 1.0 0.0

The outlier would be values below 0 and for values above 0 are the correct values. Thanks


#4

@blogjumper61199,
And which programming-language are you using....


#5

i am using Python language


#6

@blogjumper61199,

bLine="30.0 4.0 1.0 4.0 0.0 1476.0 1.0 1.0 0.0 3.0 -6.0 199.0 4.0 -1.0 0.0 1.0 0.0"

print( filter(lambda x: '-' not in x, bLine.split()))
print("=== outlier's ====")
print( filter(lambda x: '-' in x, bLine.split()))
indices = [i for i, s in enumerate(bLine.split()) if '-' in s]
print(indices)

found in stackoverflow.com with google-search
== discussions / opinions ==
python find a string in list site:stackoverflow.com
http://stackoverflow.com/questions/4843158/check-if-a-python-list-item-contains-a-string-inside-another-string
http://stackoverflow.com/questions/14849293/python-find-index-postion-in-list-based-of-partial-string

python split a string into number site:stackoverflow.com
http://stackoverflow.com/questions/15314421/in-python-how-do-i-split-a-string-into-multiple-integers


#7

Hi @blogjumper61199 ,

Always define problems very carefully.

The outlier would be values below 0 ...

... values above 0 are the correct values.

This leaves the status of the value, 0.0, undefined.