Keywords

1 Introduction

Digital filters (DF) are often required to process measurement information obtained from real observation and control objects. This is a common problem during interpretation of measurement information: filtration, trend selection, derivation, forecasting, etc.

DF can be implemented as hardware or software solutions. Hardware implementation of DF should provide low result delay \( \Theta \) considering restrictions on smoothing inaccuracy \( \upsigma \). Software filtration allows minimizing \( \upsigma \); therefore, restrictions on \( \Theta \) should satisfy real-time mode requirements [1].

Mathematical methods of digital filtration are commonly based on frequency selection of input signals or on the methods of optimal filtering [2,3,4,5].

Characteristics of modern DF are high and can be determined both in time and frequency domains [6, 7]. The time domain requires accuracy of shape of an original signal during reconstruction; the main requirement in the frequency domain is to differentiate a passband from a stopband of any useful signal and noise. Reducing the space between the two bands leads to raise of DF degree [2, 4] and complexity of its design. To provide a desired allocation of a stopband and a passband without complexing filter structure, a recursive filter with infinite impulse response (IIR) can be used to develop DF of low degree. In addition, such filter can enable processing and interpreting information in a real-time mode.

DF can be modelled by using basis functions. Simple mathematical basis provides a solution for interpretation problems, like derivation or forecasting. Algebraic splines have well developed theoretical basis; however, they are hardly applicable in real-time systems and consequently cannot be use to model an IIR filter. B-splines [8,9,10,11,12] and P-splines [13,14,15,16,17] have better computational feasibility then algebraic splines but only when the choice of nodes is optimal. Node selection [18,19,20,21] and estimation of penalty parameters [22,23,24] are typical approaches to adapt a smoothing spline. However, although adaptation raises efficiency of splines significantly, it is a laborious procedure to be performed in real time.

In this paper a modification of a P-spline as a variational approach for grouped data is proposed [14, 17, 25,26,27]. Grouping data allows avoiding spline nodes selection; high computational feasibility of proposed method of obtaining recursive spline function parameters allows real-time application of DF. Besides, an improved visualization of spline application to data interpretation is ensued due to the analysis of spline frequency and time responses in the DF framework.

2 Approaches to Problem Solution

A sequence of values \( y(t_{i} ) \) measured at times \( t_{i} ,\,i = 1,\,2,\, \ldots , \) with a random noise \( \upxi(t_{i} ) \) is used as a model of an original signal:

$$ y(t_{i} ) = f(t_{i} ) +\upxi(t_{i} ) , { }M\left\{ {\left. {\upxi(t)} \right\}} \right. = 0, \, M\left\{ {\left. {\upxi^{2} (t)} \right\}} \right. =\upsigma_{\upxi}^{2} , \, M\left\{ {\left. {f(t),\,\upxi(t)} \right\}} \right. = 0. $$
(1)

A classic smoothing spline is obtained by a variational approach and provides a minimal norm of spline \( S(t) \) derivative. Spline coefficients are calculated by minimizing an extremum functional [1, 25] defined in an observation interval [a, b]

$$ J(S) =\uplambda \cdot \int\limits_{a}^{b} {[S^{{{\prime \prime }}} (t)]^{2} dt + \sum\limits_{i = 0}^{n} {[S(t_{i} ) - y(t_{i} )]^{2} } } , $$
(2)

where coefficient \( \uplambda \) determines a curvature penalty and spline \( S(t) \) is a penalized spline and has the form of a cubic polynomial for every i-th segment.

In cases when segments comply with data values, an excessive scheme with high computational costs is implemented. Therefore, the following modifications of the extremum functional (2) is proposed to enable functional implementation in a real-time:

  • the functional is defined for each i-th segment of the spline;

  • the functional is defined between data values \( t_{0}^{i} , \, t_{h}^{i} \) for \( h \) measurements in a group;

  • \( \uplambda \) is replaced with multipliers \( \rho \) and 1 − ρ and normed as proposed in [17];

  • multiplier \( (h\Delta t)^{2} \) is included in the functional in order to provide compliance of summands dimensionalities;

$$ J(S) = (1 -\uprho)(h\Delta t)^{2} \int\limits_{{t_{0}^{i} }}^{{t_{h}^{i} }} {[S^{\prime\prime}(t)]^{2} dt +\uprho\sum\limits_{j = 0}^{h} {[S(t_{j}^{i} ) - y(t_{j}^{i} )]^{2} } } . $$
(3)

