# Weighted \(z\)-Distance-Based Clustering and Its Application to Time-Series Data
## 3 Proposed Methods
### Iterative SCC (SCC-I)  
For convenience, the proposed approach is abbreviated as SCC-I, standing for the iterative version of SCC. SCC-I consists of multiple iterations. An instance is allowed to be re-assigned to another cluster. The clustering work stops when all the assignments are stable, i.e., no assignment will be changed. A training cycle on the instances is performed in each iteration.  
In the first iteration, SCC is applied. Consider the \(r\)th iteration, \(r\geq 2\). For any instance \(\mathbf{x}_{i}\), \(1\leq i\leq N\), we first remove it from the cluster, say \(C_{t}\), which \(\mathbf{x}_{i}\) is assigned to. Three cases may arise:* If no instance remains assigned to \(C_{t}\), \(C_{t}\) is deleted and the other clusters are re-named to be \(C_{1}\),..., \(C_{J-1}\). Then \(J\) is decreased by 1, i.e., \(J\gets J-1\).
* If only one instance remains assigned to \(C_{t}\), then set \(\mathbf{c}_{t}\) to be this instance, set \(\sigma_{t}=[\sigma_{0}\ \cdots\ \sigma_{0}]^{T}\), and set \(S_{t}=1\).
* Otherwise, the characteristics of \(C_{t}\) are updated by. \[\sigma_{t,k}\leftarrow\left\{\frac{(S_{t}-1)(\sigma_{t,k}-\sigma_{0})^{2}+S_ {t}c_{t,k}^{2}+x_{t,k}^{2}}{S_{t}-2}-\frac{S_{t}-1}{S_{t}-2}\bigg{[}\frac{S_{t }c_{t,k}+x_{t,k}}{S_{t}+1}\bigg{]}^{2}\right\}^{\frac{1}{2}}+\sigma_{0},\ 1\leq k\leq n,\] \[\mathbf{c}_{t}\leftarrow\frac{S_{t}\mathbf{c}_{t}+\mathbf{x}_{i}}{S_{t }+1},\] (6) \[S_{t}\gets S_{t}+1.\]  
Then, we calculate the \(z\)-distance and MD between \(\mathbf{x}_{i}\) and each existing cluster by Equations (1) and (2). A new cluster may be created and \(\mathbf{x}_{i}\) is assigned to it as following Equation (4), or \(\mathbf{x}_{i}\) is assigned to the cluster with the largest MD as following Equation (5).  
The current \(r\)th iteration ends when all the instances are run through. If one of the cluster assignments has been changed in this iteration, the next iteration, i.e., the \((r+1)\) th iteration, proceeds. Otherwise, the assignments are stable and SCC-I stops with \(J\) clusters. The SCC-I Algorithm 2 can be summarized below.  
```
Perform SCC on \(\mathbf{X}\); repeat for each instance, instance \(i\), \(1\leq i\leq N\)  Remove instance \(i\) from its cluster and update the existing clusters;  Compute \(Z(i,j)\), \(1\leq j\leq J\);  Create a new cluster or assign instance \(i\) to the cluster with largest MD; endfor until assignments are stable; end SCC-I
```  
**Algorithm 2** SCC-I  
Note that SCC-I takes the training set \(\mathbf{X}\) as input and outputs \(J\) clusters \(C_{1}\),..., \(C_{J}\). Since re-assignments are allowed to be done, SCC-I can produce clusters that are less likely to be affected by the feeding order of the instances. As a result, more stable clusters can be obtained by SCC-I. By \"more stable\" we mean both the number of clusters and the clusters produced are less likely to be affected by the feeding order of the instances. However, SCC runs faster than SCC-I since SCC-I performs more than one iteration. To illustrate the advantage of SCC-I over SCC, a simple example is given in Appendix A.