Skip to content

kmedoids

kmedoids<T>(n, k, ops, options?): KmeansCluster<T>[]

Defined in: kmedoids.ts:28

K-medoids clustering.

Like k-means, but the cluster representative is always an actual data point (the medoid): the point that minimises the sum of centroidDistance to all other cluster members. This guarantees the representative is a real observed value, not a computed average — useful when the mean is not meaningful (e.g. discrete labels, non-Euclidean spaces).

Uses the same k-means++ seeding and assignment loop as kmeans.

T

number

Number of data points (indexed 0 … n-1).

number

Desired number of clusters; clamped to min(k, n).

KmedoidsOps<T>

Problem-specific operations. computeCentroid is handled internally.

KmeansOptions

Optional algorithm tuning.

KmeansCluster<T>[]

One entry per non-empty cluster, with its medoid and assigned indices.