spkit.total_variation_win

spkit.total_variation_win(x, winlen=11, overlap=None, method='npdiff', **kwargs)

Total Variation of a signal window-wise

Returns:
tv_win: 1d-array,
  • Total Variation of x with window-wise

References

Examples

#sp.total_variation_win
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
x, fs = sp.data.optical_sample(sample=2)
x = x[int(0.0*fs):int(2*fs)]
tv_win = sp.total_variation_win(x,winlen=11)
plt.figure(figsize=(10,3))
plt.subplot(211)
plt.plot(x)
plt.subplot(212)
plt.plot(tv_win)
plt.tight_layout()
plt.show()
../../_images/spkit-total_variation_win-1.png