# The Online Identification of the Behaviour of Pollutants inside the Tunnel Tube
## 3 Methods of Recursive Identification
### Modification of the Recursive Least Squares Method  
To ensure stability, we derive a method with exponential forgetting. This modified parameter estimation method allows for tracking parameters that change over time [26]. The modified objective function is as follows (4):  
\[J(\hat{\theta})=\sum_{i=1}^{k}\lambda^{k-i}\Big{(}y(i)-w^{T}(i)\hat{\theta}(k )\Big{)}^{2},\ 0<\lambda\leq 1. \tag{4}\]  
The result is a recursive algorithm with exponential forgetting (5). \[ \begin{split}\varepsilon(k)&=y(k)-w^{T}(k)\hat{ \theta}(k-1)\\ \hat{\theta}(k)&=\hat{\theta}(k-1)+P(k)w(k)\varepsilon (k)\\ P(k)&=\frac{1}{\lambda}\Big{(}P(k-1)-\frac{P(k-1)w(k )w^{T}(k)P(k-1)}{\lambda+w^{T}(k)P(k-1)w(k)}\Big{)}.\end{split}  \tag{5}\]  
This modified algorithm emphasizes agreement with current data and reduces the influence of previous data, meaning it gradually forgets older data. However, a secondary undesirable effect arises--sensitivity to noise, particularly when the parameter \(\lambda\) is increased. The choice of \(\lambda\) is determined via a compromise between the ability to track changing parameters and the allowed sensitivity to noise. In most cases, the parameter \(\lambda\) is chosen in the interval <0.97, 0.995>, although the correct choice depends on the nature of the identified system and the sampling period. The number of stored samples can be approximately determined using the relationship, \(\frac{1}{1-\lambda}\), corresponding to the time constant associated with the parameter \(\lambda\). This algorithm can be used if the system parameters change slowly. The disadvantage of the derived algorithm (Equation (5)) with exponential forgetting is that if the input signal has small or zero values (not identifiable), the covariance matrix increases exponentially with time when \(\lambda<1\). This phenomenon is called wind-upestimation. The solution is not to update the covariance matrix when the input variable values \(u(k)\) are close to 0. At first, an s-function was written and used in Simulink to verify the operation of the derived algorithm. However, using the s-function was unsuitable because the compiler could not create code in C or C++ code when used in the Simulink model. Therefore, the s-function was rewritten as a Matlab function. The block titled 'estimator_d' is a subsystem within Simulink and contains a function created by the authors, in which all algorithms derived in this article are programmed. First, the algorithm was tested on deterministic system models with known parameters. The Simulink simulation scheme is in Figure 3.  
The representation of the simulation results of the recursive least squares method with exponential forgetting is shown in Figure 4. The two lower graphs present the behaviours during parameter variations in more detail. Parameters \(a_{0}\) to \(a_{2}\) have negative signs because the graph shows the vector of parameters. Figure 4: The trajectories of parameter estimation in the system using the exponential forgetting method (parameter variations). Figure 3: Simulink scheme for verifying the operation of the algorithm. The algorithm tracks changes in the system parameters but exhibits significant oscillations even with small parameter changes. Due to its noise sensitivity, it is unsuitable for identifying stochastic systems. The influence of a disturbance variable acting on the identified system's output causes the estimated parameter values to oscillate (Figure 5). One possible modification is to turn off identification selectively if the estimated parameters are correct. The size of the prediction error is monitored. The parameters will not be changed if the prediction error is within an acceptable range. A new parameter \(\alpha(t)\) is defined:  
\[\alpha(t)=\left\{ \begin{array}{l}1\ if\frac{1}{1+w^{T}(k)\cdot P(k)\cdot w(k )}\cdot\varepsilon^{2}(t)>\varepsilon^{2}(t)>0\\ 0\ in\ the\ opposite\ case\end{array} \right. \tag{6}\]  
The parameter \(\varepsilon\) is a small number. The parameter \(\alpha(t)\) was added to Equation (5):  
\[