Skip to main content
. 2015 Apr 29;15(5):10100–10117. doi: 10.3390/s150510100

Algorithm 2. K-medoids algorithm.

Let Δ(x, y) denote the distance between two elements x, y ∈ Σ.
1. Choose an arbitrary partition Inline graphick = {Σk : k = 1,…, K} of Σ and an arbitrary set of medoids Λ = {mk) ∈ Σk : k = 1,…, K}.
2. For every ΣkInline graphicK, compute the elements that are wrongly classified, i.e., x ∈ Σk satisfying Δ(x, mj)) < Δ(x, mk)) for Σj ≠ Σk. For these elements, update the partition as follows:
k=k{x} and j=j+{x}. The resultant partition is PK={k:k=1,,K}.
3. Obtain the medoids set ={m(k):kPK} for the new partition PK by solving the following K optimization programs:
m(k)argmin{max{γk:Δ(x,y)γk,yk}:xk},kPK
4. If the medoids set does not change, i.e., if Λ′ = Λ, then the clustering process is completed. Otherwise, do Λ = Λ′, and go to Step 2.