【发布时间】:2020-08-02 21:31:35
【问题描述】:
我申请了Pandas.rolling().median(),它有一个延迟或相移(绿线)。
如果我使用Scipy.signal.medfilt(),结果不会移动(黄线)。
为什么,结果不一样?
附:我试图研究使用 sigtools._order_filterND 的 medfilt 实现,我认为它不在 python 中。
代码:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import medfilt
x = np.zeros(100)
x[30:70] = 2
x+= .1 * np.random.randn(100)
y1 = medfilt(x, kernel_size=5)
plt.plot(x, '.-', label='original signal');
plt.plot(y1, '.-', alpha=.5, label='medfilt');
plt.plot(pd.Series(x).rolling(5).median(), label='rolling window');
plt.legend();
【问题讨论】:
标签: pandas scipy filtering signal-processing smoothing