Where a signal becomes a number

An exact answer to a different question

The reconstruction that turns samples back into a signal is normally introduced as the thing that recovers what was there. Measured on both sides of half the sample rate it does something more interesting than failing: above the boundary it returns the alias to 1.6 parts in a thousand, which is the same accuracy it returns the input with below the boundary, and it is wrong about the input by twice the amplitude. Its error is not a degradation. It is exactness about something else.

Assumes: The frequency a sample rate invents · Every model has an edge

The previous essay showed two signals producing one set of samples and stopped there. That is the whole identity, but it leaves a question a reader is entitled to ask: if the samples are ambiguous, what exactly does the machine that turns them back into a signal produce? Something averaged? Something distorted? Something with an obvious artefact in it that a careful engineer would notice?

None of those. It produces the alias, to the same accuracy it produces the input with when the input is inside the band — and that is a stronger and less comfortable statement than “aliasing degrades the signal”.

What the reconstruction returns, either side of 5.0 kHzcomputed by solving, not by drawing. The Whittaker–Shannon sum is evaluated on the samples and compared with two things: the signal that was sampled, and the frequency the samples report. Below 5.00 kHz these are the same curve and the error is 4.88e-3 — the truncation of the sum at sixty-four samples either side, and nothing else. Above it they part: at 9.00 kHz the reconstruction is 1.59e-3 from the alias and 2.000 from the input. The small number is the interesting one. A reconstruction cannot be improved into the right answer, because it is already an exact answer to a different question.100µ1m10m100m1input frequency (kHz)worst error of the reconstruction0.512510half the rate, 5.00 kHzfrom the signal that was sampledfrom the frequency the samples reportsample rate10.0 kHzinput9.00 kHzfrom the input2.000from the alias1.59e-3solved, then checked — the sum, twiceexact about the wrong signal above 5.00 kHz
Fig. 1 The worst error of the reconstruction, measured against two references at once: the signal that was sampled, and the frequency the samples report. Below 5 kHz these are the same curve. Above it the lower curve stays where it was and the upper one goes to two — the whole amplitude of the signal. The slider walks the input across the boundary.

The sum, and what it is being asked

The reconstruction the sampling theorem prescribes is the Whittaker–Shannon sum: place a sinc function at every sample instant, scale each by its sample, and add them.

x(t)=kx[k]sinc ⁣(π(tfsk))x(t) = \sum_k x[k]\,\operatorname{sinc}\!\left(\pi\left(t f_\mathrm{s} - k\right)\right)

It has the property the theorem needs — the sinc is one at its own sample instant and zero at every other, so the sum passes exactly through every sample — and it has one more that matters here: among all signals through those samples, it is the one containing nothing above half the rate. That is what makes it the reconstruction rather than a curve through the points.

So the sum answers a specific question, and the question is not “what was the input”. It is: of the infinitely many signals through these samples, which one is inside the band? Below half the rate the answer is the input, because the input was inside the band. Above half the rate the answer is the image, because the image is inside the band and the input is not.

Nothing goes wrong. The sum does its job, correctly, and its job was never to recover the input.

Two references, one measurement

The measurement lib/sample.js performs is deliberately blunt. It samples a sinusoid, evaluates the sum at four hundred points across the record, and takes the worst departure from a stated function. Then it does it twice: once against the input, once against the image.

Three numbers come out, and it is worth putting them in one place.

what is measured value
3 kHz sampled at 10 kHz, against the input 6.7 × 10⁻³
9 kHz sampled at 10 kHz, against the image 1.6 × 10⁻³
9 kHz sampled at 10 kHz, against the input 2.000

The first two are the same kind of number — within a factor of four of each other, and the factor is the input frequency rather than the boundary, since a tone near half the rate has fewer samples per cycle for the sum to work with. Neither is zero, and neither is zero for the same reason: the sum is truncated at sixty-four samples either side of the point being evaluated, and a sinc falls only as 1/k, so the tail that is thrown away is of order 1/(π × 64). That is a property of this implementation and not of the theorem, and the site’s habit is to quote it rather than to hide it inside a tolerance.

The third number is not that kind of number at all. Two is the whole amplitude of the signal, doubled — the reconstruction and the input are in antiphase at the worst point, so the departure is the sum of two amplitudes rather than the difference of two similar things. The ratio between the second and third is 1.26 × 10³, and the gate requires it to exceed two hundred so that a change which quietly blurred the distinction would fail rather than pass.

Why the guard band is excluded, and what it costs to say so

