pyhctsa.operations.stationarity.std_nth_deriv_change

pyhctsa.operations.stationarity.std_nth_deriv_change(y, maxd=10)

How the output of std_nth_deriv() changes with the order of the derivative.

Computes std_nth_deriv(y, n) (the standard deviation of the nth difference of the time series) for orders n = 1, …, maxd, and characterizes how it varies with n in two ways: by an exponential fit, and directly through the order at which it is smallest.

An exponential function, f(x) = a*exp(b*x), is fitted to the variation across successive derivatives: regular signals decrease, irregular signals increase. This exponential-decay/growth picture only holds when std(diff(y, n)) is monotonic across n. Many real (especially oversampled/smooth) series instead show successive differencing reduce the standard deviation up to some order (removing trend or nonstationary drift) before over-differencing increases it again: a classic Box-Jenkins ARIMA-order-selection U-shape that a monotonic exponential cannot represent. minOrder, minOrderInterp, minRatio, overDiffRatio and isInterior characterize this directly, alongside the exponential fit. The exponential is fitted by least squares with bf_exp_fit() (the global optimum over rates |b| <= 40 / (maxd - 1), with no starting point to choose); if it cannot be fitted (e.g. a constant curve), the fexp_* outputs are NaN and the others are still returned.

Operation inspired by a comment in a comp.soft-sys.matlab (MATLAB newsgroup) posting: “You can measure the standard deviation of the n-th derivative, if you like.” (Vladimir Vassilevsky, DSP and Mixed Signal Design Consultant).

Parameters:
y : array-like

The input time series.

maxd : int, optional

The maximum derivative (difference) order to take. Default is 10.

Returns:

  • ‘fexp_a’, ‘fexp_b’, ‘fexp_r2’, ‘fexp_rmse’: the parameters a and b, the R^2, and the root-mean-square error of the exponential fit f(n) = a*exp(b*n),

  • ’minOrder’: the order (1 to maxd) at which the standard deviation is smallest,

  • ’minOrderInterp’: that order refined between integers by a parabola through the three points around the minimum (equal to minOrder if the minimum is at either end),

  • ’minRatio’: the smallest standard deviation divided by that at order 1,

  • ’overDiffRatio’: the standard deviation at order maxd divided by the smallest,

  • ’isInterior’: 1 if the minimum is strictly between order 1 and maxd (a U shape), else 0.

NaN if the time series is too short to take maxd differences.

Return type:

dict