# Data-Driven Fault Detection and Diagnosis: Challenges and Opportunities in Real-World Scenarios
## Appendix B  
[PERSON], [PERSON], & [PERSON] [62] introduced the concept of recursive density estimation (RDE) in the context of detection and object tracking in video streams. Aiming to decide whether a pixel belongs to the background or the foreground in real time, the introduced approach substitutes the standard Gaussian kernel adopted for modeling the pixel probability density function (pdf) with the Cauchy function, which allows the recursive estimation of pixel pdf as a new image frame occurs. In [PERSON] et al. (2015), concepts of RDE theory are adopted in the context of online fault detection in order to discover anomalous behaviors. The parameters involved are the global density, the mean value, and the scalar product, which can be recursively computed by Equation (A2), Equation (A3), and Equation (A4), respectively. \[D(x_{k})=\frac{1}{1+\left\|x_{k}-\mu_{k}\right\|^{2}+\Sigma_{k}-\left\|\mu_{k} \right\|^{2}}\] (A2)  
\[\mu_{k}=\frac{k-1}{k}\mu_{k}+\frac{1}{k}x_{k}\] (A3)  
\[\Sigma_{k}=\frac{k-1}{k}\Sigma_{k}+\frac{1}{k}\left\|x_{k}\right\|^{2}\] (A4)  
where \(x_{k}\in\mathbb{R}^{n}\) is the feature vector at the time stamp \(k\). At the first iteration \(k=1\), the parameters are initialized as \(D(x_{1})=1\), \(\mu_{1}=x_{1}\), \(\Sigma_{1}=\left\|x_{1}\right\|^{2}\). Then, for each \(k>1\), the parameters are updated, and the condition expressed in Equation (A5) is checked to decide whether the current point represents an anomaly or not:  
\[IF\;D(x_{k})<\mu_{D}\;\;for\;k=t_{1},\ldots,k-1,k\;\;\;THEN\;x_{k}\;is\;an\; anomaly\] (A5)  
where:  
\[\mu_{D}=\left(\frac{ks-1}{ks}\mu_{D}+\frac{1}{ks}D(x_{k})\right)(1-\Delta_{D}) +D(x_{k})\Delta_{D}\] (A6)  
is the mean value of the local density computed recursively, \(\Delta_{D}=\left|D(x_{k})-D(x_{k-1})\right|\) is the absolute value of the difference between the global density computed at two consecutive time stamps, and \(ks\) is the number of data samples from the last status change. Indeed, if the condition is satisfied, then the status of the system switches from normal to anomalous, and \(ks\) is set to 0. The condition expressed in Equation (A5) means that, if the global density is lower than the mean density for a certain number of time stamps (or seconds), the status becomes anomalous. Indeed, when a new data point arrives, if it is close to the previous point, then \(\mu_{k}\) is close to the \(x_{k}\), \(D(x_{k})\) stays close to 1, and \(\mu_{D}\) stays close to the actual mean of the data points, as \((1-\Delta_{D})\) is very close to 1, which gives more importance to the first term of Equation (A6). However, when the new point is far from the previous ones, \(D(x_{k})\) slightly decreases, while \(\mu_{D}\) becomes closer to \(D(x_{k})\), as the term \(\Delta_{D}\) gives more importance to the second term of Equation (A6). As new points are closer to the previous point, then \(D(x_{k})\) continues to decrease until the condition in Equation (A5) is satisfied. Note that, when the status changes from normal to anomalous, \(ks\) is set to 0, leading \(\mu_{D}\) to notably decrease. When the mean density is lower than the global density for a certain number of points, or seconds, the status returns to the normal condition. Thus, the condition expressed by Equation (A7) applies:  
\[IF\;D(x_{k})>\mu_{D}\;\;for\;k=t_{2},\ldots,k-1,k\;\;\;THEN\;x_{k}\;is\; \text{normal}\] (A7)  
Note that both \(t_{1}\) in Equation (A5) and \(t_{2}\) in Equation (A7) are set by the user and may represent either the data samples or seconds. Based on the concepts of RDE, a clustering algorithm has also been introduced in [54], in both offline and online versions. Here, the online version will be briefly described.