spkit.conv1d_fb

spkit.conv1d_fb(x, kernel, iterations=1, mode='same', return_full=False)

1D Forward-Backward-Convolution (ConvFB)

1D Forward-Backward-Convolution (ConvFB)

Parameters:
x: np.array (n,)
  • signal

kernel: kernel to be used
iterations >=1,
  • applying conv_fb recursively

return_full: bool,
  • if true, it will return 3 times of length of signal

Returns:
y: output signal

Examples

#sp.conv1d_fb
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
fs=100
seed=1
x = sp.create_signal_1d(n=200,seed=seed)
np.random.seed(seed)
x = sp.add_noise(x,snr_db=0)
np.random.seed(None)
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_fb(x.copy(),kernel,iterations=2)
plt.figure(figsize=(12,3))
plt.plot(t,x,label='x: signal')
plt.plot(t,y1,label='y1: conv')
plt.plot(t,y2,label='y2: conv_fb, itr=2')
plt.xlim([t[0],t[-1]])
plt.ylabel('signal')
plt.grid()
plt.legend(loc = 'upper left')
plt.tight_layout()
plt.show()