# Distributed Global Function Model Finding for Wireless Sensor Network Data
## 4 Distributed Global Function Model Finding for Wireless Sensor Networks Data
### Global Model Generation Algorithm Based on Unconstrained Nonlinear Least Squares
\begin{array}{ccccc}\sum\limits_{i=1}^{k}C_{1i}^{2}&\sum\limits_{i=1}^{ k}C_{1i}C_{2i}&...&\sum\limits_{i=1}^{k}C_{1i}C_{ni}\\ \sum\limits_{i=1}^{k}C_{2i}C_{1i}&\sum\limits_{i=1}^{k}C_{2i}^{2}&...&\sum \limits_{i=1}^{k}C_{2i}C_{ni}\\...&...&...&...\\ \sum\limits_{i=1}^{k}C_{ni}C_{1i}&\sum\limits_{i=1}^{k}C_{ni}C_{2i}&...&\sum \limits_{i=1}^{k}C_{ni}^{2}\end{array} \right]\left[ \begin{array}{c}a_{1}\\ a_{2}\\...\\ a_{n}\end{array} \right]=\left[ \begin{array}{c}\sum\limits_{j=1}^{k}y_{j}C_{1 j}\\ \sum\limits_{j=1}^{k}y_{j}C_{2j}\\...\\ \sum\limits_{j=1}^{k}y_{j}C_{nj}\end{array} \right] \tag{8}\]  
Denote  
\[\left[ \begin{array}{ccccc}\sum\limits_{i=1}^{k}C_{1i}^{2}&\sum\limits_{i=1}^{ k}C_{1i}C_{2i}&...&\sum\limits_{i=1}^{k}C_{1i}C_{ni}\\ \sum\limits_{i=1}^{k}C_{2i}C_{1i}&\sum\limits_{i=1}^{k}C_{2i}^{2}&...&\sum \limits_{i=1}^{k}C_{2i}C_{ni}\\...&...&...&...\\ \sum\limits_{i=1}^{k}C_{ni}C_{1i}&\sum\limits_{i=1}^{k}C_{ni}C_{2i}&...&\sum \limits_{i=1}^{k}C_{ni}^{2}\end{array} \right]=B,\left[ \begin{array}{c}a_{1} \\ a_{2}\\...\\ a_{n}\end{array} \right]=X\text{, and }\left[ \begin{array}{c}\sum\limits_{j=1}^{k}y_{j}C_{1j}\\ \sum\limits_{j=1}^{k}y_{j}C_{2j}\\...\\ \sum\limits_{j=1}^{k}y_{j}C_{nj}\end{array} \right]=Y\]  
Then Equation (8) can be rewritten as \(BX=Y\). Because of the randomness of data acquisition and function model finding using GEP in wireless sensor networks, there are no two identical or proportional row vectors in the matrix \(B\) so that the determinant of matrix \(B\) is not equal to 0. According to definition of rank of a matrix, we have that \(R\left(B\right)=R\left(B|Y\right)=n\). Therefore, non homogeneous linear equations \(BX=Y\) exist unique solution \((a_{1},a_{2},...,a_{n})\). According to the theorem and deduction of the corresponding calculation of determinant [46], we have that \((a_{1},a_{2},...,a_{n})=(\dfrac{d_{1}  
```
Input: local Function Model \(f_{i}\left(X\right),i\in[1,n]\), \(k\) sample data; Output: global Function Model \(f(X)\); Begin {
1. double \(a_{1},a_{2},...,a_{n}\); // Defining \(n\) real variables. 2. Set \(f(X)=\sum\limits_{i=1}^{n}a_{i}f_{i}(X)\). //Building global function equation. 3. Set \(Q(a_{1},a_{2},...,a_{n})=\sum\limits_{i=1}^{k}\left(y_{i}-\sum\limits_{j=1}^{n }a_{j}f_{j}(X_{i})\right)^{2}\);//Building function model, where \(y_{i},i\in[1,k]\) is target value for \(k\) sample data. 4. \(k\) sample data \(\rightarrow\)\(Q(a_{1},a_{2},...,a_{n})\); // Substituting \(k\) sample data into \(Q(a_{1},a_{2},...,a_{n})\). 5. \(\frac{\partial Q}{\partial a_{i}}=0,i\in[1,n]\); // \(\left(a_{1},a_{2},...,a_{n}\right)\) is obtained by solving non homogeneous linear equations. 6. return \(f(X)\); // Substituting \((a_{1},a_{2},...,a_{n})\) into \(\sum\limits_{i=1}^{n}a_{i}f_{i}(X)\) and returning \(f(X)\). ```  
**Algorithm 3. GMG-UNLS**  
The time-consumption of GMG-UNLS focuses on solution of \((a_{1},a_{2},...,a_{n})\). The time complexity of GMG-UNLS is \(O(n^{3})\).