Library / Signal processing and digital filters / DSP-21
Signal processing and digital filters
Linear convolution at a specified sample
One sample n of the full linear convolution of an input x (up to 6 samples) with a filter h (up to 4 taps), both indexed from zero and taken as zero outside their stored values.
- Ref
- DSP-21
- Rev
- v1
- Field
- Signal processing and digital filters
- Result
- y[n] [V]
One sample of the linear convolution of x with a filter h is y[n] = Σ h[j]x[n − j]: the current and past inputs weighted by the taps. Samples outside either stored vector count as zero. The full convolution has len(x) + len(h) − 1 samples, so n runs from 0 to len(x) + len(h) − 2.
One sample n of the full linear convolution of an input x (up to 6 samples) with a filter h (up to 4 taps), both indexed from zero and taken as zero outside their stored values. Leave unused entries at zero. Valid for 0 ≤ n ≤ len(x) + len(h) − 2.
Calculator
- Sum of the taps, Σh (the DC gain)0.5
- Sum of the inputs, Σx7 V
- Sum of all outputs, Σh × Σx3.5 V
What drives the result
Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.
- Output sample 2 is 3 V.
- The sum of all output samples is always the sum of the taps times the sum of the inputs, here 3.5 V, a quick check on a convolution routine.
Chart data as tables
Ranked variables
| Variable | Typical range | Lowest result | Highest result | Swing (V) | Local step | Change in result |
|---|---|---|---|---|---|---|
| x2 Input sample 2 | −10 to 10 V | −11 | 9 | 20 | +0.4 V | +13.3 % |
| h0 Filter tap 0 | −2 to 2 | −9 | 7 | 16 | +0.08 | +10.7 % |
| x1 Input sample 1 | −10 to 10 V | −1 | 9 | 10 | +0.4 V | −6.67 % |
| h1 Filter tap 1 | −2 to 2 | 0 | 8 | 8 | +0.08 | +5.33 % |
| n Output index | 0 to 8 | −2 | 3 | 5 | +1 | −167 % |
| h2 Filter tap 2 | −2 to 2 | 1 | 5 | 4 | +0.08 | +2.67 % |
| x0 Input sample 0 | −10 to 10 V | 3 | 3 | 0 | +0.4 V | 0 % |
| x3 Input sample 3 | −10 to 10 V | 3 | 3 | 0 | +0.4 V | 0 % |
| x4 Input sample 4 | −10 to 10 V | 3 | 3 | 0 | +0.4 V | 0 % |
| x5 Input sample 5 | −10 to 10 V | 3 | 3 | 0 | +0.4 V | 0 % |
| h3 Filter tap 3 | −2 to 2 | 3 | 3 | 0 | +0.08 | 0 % |
Sweep of Output index
| Output index | Convolution output (V) |
|---|---|
| 0 | 1 |
| 1 | 1.5 |
| 2 | 3 |
| 3 | −2 |
| 4 | 0 |
| 5 | 0 |
| 6 | 0 |
| 7 | 0 |
| 8 | 0 |
Sweep one variable
Variables and how each one contributes
Convolution output
What the equation gives you. Everything else feeds it.
Output index
The output index. Selects which output sample is computed; it picks different pairs of input and tap. Raising it by 10 % (to 2.2) moves the result by +0 %, from 3 to 3 V.
Input sample 0
The input sample x[0], in V. Is multiplied by tap h[n − 0] if that index exists. Raising it by 10 % (to 1.1) moves the result by +0 %, from 3 to 3 V.
Input sample 1
The input sample x[1], in V. Is multiplied by tap h[n − 1] if that index exists. Raising it by 10 % (to 2.2) moves the result by −3.33 %, from 3 to 2.9 V.
Input sample 2
The input sample x[2], in V. Is multiplied by tap h[n − 2] if that index exists. Raising it by 10 % (to 4.4) moves the result by +13.3 %, from 3 to 3.4 V.
Input sample 3
The input sample x[3], in V. Is multiplied by tap h[n − 3] if that index exists. Raising it by 10 % (to 0) moves the result by +0 %, from 3 to 3 V.
Input sample 4
The input sample x[4], in V. Is multiplied by tap h[n − 4] if that index exists. Raising it by 10 % (to 0) moves the result by +0 %, from 3 to 3 V.
Input sample 5
The input sample x[5], in V. Is multiplied by tap h[n − 5] if that index exists. Raising it by 10 % (to 0) moves the result by +0 %, from 3 to 3 V.
Filter tap 0
The filter tap h[0]. Weights the input sample x[n − 0]. Raising it by 10 % (to 1.1) moves the result by +13.3 %, from 3 to 3.4 V.
Filter tap 1
The filter tap h[1]. Weights the input sample x[n − 1]. Raising it by 10 % (to −0.55) moves the result by −3.33 %, from 3 to 2.9 V.
Filter tap 2
The filter tap h[2]. Weights the input sample x[n − 2]. Raising it by 10 % (to 0) moves the result by +0 %, from 3 to 3 V.
Filter tap 3
The filter tap h[3]. Weights the input sample x[n − 3]. Raising it by 10 % (to 0) moves the result by +0 %, from 3 to 3 V.
Worked example with the values above
- Index pairs with j + (n − j) = 2, kept when both exist.
- Terms: h[0]·x[2] = 1 × 4 = 4; h[1]·x[1] = −0.5 × 2 = −1; h[2]·x[0] = 0 × 1 = 0.
- y[2] = 3 V.
Assumptions and limits
- Finite real sequences indexed from zero and taken as zero outside their stored length.
- Equally spaced samples, and for the circular forms, periodic extension of both sequences.
Common mistakes
- Mixing up the linear and circular forms when an FFT is used.
- Reversing the lag convention for correlation.
- Dividing by N − ℓ where the biased form divides by N.
Statistics and uncertainty
Convolution and correlation sums are exact, so errors come from the data; a delay found from a correlation peak is limited to the sampling interval unless interpolated, and finite records bias the autocovariance by a factor of (N − ℓ)/N.
Where it is used
- Computing filter outputs, delays and covariance by hand for checks.
- Choosing block sizes for fast FFT-based filtering.
Maths you need
- Linear convolution: y[n] = Σ h[j] x[n − j]
- Circular convolution: the same sum with indices wrapped modulo N
- Correlation: a sliding product that measures similarity at each lag