# Application and Optimization of Algorithms for Pressure Wave Evaluation Based on Measurement Data
## 4 Algorithms
The absolute differences \(D_{i,1}\) between predicted data point \(a\) and real data point \(b\) and \(D_{i,2}\) between predicted data point \(c\) and real data point \(d\) were calculated according to Equations (5) and (6):  
\[D_{i,1}(j)=p_{i}\big{(}t_{j}\big{)}-p_{i,1}^{*}\big{(}t_{j}\big{)} \tag{5}\]  
\[D_{i,2}(j)=p_{i}\big{(}t_{j+1}\big{)}-p_{i,2}^{*}\big{(}t_{j+1}\big{)} \tag{6}\]  
Then, point \(a\) with the smallest \(j\) for which the following conditions (Equations (7)-(9)) held, was selected as the PDTP:  
\[D_{i,1}(j)<0 \tag{7}\]  
\[D_{i,2}(j)<0 \tag{8}\]  
\[D_{i,1}(j)<D_{i,2}(j) \tag{9}\]  
The fourth algorithm was the linear algorithm (LNR algorithm, cp. Figure 4, middle right). A linear line was constructed from each point to every other point with \(t_{n+1}>t_{j}\) and \(p_{i}(t_{n+1})<p_{i}\big{(}t_{j}\big{)}\). At each point \(j\), the sum of the negative gradients \(g_{ij}(n)\) of the linear lines passing through this point was calculated. The PDTP was located at the point where the sum of all the gradients \(G_{i}(j)\) was at its maximum. For the calculation, Equations (10)-(12) were applied:  
\[M_{i,b}(j)=\sum_{n=j+1}^{N_{i}}\frac{p_{i}(t_{n})}{j} \tag{2}\]0  
\[M_{i,b}(j)=\sum_{n=j+1}^{N_{i}}\frac{p_{i}(t_{n})}{j} \tag{2}\]1  
\[M_{i,b}(j)=\sum_{n=j+1}^{N_{i}}\frac{p_{i}(t_{n})}{j} \tag{2}\]2  
The last self-developed algorithm was the moving linear regression algorithm (MLR algorithm, cp. Figure 4, bottom left) as number five. There were two main factors that influenced this algorithm. One of them was the location of the starting point, and the other one was the scaling factor \(s\). The starting point \(t_{max}\) for the algorithm was set to the maximum value \(p_{i,max}\) in the pressure data because a pressure drop should be detected and not an increase. From the starting point \(t_{max}\), two more data points, \(t_{max+1}\) and \(t_{max+2}\), were used for starting a moving linear regression \(p_{i}^{*}\) with \(\{t_{max},t_{max+1},t_{max+2}\}\). The permitted prediction interval for \(p_{i}^{*}\) was defined by the standard deviation \(\sigma_{i}^{*}\) of the used data points \(\{t_{max},t_{max+1},t_{max+2}\}\) for linear regression. The interval was expanded or reduced by the scaling factor \(s\) to optimize the prediction interval. The point \(j\) was checked by the following conditions according to Equation (13):  
\[M_{i,b}(j)=\sum_{n=j+1}^{N_{i}}\frac{p_{i}(t_{n})}{j} \tag{2}\]3  
If the checked point \(j\) was within this interval, it was not the PDTP. In addition, this point was also considered for the moving linear regression, and the next data point \(j+1\) was evaluated (which was then the new data point \(j\) to be checked). The moving linear regression \(p_{i}^{*}\) was calculated for \(\{t_{max},t_{max+1},t_{max+2},\ldots,t_{j-1}\}\). If the checked point \(j\) was not within the interval, this point could be the PDTP or an outlier. For an outlier, the next data point \(j+1\) had to be in the interval. In this case, both points were used for the moving linear regression (and \(j+2\) was the new data point \(j\) to be checked). However, if the point \(j+1\) was also outside of the interval, then the point \(j\) was the PDTP. The sixth algorithm was change-point estimation by a probabilistically pruned objective via the Kolmogorov-Smirnov statistic (KSS algorithm) [26]. For applying this algorithm, the R package \"ecp\" was used. The package was developed to be able to perform analyses of multiple change-points with as few assumptions as possible. Furthermore, the package is suitable for both univariate and multivariate observations. Hierarchical estimation is based on either a divisive or agglomerative algorithm. For divisive estimation, the change-pointsare identified sequentially via a bisection algorithm. The agglomerative algorithm estimates the location of change-points by determining an optimal segmentation. Both algorithms can detect any type of distributional change within the data.