I am working on convolving chunks of a signal with a moving average type smoothing operation but having issues with the padding errors which affects downstream calculations.
If plotted this is the issue that is caused on the chunk boundaires.
To fix this I am adding N samples from the previous chunk to the beginning of the array.
The question is does the convolve operation below remove samples from the beginning or end of the original array?
arr = np.array([0.9, 0.9, 0.9, 0.1, 0.1, 0.1, 1.0, 0.1, 0.1, 0.1, 0.9, 0.9, 0.9, ])print(f"length input array {len(arr)}")result = np.convolve(arr, [1]*3, 'valid')/3print(f"length result array {len(result)}")print(result)plt.plot(result)I setup the above example to try to confirm adding samples to the beging of the array is the correct place but it did not help. The input length is 13, the output length is 11.
With overlap the convolve looks like:
result = np.convolve(np.concatenate(previous_samples[-2:], arr), [1]*3, 'valid')/3
