## 3 Methodology
### Clustering of the SPCC Signals  
The k-means is an unsupervised clustering algorithm that aims at partitioning \(n\) observations into \(k\) clusters [39; 40; 41]. The algorithm clusters the data minimising the distance between observations belonging to the same clusters and maximizing the distance between the cluster centroids. The number of clusters must be set by the user, but if they are not known a priori, a parametric analysis can be performed, and the best clustering can be chosen. Several distance types can be performed in k-means analysis. The distance used here is Cityblock (where the distance \(d_{ij}\) between the point \(i\) and the point \(j\) is defined as \(d_{ij}=\sum\left|x_{i,k}-x_{j,k}\right|\)) [42], since it provides higher stability, but comparable results have been obtained also with squared Euclidian distance [40]. Since the results are affected by the first guess clusters (especially for challenging problems), the clustering analysis can be performed multiple times and the most frequent result is taken. Figure 5 shows an illustrative example of k-means clustering, where un-classified data are separated into two clusters, according to variable 1 and variable 2. In general, the k-means can perform the clustering using any number of variables, and it can find from 1 to \(k\) number of clusters, where \(k\) must be smaller than the number of observations N. In this work, the number of expected clusters is two, natural and triggered ELMs, while the variables are the SPCC values at each analysed time delay.  
Figure 5: Illustrative example of k-means algorithm. In left graph, data are un-clustered and each point may belong to the cluster 1 or 2. In the right graph, the k-means clustered the data minimising the “within” distance and maximising the cluster centroid distance.  
Even if it is an unlikely event, the possibility has to be considered that pellets do not trigger any ELM. In this case, the correct number of clusters is one (natural ELMs), while the k-means searches for two clusters. In order to solve this problem, an indicator that quantify the clustering quality has been used. Suppose to have N observations (in this work, N SPCs) described by M features (in this work, one feature is the SCC value at one time delay) and suppose that the data are clustered in two, \(k1\) and \(k2\). The first cluster will have a number of observations \(N_{k1}\), while the second cluster \(N_{k2}\). This indicator is based on comparing the variance of the un-clustered data:  
\[\sigma_{unclustered}^{2}=\frac{1}{N}\frac{1}{M}\ \sum_{i=1}^{N}\sum_{j=1}^{M} \bigl{(}x_{i,j}-\overline{x_{i,j}}\bigr{)}^{2} \tag{4}\]  
with the sum of the variances of the two clusters:  
\[\sigma_{k1}^{2}=\frac{1}{N_{k1}}\frac{1}{M}\ \sum_{k1=1}^{N}\sum_{j=1}^{M} \Bigl{(}x_{k1,j}-\overline{x_{k1,j}}\Bigr{)}^{2} \tag{5}\]  
\[\sigma_{k2}^{2}=\frac{1}{N_{k2}}\frac{1}{M}\ \sum_{k2=1}^{N}\sum_{j=1}^{M} \Bigl{(}x_{k2,j}-\overline{x_{k2,j}}\Bigr{)}^{2} \tag{6}\]  
Thus, the indicator used to evaluate the quality of the cluster is:  
\[K_{score}=\frac{\sigma_{unclustered}^{2}}{\sigma_{k1}^{2}+\sigma_{k2}^{2}} \tag{7}\]  
This indicator highlights the relative change of the variance value when data are clustered. If the two clusters are separated, the \(K_{score}\) is bigger than one; otherwise, it tends to one. The higher the \(K_{score}\) is, the lower the uncertainty that the separation in two clusters is misleading.