The sum needs samples on both sides of the point it is evaluating, and near the ends of a finite record it does not have them. Evaluating there measures the truncation of a one-sided sum, which is much worse than the truncation of a two-sided one and has nothing to do with the sampling.

So reconstructionError excludes a guard of sixty-eight samples at each end and says that it does. This is the kind of exclusion that is easy to make quietly and worth making loudly, because the numbers it protects are the ones the whole comparison rests on. Without the guard both errors would be an order of magnitude larger and would still be equal to each other, so the argument would survive while every number in it became a measurement of the window rather than of the sampling.

The general form of that trap is one this collection has met twice already. The noise field’s two routes to a noise voltage disagreed by two to seven per cent until two discretisation errors were found, and widening the tolerance would have hidden both. A number that is not what it claims to be usually still moves the right way; that is exactly what makes it durable.

What the reconstruction returns, either side of 5.0 kHz. computed by solving, not by drawing. The Whittaker–Shannon sum is evaluated on the samples and compared with two things: the signal that was sampled, and the frequency the samples report. Below 5.00 kHz these are the same curve and the error is 4.88e-3 — the truncation of the sum at sixty-four samples either side, and nothing else. Above it they part: at 4.50 kHz the reconstruction is 6.42e-3 from the alias and 0.006 from the input. The small number is the interesting one. A reconstruction cannot be improved into the right answer, because it is already an exact answer to a different question.
Fig. 2 Four and a half kilohertz, just inside the band. The reconstruction is 6.42×10⁻³ from the input and 6.42×10⁻³ from the alias, because below 5 kHz those are the same curve: there is no second answer to be exact about. The error that remains is the truncation of the sum at sixty-four samples either side and nothing else.

How slowly the sum converges, measured

The truncation was described above as “of order 1/(π × 64)”. That is an estimate from the shape of the sinc, and this collection’s rule is that an estimate of that kind gets measured rather than quoted — the same rule that turned the trapezoidal rule’s claimed second order into a measured factor of 4.00 per halving of the step and the lumped ladder’s approach to the wave limit into a measured exponent of −0.54.

Run the same reconstruction at six truncation lengths, on the same samples, against the same reference:

terms either side worst error
8 2.40 × 10⁻²
16 8.82 × 10⁻³
32 1.66 × 10⁻²
64 6.74 × 10⁻³
128 1.32 × 10⁻³
256 6.47 × 10⁻⁴

Fitted across all six, the error falls as the −1.02 power of the number of terms, which is the 1/k tail of the sinc read directly off the measurement. That is a slow convergence by the standards of the rest of this site: the trapezoidal rule gains two digits for every factor of ten in the step, and this gains one for every factor of ten in the effort.

The middle of the table is worth not smoothing over. At thirty-two terms the error is worse than at sixteen, which is not noise and not a defect. A sinc’s tail alternates in sign, so a truncation that stops on a favourable half-cycle beats one that stops on an unfavourable one, and the envelope rather than the sequence is what falls as 1/k. A version of this measurement that had reported only the two ends would have shown a tidy factor of thirty-seven across five doublings and hidden a real property of the method.

The practical consequence is the reason the ideal reconstruction is a measuring instrument here and not an implementation. Reaching sixteen-bit accuracy with this sum needs of order sixty-five thousand terms per output point, which is why nothing does it — and why the crude reconstruction below is what every converter actually performs.

What a converter actually does instead

No converter evaluates that sum. A digital-to-analogue converter holds each sample for a clock period, which is a much cruder reconstruction, and the difference between the crude one and the ideal one is itself measurable and is an essay further along this field.

What the reconstruction returns, either side of 5.0 kHz. computed by solving, not by drawing. The Whittaker–Shannon sum is evaluated on the samples and compared with two things: the signal that was sampled, and the frequency the samples report. Below 5.00 kHz these are the same curve and the error is 4.88e-3 — the truncation of the sum at sixty-four samples either side, and nothing else. Above it they part: at 1.00 kHz the reconstruction is 1.59e-3 from the alias and 0.002 from the input. The small number is the interesting one. A reconstruction cannot be improved into the right answer, because it is already an exact answer to a different question.
Fig. 3 A kilohertz, a fifth of the way up the band, where the truncation error falls to 1.59×10⁻³. Well inside the band the sum is doing the only thing it can do and doing it to within a part in six hundred; the quantity that will matter later — the distance from the alias — is the same number here, and stays the same number all the way up.

It is worth being clear that this does not rescue anything. The hold is a worse reconstruction than the sum, not a differently-behaved one: it produces the same in-band signal with a droop across it, plus images around every multiple of the clock that a reconstruction filter then has to remove. If the in-band signal is the alias, the hold reproduces the alias with a droop on it.

