Where a signal becomes a number

The peak that is a corner

The largest of a set of samples falls short of a sine wave's peak as the square of the sample interval, and that law belongs to the sine. Measured over every sampling phase, a triangle's corner falls short as the first power, 12.5 per cent at sixteen samples a period against the sine's 1.92, a peak whose curvature vanishes as the fourth power, and a sine clipped at nine-tenths of its height reads exactly above seven samples a period. The order in which a waveform leaves its peak is the whole of the law, and it also fixes how much better the average reading is than the worst. A real corner is round at some scale, so the law bends where the samples resolve its top harmonic, and a parabola through three samples helps a round peak, barely touches a corner and makes a flat one worse.

Assumes: The frequency a sample rate invents

The rate each reading needs found that eight samples a cycle hold a sine wave completely, four times what the Nyquist rate asks, and that the largest of them is still 7.61 per cent below the peak. The largest sample needs twenty-three samples a cycle to come within one per cent. It stated the reason in a sentence that is true and easy to over-read: the maximum of a smooth curve is flat, so the shortfall goes as the square of the sample interval. It then closed on the observation that the square belongs to a maximum with a continuous second derivative, and that many peaks on an oscilloscope do not have one.

That matters because the peak reading is the one instruments take most casually. A meter or a scope that reports the largest sample is making no assumption about the waveform, or appears not to be, and its specification states a rate. The rate it needs to reach a stated accuracy depends entirely on a property of the waveform that the instrument does not know, and the dependence is not a matter of a constant. Three common waveforms at sixteen samples a period, with the same period and the same peak, read 1.92 per cent, 12.5 per cent and exactly nothing short.

Three waveforms at 16 samples a period, sampled at the worst instant: the largest sample of a sine is 1.92% short, of a triangle 12.5%, of a clipped sine 0computed by solving, not by drawing: three waveforms with the same period and the same peak, sampled 16 times a period at the phase that puts the peak midway between two samples (dots). The sine leaves its peak as the square of the time, the triangle in proportion to it, and the sine clipped at nine-tenths of its height does not leave it at all for as long as it stays flat. The largest sample therefore falls short by 1.92% for the sine, 12.5% for the triangle, 0 for the clipped sine, at one rate, for three waveforms with the same period.00.2000.4000.6000.8001-0.250-0.12500.1250.250time from the peak, in periodsover the true peaksine1.92% shorttriangle12.5% shortclipped sine0 shortsolved, then checked — worst sampling phaseone rate, three shortfalls
Fig. 1 Three waveforms with the same period and the same peak, sampled at the phase that puts the peak midway between two samples (dots). At 16 samples a period the largest sample of the sine is 1.92% short, of the triangle 12.5% and of the sine clipped at nine-tenths of its height nothing at all. The slider changes the rate, and only one of the three shortfalls moves as the square of it.

What counts as the worst

A reading taken from samples depends on where the samples happened to fall, and the fair measure of a rate is what it guarantees. So every shortfall here is taken over the sampling phase, the distance from the true peak to the nearest sample, which for an unsynchronised instrument takes every value between minus and plus half an interval with equal likelihood. The largest shortfall occurs at the midpoint, where two samples sit an equal distance either side of the peak; the smallest occurs when a sample lands exactly on it, where the reading is perfect at any rate. A claim about a rate is a claim about the midpoint.

That distinction has a useful side effect, and it is the first thing a sweep over the phase shows. A shortfall that depends on where the sample fell is a curve, and the curve is a portrait of the waveform at its peak.

The shortfall against where the sample falls, at 16 a period: a corner is a V, a round peak a parabola, and a flattened peak stays near zero until the sample is almost halfway. computed by solving, not by drawing: the shortfall of the largest of 16 samples a period against the distance of the nearest sample from the true peak, for a triangle, a sine and a peak whose curvature vanishes. triangle: worst 12.5%, mean over the phase 6.25%, ratio 0.500 against 1/(p + 1) = 0.500; sine: worst 1.92%, mean over the phase 0.641%, ratio 0.334 against 1/(p + 1) = 0.333; flattened peak: worst 0.0369%, mean over the phase 0.0074%, ratio 0.200 against 1/(p + 1) = 0.200. Each curve is |x|^p, where p is the first power of time in which the waveform leaves its peak, so the same order that sets the rate's law sets the ratio between the worst reading and the average one.
Fig. 2 The shortfall of the largest of 16 samples a period against where the nearest sample falls, in sample intervals from the peak, for a triangle (a V), a sine (a parabola) and a peak whose curvature vanishes. The mean over the phase is half of the worst for the V, a third for the parabola and a fifth for the flat peak: 1/(p+1)1/(p + 1) of it, measured 0.500, 0.334 and 0.200.

