spkit.conv1d_fft

spkit.conv1d_fft(x, y)

1D Convolution using FFT

Parameters:
x,y: arrays
  • input signals

Returns:
z = convolution of x and y

Notes

#TODO

References

Examples

#sp.conv1d_fft
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
fs=100
seed=100
x = sp.create_signal_1d(n=200,seed=seed)
t = np.arange(len(x))/fs
kernel = sp.gaussian_kernel(window_length=11)
y1 = signal.convolve(x.copy(),kernel, method='auto',mode='same')
y2 = sp.conv1d_fft(x.copy(),kernel)
y2x = y2[len(kernel)//2:len(kernel)//2+len(x)]
plt.figure(figsize=(12,3))
plt.plot(t,x,label='x: signal')
plt.plot(t,y1,label='y1: conv')
plt.plot(t,y2x,label='y2: conv FFT')
plt.xlim([t[0],t[-1]])
plt.ylabel('signal')
plt.grid()
plt.legend(loc = 'upper left')
plt.tight_layout()
plt.show()