DSPRelated.com

Discrete Sums

The discrete integral

Same story as before. Real signals are sampled, not continuous. The discrete cousin of the integral is the sum. Just add up the samples, that's it.

The catch (and it's a tiny one) is that you usually multiply each sample by its width Δt first, to keep the units right. After that, summing is summing.

Sums as Discrete Integrals

Below is a sin(t) signal, drawn as a Riemann sum: each sample is a rectangle of width Δt and height x[n]. The total area of all rectangles is the discrete integral. The lower panel plots the running sum. Shrink Δt and the rectangles fuse into the smooth integral curve from the last lesson.

Each rectangle has height x[n] (the sample value) and width Δt (the sample spacing). The area of each rectangle is x[n]·Δt. Add them all up, and you have approximated the area under the curve, the integral.

Key Insight: The Riemann sum Σ x[n]·Δt is the discrete integral. As Δt → 0, it converges to the continuous integral ∫ x(t) dt. In real DSP, almost every formula written with ∫ becomes a Σ in code.

Shrink Δt and watch the running-sum trace converge onto the smooth integral curve (the faint overlay). They become indistinguishable. This is the entire idea behind numerical integration, and it's how a CPU computes any integral.

Try it: Set Δt to its maximum. The rectangles obviously over- and under-shoot the curve, and the running-sum trace zigzags around the true integral. Now shrink Δt. The two traces sit on top of each other. Toggle to "Dots" mode and you can see the same data presented as samples without rectangles, that's how DSP code actually thinks about it.

Why This Matters for DSP

This is the bridge from theory to code. Every DSP textbook integral formula becomes a sum when you write it in C, Python, or hardware. The continuous Fourier integral ∫x(t)·e−jωtdt becomes the DFT sum Σ x[n]·e−j2πkn/N. Same idea, sampled.

Convolution? A discrete sum. Correlation? A discrete sum. Filter output? A discrete sum. Signal energy? A discrete sum. All of DSP is, fundamentally, summing weighted samples.

We've now built the toolkit. The final lesson of this chapter brings it all together with the single most important kind of sum in DSP: the inner product, which is what happens when you multiply two signals together first, then sum. That's the operation hiding inside every filter and the entire DFT.

Frequently Asked Questions

Why multiply by Δt?

Each rectangle in the Riemann sum has area = height × width = x[n] × Δt. Without multiplying by Δt you are just adding sample values, which is useful for some operations (the textbook DFT formula omits it by convention) but is not strictly an area. Whether you include Δt depends on whether you need physical units.

Is Σ exactly equal to ∫?

Only in the limit Δt → 0. For real samples there is always an approximation error. For bandlimited signals sampled above Nyquist, the error can be made very small, so in practice we treat them as equivalent for most computations.

Do I always need to multiply by Δt in code?

Not always. For physical quantities (energy in joules, integrated voltage), yes. For pattern-matching operations like the DFT and correlation, the Δt is often absorbed into a normalization constant or omitted entirely — only the relative magnitudes between frequency bins matter. The key is to be consistent within a calculation.

Quick Check

Test your understanding of the key concepts from this lesson.