The triangle’s curve is a V, the sine’s a parabola and the third curve stays near zero until the sample is nearly halfway to the next. Each is ∣x∣p|x|^p, where pp is the first power of time in which the waveform leaves its peak. Call that the order of the peak: a corner has order one, since its value falls in proportion to the time from it. A smooth maximum has order two. The third waveform, 1−(1−cos⁡ωt)21 - (1 - \cos\omega t)^2, has its second derivative vanish at the top as well, and leaves as t4t^4: a flattened peak of order four, which is what a slightly over-driven stage with a soft limit looks like and a good approximation to many real flat-topped waves.

The curve also fixes something a specification sheet rarely separates, which is how far the average reading is from the worst one. A shortfall of ∣x∣p|x|^p averaged over the phase is 1/(p+1)1/(p + 1) of its worst value. So a triangle’s average reading is half as short as its worst, a sine’s a third and a flattened peak’s a fifth. Measured at sixteen samples a period these come out 0.500, 0.334 and 0.200. The reading a user sees most often therefore depends on the order too, and a sine and a triangle that disagree by a factor of 6.5 in the worst case disagree by a factor of 9.8 in the mean.

The law is the order

With the phase settled, the rate can be swept. Each curve below is the worst shortfall against samples per period, over four decades of error, and its slope needs no assumption to measure: it is the ratio of two worst shortfalls an octave apart.

The rate's law is the peak's order: a corner's shortfall falls as 1/N, a round peak's as 1/N², a flattened one's as 1/N⁴, and a clipped one's is exactly zero above 7.0 samples a period. computed by solving, not by drawing: the worst shortfall of the largest sample against the samples per period, over every sampling phase. triangle: measured slope 1.000 against 1, 12.5% at 16 and 3.13% at 64; decaying pulse: measured slope 0.986 against 1, 26.8% at 16 and 7.52% at 64; sine: measured slope 2.000 against 2, 1.92% at 16 and 0.12% at 64; flattened peak: measured slope 4.000 against 4, 0.0369% at 16 and 0.000145% at 64. The sine clipped at nine-tenths is flat for 14.4% of a period, so it reads 21.4% at 4 a period and nothing at all above 7.0, which is the one law on the figure with a threshold in it.
Fig. 3 The worst shortfall of the largest sample against the samples per period, for a triangle, a decaying pulse, a sine and a flattened peak, with the clipped sine as well. Measured slopes 1.000, 0.986, 2.000 and 4.000. The triangle reaches 3.13% at 64 samples a period, the sine 0.12% and the flattened peak 0.000145%. The clipped sine is 21.4% at 4 and exactly zero above 7.0.

The measured slopes are 1.000 for the triangle, 2.000 for the sine and 4.000 for the flattened peak, and at those exponents the fit has nothing to do: the shortfall is exactly a power of the interval at every rate on the figure. A decaying pulse whose peak is a cusp, an exponential falling away from a sharp top, has slope 0.986 by the top of the range, since its shape changes across the interval at low rates. That is how a real RC-discharged pulse behaves, and a sampled pulse from a first-order network is a corner.

The numbers that come from those slopes are not close to one another. For a peak to come within one per cent, a sine needs 23 samples a period, as the earlier essay found. A triangle needs 200, since a shortfall of 2/N2/N reaches a hundredth only there. A pulse with a time constant of a tenth of its period needs about five hundred. So an instrument that quotes “one per cent at twenty-five samples a cycle” has quoted something about sine waves, and a triangular or sawtooth signal on the same instrument at the same rate reads eight per cent short. Nothing about the waveform’s frequency has changed.

The Nyquist rate has nothing to say about any of this, which is the same conclusion the rate each reading needs reached from another direction. The frequency a sample rate invents measured that boundary, and it is about what the samples determine. A triangle wave with a finite number of harmonics, sampled above twice the top one, is completely determined and its peak can be recovered exactly. It is just not in any sample.

A law with a threshold in it

The clipped sine is the odd one out, and it gets its own law. A sine limited at nine-tenths of its height is flat for 14.4 per cent of its period, since it exceeds 0.9 for that fraction of each cycle. Once the sample interval is shorter than the flat, a sample must land on the flat at every phase, and the largest sample is then the peak exactly. The threshold is at 1/0.144=7.01/0.144 = 7.0 samples a period, and above that the shortfall is not small: it is zero, to the last digit.

