cluster.error computes the clustering error. The clustering error for a design \(D=[\bm x_1, \dots, \bm x_n]^T\) is defined as \(\frac{1}{N}\sum_{i=1}^n\sum_{\bm x\in{V_i}}\|\bm x - \bm x_i\|^\alpha\), where \(V_i\) is the Voronoi cell of each design point \(\bm x_i\) for \(i=1,\dots,n\), N is the size of X. When \(\alpha=2\), we obtain K-means and when \(\alpha=1\), we obtain K-medians.