Then, parameter \( \rho \in [0,\,1] \) obtains significance: interpolating properties of the spline can be increased by increasing \( \rho \) up to 1; smoothness of the spline can be increased by decreasing \( \rho \) down to 0.

Therefore, a P-spline for the i-th segment can be written as follows:

$$ S_{i} (\uptau)\, = \,a_{0}^{i} + a_{1}^{i} \cdot\uptau\, + \,a_{2}^{i} \cdot\uptau^{2} \, + \,a_{3}^{i} \cdot\uptau^{3} , \, - q\, \le \,\uptau\, \le \,h\, - \,q, $$

where \( q \) - the number of value \( t_{j}^{i} \) inside the i-th segment \( \left( {j\, = \,\overline{0,\,h} ; \, q = \overline{0,\,h\, - \,1} } \right) \), in which continuous derivatives of the spline \( S^{(k)} (t_{q + 1}^{i - 1} )_{ + } = S^{(k)} (t_{q}^{i} )_{ - } \) are joint, \( k = 0.1 \) for defect 2 and \( k = 0 \) for defect 1. Discontinuous coefficients \( a_{2}^{i} ,a_{3}^{i} \) are calculated from the expression (3) minimizing condition \( \frac{\partial J(S)}{{\partial a_{2}^{i} }} = 0, \, \frac{\partial J(S)}{{\partial a_{3}^{i} }} = 0 \). Allocation of computation points \( (\uptau) \) and junction points (q) for the i-th segment results in several computation schemes for a recursive spline [1].

Let \( q = 1, \,\uptau = \overline{1,\,h} \). Recursive formulas of spline coefficients are given in [25].

3 Using a P-spline as a Digital Filter

A difference equation of DF links sequences of input data \( \{ y(t_{j}^{i} )\} , \, j = \overline{0,\,h} \) and output data \( S(t_{\uptau}^{i} ), \,\uptau = \overline{1,\,h} \) and can be used to derive a transfer function.

Let us assume that \( S_{i} = S(t_{\uptau}^{i} ) \), then \( \, S_{{i -\uptau}} = S(t_{\uptau}^{i - 1} ) = a_{0}^{i} , \, S_{{i -\uptau}}^{{\prime }} = S^{{\prime }} (t_{\uptau}^{i - 1} ) = a_{1}^{i} \). Considering all previously made designations, an equation of a P-spline for the i-th segment can be written as follows:

$$ \upgamma_{0} S_{i} -\upgamma_{1} (\uptau)S_{{i -\uptau}} -\upgamma_{2} (\uptau)\,S_{{i -\uptau}}^{{\prime }} =\upgamma_{3} (\uptau)\sum\limits_{k = i}^{i + h} {y_{{k -\uptau}} (k -\uptau)^{2} } \, + \,\upgamma_{4} (\uptau)\sum\limits_{k = i}^{i + h} {y_{{k -\uptau}} (k -\uptau)^{3} } , $$
(4)

where

$$ \upgamma_{0} = BC - A^{2} ; \,\upgamma_{3} (\uptau) =\uprho(\uptau^{2} C -\uptau^{3} A); \,\upgamma_{4} (\uptau) =\uprho(\uptau^{3} B -\uptau^{2} A); $$
$$ \upgamma_{1} (\uptau) =\upgamma_{0} +\uprho \uptau ^{2} (AH_{3} - CH_{2} ) +\uprho \uptau ^{3} (AH_{2} - BH_{3} ); $$
$$ \upgamma_{2} (\uptau) =\upgamma_{0}\uptau +\uprho \uptau ^{2} (AH_{4} - CH_{3} ) +\uprho \uptau ^{3} (AH_{3} - BH_{4} ). $$
$$ A = 6(1 - {\uprho })h^{4} + {\uprho }H_{5} ;\,B = 4(1 - {\uprho })h^{3} + {\uprho }H_{4} ;\,C = 12(1 - {\uprho })h^{5} + {\uprho }H_{6} ;\,H_{n} = \sum\limits_{k = 0}^{h} {k^{n} } $$

Equation (4) is a difference equation of degree \( \uptau,\,\uptau \in [1,\,h] \) with variable parameters \( \upgamma_{j} (\uptau), \, j = \overline{1,\,4} \). However, in this paper we will consider a moment of computing \( \uptau \) as a constant value for different segments of the spline. Consequently, coefficients \( \upgamma_{j} (\uptau), \, j = \overline{1,\,4} \) will be constant for each segment of the spline and Eq. (4) will be a difference equation of degree \( \uptau \) with constant parameters.

