## 2 Thermal Error Modeling
### Selection of Temperature-Sensitive Points
#### 2.1.1 Principle of Hierarchical Clustering Algorithm  
The idea of hierarchical clustering is to divide the dataset at different levels based on the similarity between clusters and finally form a tree-like structure. The proximity between clusters can be assessed by the distance between two samples. At first, it is assumed that each sample point is a separate category, and then the two categories with the highest similarity are found and merged in each iteration of the algorithm. This process is repeated until all samples are merged into a large category. Hierarchical clustering can reflect well the hierarchical relationship between data, and there is no need to predefine the number of clusters. The execution process is as follows:  
1. The data of N temperature measurement points to be classified are regarded as \(N\) classes, each class contains exactly one sample, and the feature data set to be classified by \(X\) is constructed: \[X=\{X_{1},X_{2},X_{3},\ldots,X_{N}\}\] (1)  
Figure 1: Diagram of the overall prediction process for thermal errors.  
2. Calculate the similarity between the N classes, where the similarity is measured by the mutual distance between the temperature measurement points. The N-order similarity symmetry matrix \(M^{(0)}\) is obtained: \[M^{(0)}=\begin{bmatrix}0&M_{1,2}&\cdots&M_{1,N}\\ M_{2,1}&0&\cdots&M_{2,N}\\ \vdots&\vdots&&\vdots\\ M_{N,1}&M_{N,2}&\cdots&0\end{bmatrix}\] (2) where \(M_{i,j}\) denotes the distance between temperature measurement points \(X_{i}\) to \(X_{j}\), \(1\leq ij\leq N\).
3. Among the off-diagonal elements of the matrix, choose the one with the smallest value. Assuming that this element is \(M_{p,q}\), merge the temperature measurement points \(X_{p}\) and \(X_{q}\) into a new class. The new class can be noted as \(X_{g}=\left\{X_{p},X_{q}\right\}\). Eliminate the rows and columns where \(X_{p}\) and \(X_{q}\) are located in the original matrix \(M^{(0)}\) and recalculate the interclass similarity of the N-1 classes consisting of the N-2 classes in the original matrix and the new class \(X_{g}\) to obtain the new N-1 order similarity matrix \(M^{(1)}\): \[M^{(1)}=\begin{bmatrix}0&M_{1,2}&\cdots&M_{1,N-1}\\ M_{2,1}&0&\cdots&M_{2,N-1}\\ \vdots&\vdots&&\vdots\\ M_{N-1,1}&M_{N-1,2}&\cdots&0\end{bmatrix}\] (3)(5) For each cluster, compute the total distance between each sample point and all other sample points and select the point with the smallest total distance as the new cluster center:  
\[C_{j}^{(1)}=min\left\{\sum_{i=1}^{\left|H_{j}\right|}\sum x_{i\in H_{j}}Dis \big{(}X_{i},X_{j}\big{)}\right\}i\
eq j,\ 1\leq j\leq\left|H_{j}\right| \tag{7}\]  
where \(H_{j}\) represents the \(j\)-th cluster, and \(\left|H_{j}\right|\) is the number of samples of the \(j\)-th cluster. The new \(K\) centroids are expressed as follows:  
\[C^{(1)}=\left\{C_{1}^{(1)},C_{2}^{(1)},\ldots,C_{j}^{(1)},\ldots,C_{K}^{(1)} \right\}\ \ 1<K<N,\ 1\leq j\leq K \tag{8}\]  
(6) Repeat steps 3 and 4 to obtain new K clusters:  
\[K^{(1)}=\left\{H_{1}^{(1)},H_{2}^{(1)},H_{3}^{(1)},\ldots,H_{K}^{(1)}\right\} \tag{9}\]  
(7) Repeat steps 5 and 6 until the center of mass of each cluster does not change and consider that the algorithm has converged and the clustering is completed. The final K clusters are obtained as follows:  
\[K^{(t)}=\left\{H_{1}^{(t)},H_{2}^{(t)},H_{3}^{(t)},\ldots,H_{K}^{(t)}\right\} \tag{10}\]  
where \(t\) stands for the algorithm having gone through a total of \(t\) iterations.