At 4 samples a period it is 21.4 per cent, so the function falls from a substantial error to nothing at a definite rate. That is unlike any other reading on these figures, and it inverts the usual advice. A flat-topped pulse, the kind a limiter or a digital output makes, has a peak reading that is trivially exact at rates where a sine’s is several per cent out. A designer testing a peak-reading path with a clipped calibrator will see a flawless instrument. That instrument is 3.41 per cent short on a sine at twelve samples a period and 16.7 short on a triangle, and the calibrator did not ask.

The general statement follows from the three cases. A peak’s order is the number that describes how quickly the waveform leaves it, and increasing the order improves the law: 1, 2, 4 and then, in the limit of a flat top, the threshold. A flat top is the case where the order is infinite.

A corner is round if looked at closely enough

The order is not really a property of a waveform, and the figure that shows this is the one with the most practical content. No signal in a circuit has a true corner, since any path has a bandwidth. A triangle reaching an instrument through a stage with a finite number of harmonics has a corner rounded at a scale set by the period over its top harmonic.

A real corner is round if looked at closely enough: a triangle of 10 odd harmonics follows 1/N until the samples resolve its top harmonic, about N = 2·(2K − 1), and then 1/N². computed by solving, not by drawing: the worst shortfall of the largest sample of a triangle wave truncated to its first K odd harmonics, against samples per period, against the ideal triangle. K = 3, top harmonic 5: slope above the bend 2.00, 0.313% at 64 and 0.00123% at 1024 a period; K = 10, top harmonic 19: slope above the bend 2.00, 0.971% at 64 and 0.00389% at 1024 a period; K = 30, top harmonic 59: slope above the bend 2.00, 2.35% at 64 and 0.0115% at 1024 a period. Any waveform in any circuit has a finite bandwidth, so no corner is sharp at every scale: the order of a peak is a statement about the peak at the size of the sample interval. Below the bend the samples cannot tell the truncated wave from the ideal one; above it they see a parabola.
Fig. 4 The worst shortfall of the largest sample of a triangle wave truncated to its first KK odd harmonics, against samples per period, with the ideal triangle dashed. Each truncated wave follows 1/N1/N until the samples begin to resolve its rounded peak, then bends to 1/N21/N^2. At 1024 samples a period: 0.00123%, 0.00389% and 0.0115% for 3, 10 and 30 harmonics, against the ideal triangle’s 0.195%.

So the truncated triangle tracks the ideal one at low rates, with its shortfall falling as 1/N1/N, and then bends to the square law once the samples are close enough together to see the top as a parabola. The bend is where the sample interval reaches the width of the rounded region. Far above it the slope is 2.00 for all three truncations. A wave of 30 harmonics reads 2.35 per cent short at 64 samples a period and 0.0115 at 1,024, against 3.13 and 0.195 for the sharp corner. Four octaves of rate buy the sharp corner a factor of 16 and the rounded one a factor of 204.

The consequence is that the order of a peak is a statement about the peak at the size of the sample interval. A slow instrument looking at a wave that has been through a 10 MHz path sees a corner. A fast one looking at the same wave sees a round top. Both are correct, and their laws are both right, and the bandwidth of the path decides which applies at a given rate.

This is the same situation as the corner that says nothing about an edge, turned round: a bandwidth was too blunt a description there and here it is the thing that decides a law. It also says what a rate’s guarantee can really be stated against. The path’s bandwidth gives a fixed scale, so for a signal known to have passed through it the shortfall at rates above the bend cannot be worse than a square law with a constant set by that bandwidth. An instrument with its own front-end filter can state a law. One that does not know the path has only a bound of the 1/N1/N kind.

What a parabola recovers

If a peak is flat at the top, the obvious repair is interpolation. Take the largest sample and its two neighbours, fit a parabola and report its vertex. That is cheap, it is built into several measurement instruments and spectrum analysers, and on a sine it is excellent.

