running_moment
- plasmapy.analysis.time_series.running_moments.running_moment(signal, radius: int, moment=1, time=None)[source]
Calculate either the running mean, standard deviation, skewness or excess kurtosis of a sequence.
- Parameters:
signal (1D array_like) – Signal to be averaged.
radius (int) – The number of points on either side of each point for which the running moment is being calculated. The window size is
2 * radius + 1
for running mean and4 * radius + 1
for higher moments.moment (int) –
Choose between:
1
: running mean2
: running standard deviation3
: running skewness4
: running excess kurtosis
time (1D array_like, optional) – Time base of
signal
.
- Returns:
Contains the following attributes:
run_moment
: 1D array_likeRunning moment of
signal
. The length is(len(signal) - 2 * radius)
for the running mean or(len(signal) - 4 * signal)
for higher moments.
time
: 1D array_likeTime base corresponding to
run_moment
iftime
is notNone
.
- Return type:
- Raises:
ValueError – If
moment
is not in (1, 2, 3, 4).ValueError – If
signal
andtime
don’t have same length.ValueError – If
len(signal) <= 4 * radius
andmoment > 1
.
Notes
The running rms divides by
window
, not(window - 1)
.Examples
>>> from plasmapy.analysis.time_series.running_moments import running_moment >>> running_moment([1, 2, 3, 2, 1], 1, 4, [1, 2, 3, 4, 5]) Running_Moment(run_moment=array([3.]), time=[3])