# How is centroid clustering performed with only pair wise distances

I am new to clustering and am a bit confused on how the following code can compute centroid information without the original euclidean vectors.

import numpy as np
from scipy.cluster import hierarchy
import matplotlib.pyplot as plt

# Create an array of distances
x = np.array([100., 200., 300., 400., 500., 250.,
450., 280., 450., 750.])



This code runs without error and is using 'centroid' as the link method. I am confused as to how this is even possible. My guess is there might be a formula which maps distance pair values to the centroid distance value.

I tried looking at various sources, including scipy documentation, but they all mention taking on average of the original data. Is there some reference which discusses how one can compute centroid distances without the original euclidean data?

• You might want to read docs.scipy.org/doc/scipy/reference/generated/… including Note 2 towards the end which says "it is the user’s responsibility to assure that these distances are in fact Euclidean, otherwise the produced result will be incorrect" I am not sure your example distances are consistent with that, but if they were then some geometric shortcuts might be possible including the Unweighted Pair-Groups Method Centroid algorithm. Aug 20, 2022 at 20:47
• How to compute distances between centroids from pairwise eucludean distance matrix: stats.stackexchange.com/q/148847/3277 Aug 21, 2022 at 22:04