WHY this formula? Ek linear time-invariant (LTI) system poori tarah se describe hota hai iss baat se ki woh ek single spike δ[n] par kaise respond karta hai — us response ko h[n] kaho (the impulse response). Koi bhi input scaled, shifted spikes ka sum hoti hai:
x[n]=∑kx[k]δ[n−k]. Linearity ki wajah se output bhi scaled, shifted responses ka wohi sum hoga → exactly convolution sum. Toh convolution arbitrary nahi hai: ye forced hai linearity + time-invariance ki wajah se.
HOW (the flip-and-slide):h ko flip karo, use x ke across slide karo, overlapping samples ko multiply karo, sum karo. Output length =len(x)+len(h)−1.
from scipy.signal import convolve, correlate, fftconvolveconvolve([1,2,3],[1,1]) # -> [1,3,5,3], 'full' by defaultconvolve(x, h, mode='same') # output same length as x (centered)fftconvolve(x, h) # SAME result, O(N log N) via FFT — fast for big arrays
WHY:e−i2πkn/N ek probe wave hai; sum ek inner product hai, toh ∣X[k]∣
tab bada hota hai jab x us wave se miltaa-julta ho. FFT bas saare X[k] ko
O(N2) ki jagah O(NlogN) mein compute karta hai.
import numpy as npfs = 1000 # Hz sampling ratet = np.arange(0, 1, 1/fs) # 1 sx = np.sin(2*np.pi*50*t) + 0.5*np.sin(2*np.pi*120*t)X = np.fft.rfft(x)f = np.fft.rfftfreq(len(x), d=1/fs) # frequency in Hzmag = np.abs(X)/len(x)*2 # *2 for one-sided amplitude# peaks appear at 50 Hz and 120 Hz
Ek LTI system apni impulse response se poori tarah describe kyun hota hai?
Koi bhi input = scaled/shifted spikes ka sum; linearity se output = scaled/shifted impulse responses ka same sum = convolution.
Len-M aur len-N arrays ki full convolution ki output length?
M+N−1
Convolution aur correlation mein kya fark hai?
Correlation kernel ko flip NAHI karta; template matching / alignment ke liye use hota hai.
Nyquist frequency?
fs/2 — aliasing ke bina represent karne layak highest frequency.
FFT frequency bin spacing?
Δf=fs/N
Convolution theorem?
x∗h↔X⋅H — time convolution = frequency multiplication.
FIR vs IIR?
FIR: output sirf past inputs se, hamesha stable, linear phase. IIR: past outputs se feedback, sasta lekin unstable ho sakta hai.
filtfilt vs lfilter?
filtfilt = forward+backward → zero phase; lfilter = causal lekin phase delay add karta hai.
80 Hz, fs=1000 ke liye normalised cutoff Wn?
80/(1000/2)=0.16
Large arrays ke liye fftconvolve, convolve se behtar kyun hai?
Convolution theorem use karta hai: O(N log N) FFTs + pointwise multiply vs O(N²) direct sum.
Do close frequency peaks resolve karne ke liye kya change karte ho?
Zyada der record karo (bada N) → chhota Δf. Faster sampling se resolution help nahi hoti.
Recall Feynman: explain to a 12-year-old
Socho ek chhoti stamp (kernel) ko stickers ki ek lambi strip (signal) par slide kar rahe ho,
aur har jagah dekh rahe ho kitna overlap hota hai — wahi hai convolution,
aur isi se hum cheezein blur ya smooth karte hain. Ek filter matlab ek aisi stamp chunna jo
jiggly fast bits mita de lekin slow shape rakhle. FFT ek jaaduyi prism jaisi hai: apni
wiggly signal usmein se gujaro aur woh use pure musical notes (frequencies) mein tod deta hai, toh
tum dekh sako "aha, yahan ek loud 50 Hz hum hai," aur phir us note ko zero kar do.