I'm doing a clustering algorithm to group properties. In this sense, I have geographic coordinate information for these properties. However, for the clustering process, I would like to exclude some outliers properties. For this, I made the following pseudocode.

Algorithm: Exclusion of outliers properties

1: procedure EXCLUSION OF OUTLIERS PROPERTIES (uij)

2: Calculate dik as in (4), which is the Euclidean distance between
all properties to be clustered.

dik=√(ui2- uk2)2+(ui3- uk3)² ,                     (4)

with i and k from 1, …, n and i≠k

m=mean (dik)                                       (5)

sd=Standard Deviation (dik)                        (6)

limit=m+3*sd                                       (7)

3: Select property i from {uij} that has distance dik<= limit ∀k, ∀i

4: end procedure


However, after I use the Euclidean distance between the properties in step 2, a distance matrix from each location to every other location is generated. Ex:

         [,1]     [,2]      [,3]      [,4]
[1,]    0.000 1522.997 1693.9978 2413.0564
[2,] 1522.997    0.000 2410.7105 2748.2810
[3,] 1693.998 2410.711    0.0000  825.7868
[4,] 2413.056 2748.281  825.7868    0.0000


From this matrix, I take the smallest distance value for each unit. For example, the smallest value between property 1 and other properties is 1522.9967. For the second property, it is 1522.9967, and so on. In this case, I have an matrix like this:

         [,1]
[1,] 1522.9967
[2,] 1522.9967
[3,]  825.7868
[4,]  825.7868


So from this matrix, I do mean and standard deviation and so I find limit value. However, I would like to make this adjustment in the pseudocode, regarding this new change I made. Can you help me?

• It seems the second mentioned matrix needs some adjustments. For example, the number 1522.9967 would actually belong to the second location, but it falls in the first location. Do you check it? Jul 23, 2022 at 7:19