4 Examining Frequency and Time Responses of a Recursive Spline Filter

Frequency transfer functions (complex transfer coefficients) and impulse weight functions give a complete set of information about the quality of linear dynamic systems. In a similar way, DF can be described with system and instrumental functions of the filter [2,3,4,5].

Laplace images of the left \( S(z) \doteq S_{i} \) and the right \( Y(z) \doteq y(t_{\uptau}^{i} ) \) parts of Eq. (4) were derived in order to find a system (transfer) function \( W(z) = \frac{S(z)}{Y(z)} \) of the spline filter. Then, \( H(\upomega) = W(e^{{j\upomega\Delta t}} ) \) can be written as follows considering properties of lattice functions and assuming that \( z = e^{{j\upomega}} \, \), \( \, \Delta t = 1 \):

$$ H({\upomega }) = \frac{{\sum\limits_{k = 0}^{h} {e^{{(k - {\uptau }){\upomega }}} \cdot \left( {(k - {\uptau })^{2} {\upgamma }_{3} + (k - {\uptau })^{3} {\upgamma }_{4} } \right)} }}{{{\upgamma }_{0} - {\upgamma }_{1} e^{{ - {\upomega \tau }}} - {\upgamma }_{2} {\upomega }e^{{ - {\upomega \uptau }}} }} $$
(5)

Frequency characteristics \( H(\upomega) \) is periodic with a period equal to \( \frac{{2\uppi}}{\Delta t} \) because of the periodicity of function \( e^{{j\upomega\Delta t}} \) [2,3,4]. Therefore, DF should be examined in the range of the main frequencies \( \left[ {\frac{{ -\uppi}}{\Delta t},\,\frac{\uppi}{\Delta t}} \right] \) to obtain a complete set of information about its quality. Characteristics of discrete and continuous filters comply and aliasing effect is insignificant in this range.

Frequency characteristics \( H(\upomega) = A(\upomega) \cdot e^{-j\upvarphi}(\upomega) \) can be represented as amplitude-frequency characteristics (AFC) \( A(\upomega) = \left| {H(\upomega)} \right| \) and phase-frequency characteristics (PFC) \( {\upvarphi }(\upomega ) = \arg \left[ {H(\upomega )} \right] \).

Numerical analysis of DF properties with AFC and PFC allows examining selective features of a spline filter in dependence on its parameters: the number of measurements in group \( h \), a smoothing multiplier ρ and the moment of computation \( \uptau \). Figure 1 show sets of AFC and PFC for different basic parameters of the spline. Figure 1a, c and e demonstrate AFC dependence on \( \uprho\, \in \,[0,\,1] \), \( h\, \in \,[3,\,20] \), \( \uptau\, \in \,[1,\,h] \); Fig. 1b, d and f depict AFC and PFC for several values of spline-filter parameters.

Fig. 1
figure 1

AFC and PFC of a recursive filter (P-spline) (a), (b) \( h = 10, \,\uptau = 1 \); (c), (d) \( \uptau = 1, \,\uprho = 0.5 \); (e), (f) \( h = 10, \,\uprho = 0.5 \)

Spline-filter is a low-frequency filter and can be described with a dynamic element of the second degree according to its AFC. Peaks of AFC occur at some parameter values \( (\uprho = 0.1, \, h = 3, \,\uptau = h) \). PFC of the spline filter is of a feed-forward type because of grouping of input data [25]. PFC delay is registered at \( \uptau \to h \) (see Fig. 1f).

A passband is the main selective parameter of DF. The influence of the length of a spline segment \( h \) on the passband is the most significant; influence of parameters τ and ρ is less significant. A signal passband narrows by increasing \( h \) because the spline becomes smoother, however, the transfer coefficient decreases and error grows.

This feature of the spline filter is confirmed by the analysis of IF width as shown in Fig. 2a. At low h, inertness of the spline drops and its AFC complies with AFC of an interpolation spline to a greater extent. \( A(\upomega ) = 1, \upvarphi (\upomega ) = 0 \) for an ideal filter in a previously determined band of frequencies.

Fig. 2
figure 2

Instrumental function of recursive filter (P-spline) (a) \( h \in [3,\,20], \,\uprho \in [0,\,1] \); (b) \( \uptau = 1, \, h = 10 \); (c) \( h = 10, \,\uprho = 0.6 \), (d)

