I would like to convolve a 1D signal with the first derivative kernel with variable window sizes. In other words, the linear regression of a moving window with a variable size. In python code:
def derivative_convolution(aSignal, iWindowSize):
"""
derivative of a signal by window size using kernel operator
"""
import numpy as np
aKernel = #???
return np.convolve(aSignal, aKernel, 'same')
Where aKernel is the kernel of variable window size that I am looking for.
For example, for 1D signals, the 1st derivative kernel is [-1,0,1]. Can the slope be calculated for a window size of 5 ([a,b,c,d,e])?
[[-1, 0, 1],[-2,0,2],[-1,0,1]], and for the second one:[[1, 0, -2, 0, 1],[4,0,-8,0,4],[6,0,-12,0,6],[4,0,-8,0,4],[1, 0, -2, 0, 1]]. - jojeknamount of datapoints. Hmm... - Roman