Estimate the positions of the local extrema with a given time scale of a noisy time series

[n_j,kadd]=local_extrema(x,Deltan,ni,nf) Estimates the positions of the local extrema of a partition of scale Deltan of the part x(ni:nf) of the time series x as defined in Chapter 6 of the book Călin Vamoş, Maria Crăciun, Automatic Trend Estimation, Springer 2012.

An arbitrary nonmonotonic trend is composed by a succession of monotonic segments limited by its local extrema. A superposed noise breaks up the trend monotonic variations into many small fluctuations, but the global shape of the trend is recognizable because the trend local extrema have a larger time scale than those induced by noise. We have rigurously defined the time scale of a local extremum of a time series such that it allows a classification of the local extrema with respect to their importance for the global shape of the time series. The local extrema with scales greater than a given value provide a partition of a noisy time series in segments which approximate the monotonic parts of the trend contained in the time series.

The approximation of the local extrema of the trend by the estimated local extrema can be improved if before looking for local extrema the time series is smoothed by means of the moving average algorithm. The noise fluctuations are damped by averaging more strongly than the variations of the slowly varying trend. Then the shape of the averaged time series is closer to the trend shape than the shape of the unaveraged time series. However, we have to take into account that the trend is distorted by smoothing and several of its small local extrema may disappear.

MATLAB programs freely downloadable;

local_extrema.m implements the algorithm to construct a partition of a given time scale.
test_localextr.m tests the program local_extrema on artificial time series.