# Clustering Approach for Reliable Wireless Communication
## 2 Materials and Methods
### Cluster Conception and Performance  
Since the selection of the most appropriate low-correlation codes is not trivial, as all combinations need to be explored, in this paper, an enhanced method for allocating the sequences that aim to minimize the cross-correlation between allocated sequences is proposed. The method implies the following two steps:  
1. The method first creates \(k\) groups (_clusters_) of highly cross-correlated sequences. 2. Next, a single sequence is assigned to various users, chosen at random from the group. Users are divided into groups based on a round-robin process. Users using the same cluster can only randomly choose sequences from that corresponding cluster. Compared to the random classical approach, this novel approach decreases the probability of allocating highly correlated (or the same) sequences to different users, which, in turn, leads to better system performance. \(K\)-means and \(k\)-medoids clustering algorithms were used to group length \(L\) complex values and MUSA sequences. [55]. Each sequence is assumed to be a variable having coordinates in the \(L\)-dimensions plane. The cross-correlation matrix in Figure 3 illustrates the maximum value equal to 4 (code length) and shows that any code is orthogonal with 9 other codes. Also, each code has a low cross-correlation (>0 and no more than 1.4 in absolute value) with 24 other codes. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline
**Codeword** & & & & & **Codeword** & & & \\
**No. ** & & & & & & **No. ** & & & \\ \hline
1 & 1 & 1 & 1 & 1 & 33 & 1 & 1 & 1 & \(-j\) \\
2 & 1 & 1 & \(-1\) & \(-1\) & 34 & 1 & 1 & \(-1\)  
Three metrics for cross-correlation were examined, including the squared Euclidean distance, the sample correlation _between_ sequences [39], and the cross-correlation (the dot product, \(\mathbf{x}\times\mathbf{y}^{\text{H}}\)) introduced in Equation (2):  
Squared Euclidean distance:  
Assumption: The higher the distance \(d\) between sequences \(s\) and \(c\), the less the cross-correlation. The center sequence of cluster \(c\) is the average value of the sequences of the cluster:  
\[(s,c)=(s-c)*(s-c)^{H} \tag{3}\]  
Sample correlation between sequences:  
Assumption: The higher the difference of \"\(1-\) sample correlation between points\" (viewed as sequences of values) is, the smaller the correlation. To determine the sequences of a cluster, they are normalized to have zero mean and unit standard deviation. Next, the center sequence (\(s\)) in cluster (\(c\)) is computed. \[(s,c)=1-\frac{\left(s-\frac{\overrightarrow{s}}{s}\right)*\left(c-\frac{ \overrightarrow{c}}{\overrightarrow{c}}\right)^{H}}{\sqrt{\left(s-\frac{ \overrightarrow{s}}{s}\right)*\left(s-\frac{\overrightarrow{s}}{s}\right)^{ \prime}\sqrt{\left(c-\frac{\overrightarrow{c}}{c}\right)*\left(c-\frac{ \overrightarrow{c}}{\overrightarrow{c}}\right)^{H}}}} \tag{4}\]  
\[\overrightarrow{s}=\frac{1}{L}\left(\sum_{j=1}^{L}s_{j}\right)\overrightarrow {1_{L}} \tag{5}\]  
\[\overrightarrow{c}=\frac{1}{L}\left(\sum_{j=1}^{L}c_{j}\right)\overrightarrow {1_{L}} \tag{6}\]  
where \(\overrightarrow{1_{L}}\) is a row of \(L\) elements of one. \(s_{j},c_{j}\) are elements of a sequence \(s\) and the cluster's center \(c\). One minus the normalized cross-correlation. \[d(s,c)=1-\frac{\left|s*c^{H}\right|}{4} \tag{7}\]  
Figure 3: Cross-correlation matrix for 64 spreading sequences (length of 4). The clustering algorithm groups highly correlated codes by minimizing the distance between them. Therefore, the distance metric should be smaller for codes with high correlation. Thus, we chose one minus the normalized cross-correlation as a distance metric. \(K\)-means and \(k\)-medoids implementations in MATLAB simulation environments only accept sequences with real values.