The ideal sum is therefore the right object to measure the boundary with, precisely because it is the best case. Anything a real system does is a degraded version of it, and a degraded version of an exact answer to the wrong question is still an answer to the wrong question.

Reading the curve, and one thing it does not say

The figure draws both errors as functions of the input frequency, and two features of the shape are worth naming.

The upper curve rises before the boundary. Approaching 5 kHz from below, the error against the input grows from about 5 × 10⁻³ at the bottom of the axis towards a tenth. That is not aliasing beginning early; it is the truncated sum having a harder job, because at a frequency approaching half the rate there are barely two samples per cycle and the sinc tails carry more of the answer. Refusing to explain that as “aliasing setting in gradually” matters, because it is the one place in this essay where a real effect could be misread as a soft boundary. The boundary is not soft. The measurement of it, with sixty-four terms, has a shoulder.

The lower curve is flat across the boundary. It measures the error against whichever frequency is inside the band, which below 5 kHz is the input and above it is the image — the same quantity, read against a reference that swaps at the boundary. Its flatness is the point of the whole figure: the sum’s performance does not change at all as the input crosses. What changes is what it is performing on.

The filter after the converter, which has the same trade as the one before

A held output carries the in-band signal with a droop on it and a copy of the whole band around every multiple of the clock. Removing those copies is another analogue filter, and it is the mirror image of the anti-alias filter that the next essay in this field measures — same components, same families, same trade between skirt and delay, run backwards.

It also inherits the same arithmetic. The first image band starts at fₛ minus the highest wanted frequency, so the filter has from the top of the band to there in which to fall, and how much falling it can do in that span is a property of its family and order rather than of the converter.

The sample rate each anti-alias filter demands for 60 dB. computed by solving, not by drawing. A 20 kHz passband, and each filter must be 60 dB down by the frequency that folds back into it. The required rate follows, and it is a property of the filter rather than of the converter: Bessel 3.21× Nyquist, Butterworth 2.08×, Chebyshev 1.58×. The elliptic design at a selectivity of 0.8 is refused: its equiripple stopband has a floor at -50.2 dB, which is above the requirement at every frequency, so no sample rate satisfies it. At a selectivity of 0.5 the same order needs 1.35×. The floor is the selectivity's, not the order's.
Fig. 4 The reconstruction filter’s problem is the anti-alias filter’s problem with the arrow reversed, so the same measurement answers both. At sixty decibels and sixth order the families spread by more than a factor of three in the clock rate they demand, and the elliptic design that reaches the requirement does it at the lowest rate of all.

The two are not quite symmetric, and the asymmetry is in the droop. An anti-alias filter’s passband ripple is its own; a reconstruction filter’s passband must accommodate the hold’s sinc as well, which is 3.92 dB of tilt across the band at the extreme and cannot be designed away by choosing a better family. The usual answer is to compensate for it digitally before the converter — a filter whose passband rises to meet a droop it cannot see — which is one of the places where the analogue and the digital halves of a signal chain stop being separable.

What the reconstruction returns, either side of 5.0 kHz. computed by solving, not by drawing. The Whittaker–Shannon sum is evaluated on the samples and compared with two things: the signal that was sampled, and the frequency the samples report. Below 5.00 kHz these are the same curve and the error is 4.88e-3 — the truncation of the sum at sixty-four samples either side, and nothing else. Above it they part: at 13.00 kHz the reconstruction is 6.74e-3 from the alias and 1.995 from the input. The small number is the interesting one. A reconstruction cannot be improved into the right answer, because it is already an exact answer to a different question.
Fig. 5 Thirteen kilohertz, three past the sampling rate. The reconstruction sits 1.995 away from the input — the two are different signals of amplitude one — and 6.74×10⁻³ from the alias at 3 kHz. The large number is the one a specification would quote and the small one is the one that says what the sum actually did.

Where the boundary is not a boundary

Two cases fall outside everything above, and both are worth stating so that the claim is not read wider than it is.

A signal with no content above half the rate is fully recovered, and the theorem is not approximate about it. That is the positive half, and this essay has spent its words on the negative half because the positive half is the one already believed. The measurement supports it: below the boundary the reconstruction is within seven parts in a thousand of the input at every frequency tried, and the residual is the truncation rather than the theorem.

A signal deliberately placed in an image band is recovered too, which is the technique the previous essay described. Nothing in the sum objects; it returns the band-limited member of the family, and if a designer arranged for that member to be the one carrying the information then the reconstruction is exactly right. The essay’s title is not a complaint about the sum. It is a description of what a reconstruction is: a choice of one member of a family, made by a rule that knows nothing about which member anybody wanted.