A passband in a frequency domain corresponds to the width of the time-domain instrumental function \( g(t) \) (IF) as an analogue of impulse weight function for linear dynamic systems. Impulse response of the spline filter can be derived symbolically as:

$$ g(t) = \frac{1}{{2{\uppi }}}\int\limits_{ - \infty }^{\infty } {H({\upomega })e^{{j{\upomega }t}} d{\upomega }}. $$
(6)

Dependence between the form and properties of IF and the parameters of the spline is shown in Fig. 2. IF attenuates in the whole range of parametric variations. The width of IF \( \Delta (\rho ,h) \) is determined by frequency characteristics of the spline and is inverse proportional to the passband of DF (see Fig. 2a); besides, it is also determined by the length of a spline segment h. Dependence of IF on smoothing parameter ρ is insignificant; the moment of computation π determines causality of the spline filter. Causality \( g(t) = 0, \, t < 0 \) is satisfied only for zero delay in DF: \( \uptau = h \) (see Fig. 2c and d) and \( \uptau < h \) \( g(t) \ne 0 \), which leads us to processing data in groups.

Similar to any other recursive algorithms, a recursive DF requires that the stability of the computational scheme is analyzed. Stability domains of the computational scheme in the space of spline parameters were determined with the help of discrete Hurwitz criteria. The obtained results show that the stability domain is independent from the moment of spline computation and narrows when the joint parameter q increases. It should be noted, that if \( q \le \frac{h}{2} \), then the spline is stable for all values of the smoothing multiplier ρ; if \( q > \frac{h}{2} \), then spline stability requires \( \uprho \in [0.99,\,1] \) and the spline reduces to recursive least squares method (LSM); finally, if \( q = h - 1 \), then the spline filter is instable for all values of its parameters.

5 Results of Computational Experiment

Frequency analysis showed the dependence between spline parameters and selective properties of DF, which should be proven on a computational example of function restoring. A common function for such purposes is the function that describes the Doppler effect [15, 27]

$$ f(t) = 5\sqrt {t(t - 1)} \cdot \sin \left( {2\uppi\frac{(1 + 0.05)}{t + 0.05}} \right) . $$
(7)

Similar to [15], function (7) is defined on the interval \( [0,\,1] \) with n discrete values and additive noise \( \upxi(t), \, N_{\upxi} (0,\,0.2^{2} ) \), \( y(t_{i} ) = f(t_{i} ) +\upxi(t_{i} ) \) as shown in Fig. 3.

Fig. 3.
figure 3

Doppler function (red trend) and the function restored by the P-spline in a real-time mode (green trend) (Color figure online)

Mathematical processing of this function is complicated by significant variations of frequency and amplitude. However, this function describes multiple processes in medicine, optics and a number of other applied sciences where the Doppler effect is used (change in wave length for an observer who is moving relative to the wave source).

Figure 3 shows the examples of restoring the Doppler function with the proposed P-spline in a real-time mode. Function (7) is defined on interval \( [0,\,1] \) in 400 discrete values (see Fig. 3a). Figure 3b demonstrates a high-frequency fragment of the function in 120 discrete values.

Histograms of the remainders for the restored Doppler function under noise and variation of spline parameters ρ, h are shown in Fig. 4.

Fig. 4.
figure 4

Histograms of remainders of a restored function (7)

Values of remainders prove that spline parameters influence inaccuracy of the spline filter. The width of IF (Fig. 2a) and spline approximation inaccuracy rise when spline smoothness increases, i.e. a group size h grows and a smoothing parameter ρ decreases.

The obtained quality of function restoring given in Fig. 3 is comparable with the best results for adaptive P-splines described in [15]. Adaptive P-splines are averagely 1.5 times more accurate than the proposed spline; however, the main advantage of the proposed spline is that it can be implemented in a real-time mode.

6 Conclusion

The paper represents a recursive P-spline as a digital filter with an infinite impulse response and variable parameters. The system function of the filter, which was derived symbolically, allowed examining frequency characteristics of the spline-filter. Despite parametric variations, the spline-filter operates as a low-frequency filter. Selective properties of the spline-filter are well illustrated by the width of its instrumental function, which depends significantly on some parameters of the spline. Examination of the main parameters of the P-spline showed, that the passband of the filter is highly influenced by the number of measurements in the spline segment h (the number of non-recursive elements of the difference equation). The results of frequency analysis of the spline-filter were proved by a numerical experiment of restoring the Doppler function in a real-time mode.