# UAV-Assisted Dynamic Clustering of Wireless Sensor Networks for Crop Health Monitoring
## 4 Dynamic Cluster Head Selection  
Once the UAV assisted cluster is formed, the developed system will grade cluster nodes into two types: the first type contains the nodes that don't have the capability to approach the UAV, called  
Figure 3: Working flow of sensor node.  
cluster members (CMs); candidate cluster heads (CCHs) are the other type. The CCHs are further shunted by the developed system to keep them in a range from \(1\) to \(N\) (where \(N\) is the maximum capacity of the UAV to locate sensor nodes). All CCHs and the UAV will collectively take part in the selection process to nominate a node as CH.  
Many parameters (like remaining energy, available renewable energy, energy consumption rate, antenna size and distance to the UAV) are considered in this selection process. In the proposed system, the tasks of cluster formation and the CH selection are conducted dynamically at runtime according to the context and then a reliable point to point backbone connection is established between the CH and the UAV to collect all required data for further processing and decision making. The proposed dynamic clustering scheme is illustrated in Figure 4.  
Each node will participate in the CH selection process depending upon its probability calculated by using a Bayesian classifier. Bayesian probability has been studied for two centuries and many researchers are using it for different purposes [13; 14; 15; 16]. We are inspired by Bayesian spam filtering [17] as it is more close to our problem domain. We derived our probabilities in as follows:  
Let us suppose there are \(n\) sensor nodes \(S=(s_{1},\,s_{2},\,\dots,\,s_{n})\) and each sensor node \(s_{i}\) has \(z\) attributes (independent variables) represented by a vector \(\mathcal{A}=(\alpha_{1},\alpha_{2},\dots,\,\alpha_{z})\). A sensor node \(s_{i}\) can be in one of two states:  
1. Cluster Head (CH)
2. Cluster Member (CM)  
represented by \(State=(\text{CH},\text{CM})\)  
\(\text{P}(s_{i}=\text{CH}|\mathbf{a}_{ij})\) is the posterior probability of a given sensor node \(s_{i}\) to be a CH knowing its attribute \(\mathbf{a}_{ij}\).  
\(\text{P}(s_{i}=\text{CH})\) is the prior probability of given node to be a CH.  
\(\text{P}(a_{ij}|s_{i}=\text{CH})\) is the likelihood probability that the highest value of the attribute \(\mathbf{a}_{ij}\) is in CH node.  
\(\text{P}(s_{i}=\text{CM})\) is the prior probability that a given node \(s_{i}\) is a member node.  
\(\text{P}(a_{ij}|s_{i}=\text{CM})\) is the probability that the highest value of attribute \(\mathbf{a}_{ij}\) is in CM and not in CH.  
\(\text{P}(\mathbf{a}_{ij})\) is the prior probability of the attribute value \(\mathbf{a}_{ij}\) is the highest one.  
Equation (1) is the probability of the node \(s_{i}\) to be a cluster head by knowing only one parameter \(\mathbf{a}_{ij}\). If all parameters \(\mathcal{A}_{i}=(\alpha_{1},\alpha_{2},\dots,\,\alpha_{z})\) of node \(s_{i}\) are independent in nature then the conditional probability of this node, by considering whole set \(\mathcal{A}_{i}\) can be calculated as:  
\[\text{P}(\mathbf{a}_{i1},\mathbf{a}_{i2},\dots,\mathbf{a}_{iz}|s_{i}=\text{CH})=\prod_{j= 1}^{z}\text{P}\big{(}\mathbf{a}_{ij}|s_{i}=\text{CH}\big{)}=\prod_{j=1}^{z}\frac{ \text{P}\big{(}s_{i}=\text{CH}\big{|}\mathbf{a}_{ij}\big{)}\,\text{P}\big{(}\mathbf{ a}_{ij}\big{)}}{\text{P}(s_{i}=\text{CH})}\ =\ \frac{\prod_{j=1}^{z}\text{P}_{ij}\,\text{P}\big{(}\mathbf{a}_{ij} \big{)}}{\left[\text{P}(s_{i}=\text{CH})\right]^{z}} \tag{1}\]  
\[\text{P}(\mathbf{a}_{iz},\dots,\mathbf{a}_{iz}|s_{i}=\text{CM})=\sum_{j=1}^{z}\text{P }(\mathbf{  
Finally, we can write that:  
\[\mathrm{P}_{i}=\ \frac{1}{\mathrm{e}^{\ \mu}+1} \tag{10}\]