What the reconstruction returns, either side of 5.0 kHz. computed by solving, not by drawing. The Whittaker–Shannon sum is evaluated on the samples and compared with two things: the signal that was sampled, and the frequency the samples report. Below 5.00 kHz these are the same curve and the error is 4.88e-3 — the truncation of the sum at sixty-four samples either side, and nothing else. Above it they part: at 11.00 kHz the reconstruction is 1.59e-3 from the alias and 2.000 from the input. The small number is the interesting one. A reconstruction cannot be improved into the right answer, because it is already an exact answer to a different question.
Fig. 6 Eleven kilohertz, one past the sampling rate, reporting as 1 kHz. The distance from the input is 2.000 and the distance from the alias 1.59×10⁻³ — the same 1.59×10⁻³ the in-band kilohertz case had, which is the point: the reconstruction of an 11 kHz input and the reconstruction of a 1 kHz input are the same computation on the same numbers, and nothing downstream can tell them apart.

Why this essay measures a worst error rather than a spectrum

There is an obvious alternative way to make the same argument: transform the reconstruction and show a line at 1 kHz where a line at 9 kHz was expected. It would be a shorter essay and a worse measurement, for a reason worth stating because it applies well beyond this figure.

A spectrum answers “how much of each frequency is present”, and the claim being made here is stronger than that. It is that the reconstruction is a particular function of time, matching one reference and not another, at every instant rather than on average. A worst-case departure across four hundred points supports that; a spectral line does not, because two signals can share a spectrum and differ in phase — which is exactly the case here, since the image arrives with its phase reversed and a magnitude spectrum would show the two as identical.

The site has made this choice before and for the same reason. The step response is computed twice, once from residues and once by walking the network forward in time, rather than being inferred from a transfer function; and the three-phase neutral is computed both from the solve and from the zero-sequence component, because two routes that share only their input are worth more than one route reported precisely. A time-domain comparison against two references is the same habit applied to a sum instead of to a network.

What this leaves for the rest of the field

The boundary is now measured from both directions and the machinery for it is checked. Everything after this essay is about the two things a converter does that the sampling theorem says nothing about at all.

It replaces each sample with one of a finite set of numbers, which is a boundary from below in amplitude. The floor a converter sets measures where that floor sits against the circuit in front of it, and finds the two crossing at 18.80 bits for a kilohm source in a hundred kilohertz — past which every further bit buys a more precise measurement of thermal noise. When a floor stops being a floor then measures the amplitude at which it stops behaving like a floor at all: the share of the error’s power sitting in harmonics of the input rises from 0.29 per cent at 230 levels to 76 at 1.3, with the total unchanged, so what fails is the description rather than the quantity.

And it takes each sample at an instant that is not quite the right instant, which is a boundary in time whose cost is proportional to the slope of the signal and therefore to its frequency. A picosecond, read as bits turns that into the units a designer uses — ten picoseconds holds sixteen bits up to 199 kHz and twelve bits up to 3.18 MHz, falling at exactly twenty decibels a decade — and a floor, or a line then shows that the same picoseconds can put the resulting error in two entirely different places, twenty-eight decibels apart, with nothing in the specification to distinguish them.

Neither is in the theorem, both are in every converter, and both are measurable in the way everything on this site is measurable: build the thing, run it, and read the answer back out. That is worth saying plainly because the theorem’s own exactness invites the opposite habit — a result proved rather than measured tends to be quoted rather than bounded, and a converter is the object where the proof and the part have the least in common.

There is a fourth thing, and it is the one this essay is closest to. The staircase on the way out measures what happens when the reconstruction is not the ideal sum at all but the thing a converter actually does — hold each sample for a whole clock period, which is a convolution with a rectangle and therefore a multiplication by a sinc: 0.14 dB down at a tenth of the sample rate, 0.91 at a quarter and 3.92 at half, which is exactly 20log(2/π)20\log(2/\pi). Nobody chose that droop, and it is larger than the passband ripple of every filter this site has designed. So the exactness measured on this page is the property of an interpolation nothing implements, and the error of the one that is implemented is deterministic, known in closed form, and larger than most of the errors anybody argues about.

Part 2 on sample rate

One argument about Sample rate, and one of 2 essays on it so far, each part numbered by how much of the idea it assumes. What sits either side of it:

What links here

Essays that reach for this one mid-argument — the half of a link its own author cannot write down.

The objects named here

The third axis, after the field and the idea: the things themselves, and every essay that touches each one.

AliasingConvergence orderNyquist rateReconstructionSample rate