I have a time series data I want to smooth using Savitzgy Golay filter. According to resaerch here: https://arxiv.org/ftp/arxiv/papers/1808/1808.10489.pdf
Window size should be n+2 where n -> polyorder. I performed such smoothing on my data but I see no results in by signal. Have I chosen wrong window size?
My data is EMG signal with (50858, 2)
shape having t
and emg
columns, where emg is value to be denoised. Here is the head of it.
Filter implementation:
Y= data.iloc[:,1].values
Y_filtered= savgol_filter(Y, window_length = 5, polyorder = 3)
And plotting it:
plt.subplot(1, 2, 1)
plt.plot(Y[-1000:])
plt.title("EMG with noise")
plt.subplot(1, 2, 2)
plt.plot(Y_filtered[-1000:])
plt.title("SG filter applied ")
plt.tight_layout()
plt.show()
The window size is not restricted to be n+2
. It has to be odd, though. I have tried with window_size=21
and polyorder=3
and it works.
I think it is unlikely that you will see results with a window size = 5 in a multithousand samples signal, because probably your noise spans more samples. Give it a try and use a bigger window size.