## 2 Agglomerative Hierarchical Clustering Algorithm  
As mentioned above, clustering is the process in which a set of objects or points are grouped into categories or clusters according to a virtual distance measure. Similar points in the same cluster will have a small distance to each other while points in different clusters are dissimilar and thus are at a large distance from one another. Therefore, the dissimilarity between two signals can be used as a virtual distance measure to cluster AE signals. If cross-correlation is used as a measure of similarity of two signals, dissimilarity can be defined as 1 minus the cross-correlation. Normalized cross-correlation is preferred as it can detect the correlation between two signals having a different amplitude. This is of particular interest as the source-sensor distance may vary.  
In the developed clustering algorithm, the distance \(d_{xy}\) between two discrete-time signals \(X_{n}\) and \(Y_{n}\) (\(n=1,\dots,\) N) is defined as:  
\[d_{xy}=\max_{m}\mid\hat{R}_{xy,\text{norm}}(m)\mid \tag{1}\]  
where \(\hat{R}_{xy,\text{norm}}(m)\) is equal to the normalized estimation of the cross-correlation of a given lag \(m\), with  
\[\hat{R}_{xy,\text{norm}}(m)=\frac{\hat{R}_{xy}(m)}{\sqrt{\hat{R}_{xx}(0)\hat{ R}_{yy}(0)}} \tag{2}\]  
and  
\[\hat{R}_{xy}(m)=\begin{cases}\sum_{n=0}^{N-m-1}x_{n+m}y_{n},&m\geq 0\\ \sum_{n=0}^{N+m-1}x_{n}y_{n-m},&m<0\end{cases} \tag{3}\]  
A correlation coefficient between \(-1\) and \(1\) can be defined as the maximum of the values of all points. The value \(1\) means that the two signals show a perfect correlation and are therefore identical, the value \(0\) means that they are not correlated and therefore not similar at all, and the value \(-1\) means that they are perfectly anti-correlating meaning that they have the same shape, but opposite signs. As the distance cannot be negative and the sign of the signal is not important to distinguish different signals, the absolute value is taken first. The more similar two signals are, the shorter their distance will be. The distance approaches \(0\) as correlation goes to \(1\).  
The working principle of the algorithm is shown in Figure 1. Each signal forms a separate cluster at the start meaning that the algorithm is agglomerative. These one-signal-clusters are then combined into larger clusters based on their closeness. Two clusters with the shortest distance, i.e., smallest dissimilarity, are merged first. Then, the distance between this newly formed cluster and the other existing clusters needs to be calculated. The calculation of this inter-cluster distance or cophenetic distance can be performed in different ways, among which single (nearest neighbour), complete (furthest neighbour), and average linkage are most commonly used [22]. Single linkage can produce chain-shape clusters meaning that if few data points form a bridge between two clusters, single linkage might unify these two clusters into one. Complete linkage usually gives smaller clusters, but is less sensitive to noise and outliers. Average linkage may also give smaller clusters, but is sensitive to outliers. The approach that is most suitable for the current application was investigated. Complete linkage was used as this gave better results than single and average linkage. In case of average or single linkage, all clusters were connected to each other resulting in one cluster.  
Afterwards, the two clusters with the smallest distance are combined and again the cophenetic distance is calculated. These steps are repeated until only one cluster is formed after \(N-1\) iterations with \(N\) the number of signals. The result can be visualized in a tree structure plot called dendrogram (Figure 1 (bottom)). The dendrogram can be divided in groups based on a user-defined dissimilarity threshold or a required number of clusters.