A parabola through the three largest samples helps exactly when the peak is one: a sine's error falls from 0.482% to 0.00347% at 32 a period, and a triangle's only from 6.25% to 4.69%. computed by solving, not by drawing: the worst error of the peak reading against samples per period, taking the largest sample as it is (solid) and taking the vertex of the parabola through it and its two neighbours (dashed), for a triangle, a sine and a flattened peak. triangle: 6.25% and 4.69% at 32, slope with the parabola 1.00; sine: 0.482% and 0.00347% at 32, slope with the parabola 4.00; flattened peak: 0.00232% and 0.0206% at 32, slope with the parabola 4.00. An interpolation is an assumption about the order of the peak. The parabola is the right assumption for p = 2 and takes the error down two whole powers of the rate; on a corner it reads a vertex by a fixed fraction of an interval and gains a constant factor and nothing else, and on a flattened peak it invents a curvature the peak does not have and is worse than taking the largest sample.
Fig. 5 The worst error of the peak reading against the samples per period, taking the largest sample as it is (lines) and taking the vertex of the parabola through it and its two neighbours (dots), for a triangle, a sine and a flattened peak. At 32 samples a period: sine 0.482% and 0.00347%; triangle 6.25% and 4.69%; flattened peak 0.00232% and 0.0206%. The parabola moves the sine from slope 2 to slope 4, leaves the triangle at slope 1, and makes the flattened peak nine times worse.

On a sine it moves the error from the second power of the interval to the fourth. At 32 samples a period the largest sample is 0.482 per cent short and the vertex 0.00347 per cent out, a factor of 139 for three multiplications and a division. On a triangle at the same rate it moves 6.25 to 4.69, and the slope stays exactly 1.00. A parabola through a corner has its vertex at a fixed fraction of an interval from the true one, because the three points always sit on two straight lines, so it improves the constant by a quarter and buys no power of the rate at all.

The flattened peak is the interesting third case, since a flat top is a very smooth thing and would seem even better suited. It is not. At 32 samples a period the largest sample is 0.00232 per cent short and the vertex is 0.0206 per cent out, nearly nine times worse, with the slope unchanged at 4.00. A parabola through three points on a flat top has to have a vertex, and it finds one above the true peak, by reading the small difference between three nearly equal numbers as a curvature. The waveform has no second-order term for the fit to cancel, and the fit supplies one anyway.

So an interpolation is an assumption about the order of the peak, and its benefit is sharp: it pays out in full at the one order it assumes and is a modest correction everywhere else. An instrument doing this silently is therefore far more accurate on a sine than on anything else, and its accuracy claim on a sine says less about an arbitrary signal than the plain largest-sample reading does. A sinc reconstruction, the exact answer an exact answer to a different question measured, assumes only a bandwidth, and that is a much better assumption about a signal whose shape is unknown, though it costs a very much longer sum.

A bit’s worth of a peak

A peak reading has a counterpart in converter language. An eight-bit resolution reading a full-scale peak has a step of 0.39 per cent of the peak, and a sampling shortfall the same size is a bit’s worth of the converter thrown away. Six decibels a bit measures that step against a waveform; the sine reaches a shortfall that small at thirty-six samples a period, while a triangle needs 512. An instrument that digitises at a resolution finer than the sampling law can support is reporting bits that the rate has already lost, and this happens on anything sharper than a sine at the rates scopes usually run.

The record length does not help. A long record of a periodic waveform at an unsynchronised rate does land a sample close to the peak eventually, and a peak-hold over many cycles will drift upward towards the true value, as the cycle a converter has to know discusses for periodic signals. That is a different instrument: it is averaging over phase by waiting, and it relies on the waveform repeating and on the clocks being incommensurate. On a single transient, the phase is what it is and the worst case is the case to design for.

The rate, read backwards

There is also a measurement the law makes possible rather than a limit it imposes. Sample a repeating waveform at two rates an octave apart, and the ratio of the two shortfalls against a long-run peak-hold gives the slope directly: a ratio of 2 is a corner, 4 a round peak, 16 a flattened one. So the order of a peak can be measured by a peak meter that has two clock settings, without looking at the waveform. Whether it is a corner to this instrument is then a thing it can say, and with it the instrument can say which of its peak accuracies applies. Nobody quotes the number, but it would be a good one to have on a test report, since it is the thing that decides whether a reading from one rate can be trusted at the next.

What the shapes leave out

The waveforms here are ideal functions, sampled instantly and exactly on a uniform clock. No noise is on the samples, and that matters more than it first appears, because a shortfall of a tenth of a per cent is small compared with the noise on many readings; a largest-of-N reading in the presence of noise is biased upward, by an amount that grows with how many samples lie near the peak, so the noise and the shortfall have opposite signs and a stated noise level has a rate at which they cancel. That is left open below.

Aperture is ignored as well. A real sampler averages the waveform over a short window, and on a corner that window itself clips the peak by a fixed amount regardless of the rate. That window is a filter with the droop any hold has, and on a corner it would add a floor below which the law cannot go.

