running_momentο
- plasmapy.analysis.time_series.running_moments.running_moment(signal, radius: int, moment: int = 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 + 1for running mean and4 * radius + 1for 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_momentiftimeis notNone.
- Return type:
- Raises:
ValueError β If
momentis not in (1, 2, 3, 4).ValueError β If
signalandtimedonβt have same length.ValueError β If
len(signal) <= 4 * radiusandmoment > 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])