Functions

Recursive high-order statistics for Python.

copyright:

2022 Claudio Satriano <satriano@ipgp.fr>

license:

GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html)

rhos.rec_mean_py(signal, C)[source]

Recursive mean of a signal, pure Python implementation.

μ[i] = C·signal[i] + (1-C)·μ[i-1]

Parameters:
  • signal (TypeVar(ArrayLike)) – signal to compute recursive mean for

  • C (float) – decay constant, in the [0, 1] interval

Returns:

the recursive mean, with the same length than signal

Return type:

ndarray

Raises:

ValueError – if C is not in the [0, 1] interval

Warning

This is a pure python reference implementation. Use rec_mean() for a faster implementation.

rhos.rec_mean(signal, C)[source]

Recursive mean of a signal.

μ[i] = C·signal[i] + (1-C)·μ[i-1]

Parameters:
  • signal (TypeVar(ArrayLike)) – signal to compute recursive mean for

  • C (float) – decay constant, in the [0, 1] interval

Returns:

the recursive mean, with the same length than signal

Return type:

ndarray

Raises:

ValueError – if C is not in the [0, 1] interval

Note

Fast implementation, using scipy.signal.lfilter().

rhos.rec_variance_py(signal, C, definition=0)[source]

Recursive variance of a signal, pure Python implementation.

Defined as in Poiata et al. [2016] (definition 0):

σ²[i] = C·(signal[i]-μ[i-1])² + (1-C)·σ²[i-1]

Or, defined as in Langet et al. [2014] (definition 1):

σ²[i] = C·(signal[i]-μ[i])² + (1-C)·σ²[i-1]

For both definitions:

μ[i] = C·signal[i] + (1-C)·μ[i-1]

Parameters:
  • signal (TypeVar(ArrayLike)) – signal to compute recursive variance for

  • C (float) – decay constant, in the [0, 1] interval

  • definition (int) – which formula to use

Returns:

the recursive variance, with the same length than signal

Return type:

ndarray

Raises:

Warning

This is a pure python reference implementation. Use rec_variance() for a faster implementation.

rhos.rec_variance(signal, C, definition=0)[source]

Recursive variance of a signal.

Defined as in Poiata et al. [2016] (definition 0):

σ²[i] = C·(signal[i]-μ[i-1])² + (1-C)·σ²[i-1]

Or, defined as in Langet et al. [2014] (definition 1):

σ²[i] = C·(signal[i]-μ[i])² + (1-C)·σ²[i-1]

For both definitions:

μ[i] = C·signal[i] + (1-C)·μ[i-1]

Parameters:
  • signal (TypeVar(ArrayLike)) – signal to compute recursive variance for

  • C (float) – decay constant, in the [0, 1] interval

  • definition (int) – which formula to use

Returns:

the recursive variance, with the same length than signal

Return type:

ndarray

Raises:

Note

Fast implementation, using scipy.signal.lfilter().

rhos.rec_hos_py(signal, C, order=4, var_min=-1, definition=0)[source]

Recursive high order statistics (hos) of a signal, pure Python implementation.

Defined as in BackTrackBB (definition 0):

hos[i] = C·(signal[i]-μ[i-1])ⁿ / (σ²[i])ⁿᐟ² + (1-C)·hos[i-1]

with

σ²[i] = C·(signal[i]-μ[i-1])² + (1-C)·σ²[i-1]

Note

This is the actual implementation in the BackTrackBB source code, which does not correspond to equation 7 of Poiata et al. [2016] or equation 1 of Poiata et al. [2018].

Or, defined as in Langet et al. [2014] (definition 1):

hos[i] = C·(signal[i]-μ[i])ⁿ / (σ²[i])ⁿᐟ² + (1-C)·hos[i-1]

with

σ²[i] = C·(signal[i]-μ[i])² + (1-C)·σ²[i-1]

For both definitions:

μ[i] = C·signal[i] + (1-C)·μ[i-1]

Parameters:
  • signal (TypeVar(ArrayLike)) – signal to compute recursive hos for

  • C (float) – decay constant, in the [0, 1] interval

  • order (int) – hos order

  • var_min (float) – values of variance σ² (hos denominator) smaller than var_min will be replaced by var_min

  • definition (int) – which formula to use

Returns:

the recursive hos, with the same length than signal

Return type:

ndarray

Raises:

Warning

This is a pure python reference implementation. Use rec_hos() for a faster implementation.

rhos.rec_hos(signal, C, order=4, var_min=-1, definition=0)[source]

Recursive high order statistics (hos) of a signal.

Defined as in BackTrackBB (definition 0):

hos[i] = C·(signal[i]-μ[i-1])ⁿ / (σ²[i])ⁿᐟ² + (1-C)·hos[i-1]

with

σ²[i] = C·(signal[i]-μ[i-1])² + (1-C)·σ²[i-1]

Note

This is the actual implementation in the BackTrackBB source code, which does not correspond to equation 7 of Poiata et al. [2016] or equation 1 of Poiata et al. [2018].

Or, defined as in Langet et al. [2014] (definition 1):

hos[i] = C·(signal[i]-μ[i])ⁿ / (σ²[i])ⁿᐟ² + (1-C)·hos[i-1]

with

σ²[i] = C·(signal[i]-μ[i])² + (1-C)·σ²[i-1]

For both definitions:

μ[i] = C·signal[i] + (1-C)·μ[i-1]

Parameters:
  • signal (TypeVar(ArrayLike)) – signal to compute recursive hos for

  • C (float) – decay constant, in the [0, 1] interval

  • order (int) – hos order

  • var_min (float) – values of variance σ² (hos denominator) smaller than var_min will be replaced by var_min

  • definition (int) – which formula to use

Returns:

the recursive hos, with the same length than signal

Return type:

ndarray

Raises:

Note

Fast implementation, using scipy.signal.lfilter().