What to carry away

A peak’s order is the power of time with which the waveform leaves it, and the largest sample’s worst shortfall falls as the rate to that power: 12.5 per cent for a triangle at sixteen samples a period, 1.92 for a sine and 0.0369 for a flattened peak; the mean is 1/(p+1)1/(p + 1) of the worst. A flat top reads exactly above a definite rate, seven samples a period for a sine clipped at nine-tenths. A real corner is round at the scale of its top harmonic, so the order is a property of the peak at the size of the sample interval, and the law bends where that interval reaches the rounding. A parabola through three samples takes a round peak from the second power to the fourth, gives a corner nothing but a quarter, and makes a flattened peak nine times worse. A rate quoted for a peak reading is a statement about one shape.

Still open: the noise on a largest sample, an aperture on a corner, and two rates on one meter

A largest sample with noise on it. With noise on each sample the largest is the maximum of several noisy values and is biased high by an amount that grows with the number of samples near the peak, while the shape’s shortfall pulls it low. For a stated noise level there is a rate at which the two cancel, a rate beyond which the bias dominates, and the order of the peak decides how many samples are near it. The best rate for a peak-reading instrument is a function of noise and shape together.

An aperture on a corner. A sampler that averages over a window is a filter that rounds every corner at the window’s own width, so a sampler’s aperture gives an upper limit on the order a peak can have when read through it. What fraction of a sample interval the aperture can be, before the corner’s reading stops improving with rate, is a measurement that would put a floor under the 1/N1/N line.

The order measured by the meter. A peak meter with two clock rates can read its own waveform’s order from the ratio of two shortfalls. Whether that ratio is usable on a real signal, with a peak-hold reference that is itself sampled and with noise in both readings, is a question about how many cycles it takes to know the slope.

Part 4 on sample rate

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

A sinusoid sampled 8 times a cycle, at the phase that puts its peak between two samples. computed by solving, not by drawing: the samples of a unit sinusoid at 8 a cycle, synchronous, at the sampling phase that hides its peak worst. 8 samples a cycle is 4 times the Nyquist rate and holds the waveform completely; the largest sample is still 0.9239, 7.61% below the peak, which is 1 − cos(π/8). Read straight off the samples the peak needs 22.2 samples a cycle for 1% and 70.2 for 0.1%. The rate each reading needs Part 3 — Twice the frequency is the rate at which a set of samples holds a sinusoid completely, and it is not the rate at which any particular property can be read off them. Eight samples a cycle — four times the Nyquist rate — hold the waveform, and their largest is still 7.61% below the peak; the largest sample needs 22.2 a cycle for 1% and 70.2 for 0.1%, because its error falls only as the square of the rate. A parabola through the three largest gets 1% at 8. A zero crossing found by a straight line between two samples is a hundredth of a cycle right at 5 a cycle, its error falling as the cube, because a sine is straight at its zero. The rms of whole cycles is exact from three a cycle — and at exactly two it reads anything from zero to √2. A slow rate with a long record of a steady signal does what a fast rate does, once the samples have slipped a whole interval past it: 42 cycles at 4.0236 a cycle. A Gaussian edge read at 3 samples per rise, at the worst sampling phase: straight chords between the samples say the rise is 8.78% from its true value. computed by solving, not by drawing: a Gaussian edge (solid), its samples at 3 per 10–90% rise at the sampling phase that reads worst (dots), and the straight lines an instrument's linear interpolation draws through them (dashed). The chord crosses 10 and 90 per cent earlier and later than the edge does, because a Gaussian edge curves in opposite senses at the two thresholds. The reading is 1.0878 rises against 1. The samples a rise time needs Part 5 — A rise time is read from two thresholds, and an instrument that draws straight chords between its samples is wrong at each by an amount that goes as the square of the interval. For a Gaussian edge at the worst sampling phase that is 5.02 per cent at four samples per rise and 0.818 at ten; the rule of thumb of three to five is a five per cent rule, and one per cent takes nine. The reading is not monotonic in the rate: above 20.9 per rise a first-order edge reads exactly at whole numbers and 0.046 per cent at 24.5, because its two errors subtract at one phase, and a Gaussian edge reads worse there because its two add. Reconstructing before reading needs 1.87 per rise for one per cent, and at four times the edge's 3 dB bandwidth the reading is still 11.7 per cent out.

The objects named here

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

Convergence orderModel rangeNyquist ratePower law fitReconstructionSample rate