The window that forgives the period
Assumes: What a meter multiplies by · The bandwidth noise sees
The cycle a converter has to know found the cleanest way to read a waveform’s root-mean-square: sum its square over a whole number of periods. There is no averager, so there is no ripple and no bias; the mean over a window the waveform repeats in is its mean square exactly. The catch is the period. A window of periods of an assumed length a fraction too long holds of a period too much, and the reading then depends on where that extra sliver falls — on the square’s peak or its trough. For a sine the worst error is , and it stays however many periods are summed, until reaches half a period and the slivers start to cancel. A period known one per cent long is half a per cent of error for any reasonable window.
That essay ended by suggesting the obvious repair. The sliver enters at full weight because the window weighs every instant equally; a window whose weight falls to zero at its ends would take the sliver in where it barely counts. The question was by how much, and whether weighting the window loses the exactness the plain sum has when the period is right. The measurements below answer both, and the answer to the first depends on the weight’s shape more than on how much of the window it tapers.
Four weights
Four weights are compared, each a function of position along the window. The rectangle is the plain sum. The triangle rises linearly from zero to a peak in the middle and falls back. The Hann weight is a raised cosine, one period of . The four-term Blackman–Harris weight is a sum of four cosines chosen to fall faster still. Each is applied to the square of a unit-RMS waveform over assumed periods a fraction too long, and the weighted mean square is compared with the true one, at every starting phase, with the worst taken.
With the period 1.3 per cent long, eight periods read a sine 0.599 per cent wrong through the rectangle, 79.4 ppm through the triangle, 22.8 ppm through the Hann weight and 0.59 ppm through Blackman–Harris. The rectangle is flat in , as the earlier essay found. The triangle is flat too, at a much lower level. The Hann weight falls steeply with the number of periods, from 414 ppm at two to 0.29 ppm at thirty-two.
The slider on the figure at the head of the page shrinks the period’s error tenfold, to 0.13 per cent, and the ranking changes. The rectangle falls tenfold, to 648 ppm; the Hann weight tenfold, to 2.53 ppm at eight periods; the triangle a hundredfold, to 0.889 ppm, overtaking the Hann weight. Two different kinds of improvement are at work, and they are worth separating.
The triangle changes the order
The difference shows directly when the period’s error is swept at a fixed number of periods.
The rectangle’s error is first order in — the fitted slope is 0.96 — because its sliver enters at full weight and the error is proportional to the sliver. The triangle’s slope is 1.97: second order. The reason is the shape of the triangle at its ends. Its weight is proportional to the distance from the window’s edge, so a sliver of length lying at the edge enters with a weight that is itself of order , and its contribution is the product, second order. Halving the period’s error quarters the triangle’s error and only halves the others’.
The Hann weight is also zero at its ends, and flatter there than the triangle — its weight rises as the square of the distance from the edge — so one might expect third order. It is not: its slope is 0.95, first order. What decides the order is not only how the weight starts but what the window does to the square’s own frequency. The square of a sine is a constant plus a line at twice the frequency, and the weighted mean square is off by the weight’s transform evaluated at that line. The Hann transform has a zero exactly where the line falls for whole periods, and a slope there, so a small mistake in the period moves the line off the zero by an amount proportional to and the error follows. Its coefficient is small, and it falls with the number of periods — as the inverse square at small , fitted at 0.13 per cent — because the Hann transform’s slope at its -th zero falls as while the line’s distance from that zero grows only as , and the product falls as . The triangle’s transform has a zero with no slope at even bins, a double zero, which is the frequency-domain statement of its second order.
So the two kinds of cure are distinct. The triangle is the better weight when the period is known well and the window is short, because a second-order error in a small is tiny at any . The Hann weight is the better one when the period is poorly known and the window long, because its first-order error falls with . Blackman–Harris, first order with a coefficient smaller again, wins both comparisons from two periods up, and the next two figures say what it costs.
When the period is right
The plain sum is exact when the period is exact, for any waveform and any number of periods. A weight could lose that, and whether it does is the question the earlier essay asked.
From two periods up every weight is exact for both waveforms, to rounding. Over a single period two of them are not. The square of a half-wave rectified sine repeats once a period, so it has a line at one cycle per window when the window is one period long, and the Hann transform is not zero there: the Hann weight reads that current 61 per cent wrong. The Blackman–Harris transform is not zero until four cycles per window, so over one period it misses even a sine’s square, whose line is at two, and reads the sine 10.4 per cent wrong and the half-wave current 81 per cent.
That is the price of a taper when nothing else is wrong, and it is easy to state. A weighted window is exact for a waveform whose square’s lines all fall on the weight’s transform zeros, and every weight’s zeros begin at some number of cycles per window: one for the rectangle, two for the triangle and Hann, four for Blackman–Harris. A window of whole periods puts the square’s lowest line at or cycles per window, so from two periods every weight here is safe for every waveform, and a converter using a taper must never be asked to read a single period.
The taper’s price in noise
The other price is paid on waveforms that are not periodic at all. A weight that falls to zero at its ends uses the samples near its ends less, so fewer samples effectively count, and a reading of noise — which the earlier essay’s converter was also asked to take — scatters more.
The scatter of a weighted mean square of white noise is for samples, where the equivalent noise bandwidth of the weight is , in units of the plain average’s: 1 for the rectangle, 4/3 for the triangle, 3/2 for Hann and about 2 for Blackman–Harris. Over sixteen hundred seeded records the measured scatter is 1.163, 1.203 and 1.390 times the rectangle’s, against of 1.155, 1.225 and 1.416. A Hann-weighted reading of noise scatters 22 per cent more widely than a plain sum over the same window.
That makes the choice a trade on a stated exchange rate. What a taper removes from the period’s mistake it charges to the reading’s randomness, and the rate is the square root of its noise bandwidth. The noise a true-RMS meter reads low found the explicit converter’s reading of noise biased low and scattered by its averager; the cycle-summing converter has no bias on noise, and the weight sets how much of its window’s samples it spends. The same exchange appeared in the order of the null, not the number of them, where two means in cascade cost a third more noise bandwidth for a much broader rejection of the mains.
The triangle is two sums in cascade
The triangle’s second order has a reading that makes it less surprising. A triangular weight across a window of periods is exactly what two plain sums in cascade produce: summing over periods, then summing the running result over another , weights each instant by how many of the second sum’s windows contain it, which rises linearly to the middle and falls again. The filter an average is found a plain average to be a filter with nulls at every multiple of its own inverse length; two in cascade square that filter, so every null becomes a double null, flat at the bottom.
That is the whole of the second order. The square of a periodic waveform has its lines at multiples of the period’s inverse, and a window of whole periods places them on the nulls. A period slightly wrong moves the lines slightly off the nulls; a single null’s response grows in proportion to the displacement, a double null’s as its square. The order of the null, not the number of them made exactly that point about rejecting the mains with a cascade of means, and the cycle-summing converter is the same arithmetic applied to a waveform’s own harmonics.
It also explains the triangle’s noise bandwidth. Two cascaded means of the same total length spend their samples unevenly, and the 4/3 is the price of the double null, the same third that essay measured.
A mains meter, worked
The mains is nominally 50 Hz and drifts: a few tenths of a hertz is ordinary, and 0.2 Hz is 0.4 per cent. A meter that sums over eight periods of an assumed 20 ms, with the frequency 0.4 per cent off, reads a sine 0.2 per cent wrong through the plain sum — , and flat in the number of periods. Through a triangle, whose error is second order and flat in , the error scales from the 79.4 ppm measured at 1.3 per cent by the square of the ratio, to about 7.5 ppm. Through a Hann weight, first order and falling with , it scales from 22.8 ppm by the ratio itself, to about 7 ppm. A tenfold smaller frequency error, 0.02 Hz, leaves the plain sum at 200 ppm, the Hann weight at 0.7 ppm and the triangle at 0.075 ppm.
So for mains measurement the taper removes the need to track the frequency to better than a few per cent of a hertz, which is the job a synchronised converter spends a phase-locked loop on. The cost, a fifth more scatter on noise, is invisible on a mains waveform whose noise is far below its own amplitude. What a meter multiplies by found an averaging meter’s error set by the waveform’s shape; a weighted cycle-summing meter has almost none from the waveform and almost none from the period, and what remains is its converter’s own resolution.
What the weight does to the jitter
The worst error is one number; the error at every starting phase is a curve, and it is what a converter reading an unsynchronised waveform actually shows, since each reading starts wherever it happens to.
Through the rectangle the reading swings ±0.574 per cent as the starting phase moves, so successive readings of a steady sine jitter by that much with nothing wrong but the period. Through the triangle the swing is ±78 ppm, through Hann ±14 ppm, through Blackman–Harris ±0.06 ppm. A taper flattens the jitter along with the error, which matters as much as the worst case for a meter whose display is watched: a reading that wanders in its third digit is taken to be noisy, and here the wandering is entirely the period’s.
What a designer should take
A cycle-summing converter whose period is uncertain should weight its window. If the period is known to a fraction of a per cent and the window is a few periods, use a triangle: its error is second order in the period’s mistake. If the period is poorly known or the window long, use a Hann weight, whose error falls about as the inverse square of the number of periods. If both the period’s error and the noise budget allow, Blackman–Harris is smaller than either. In every case sum at least two periods, since a single period loses the plain sum’s exactness for any taper with more than the rectangle’s zeros.
Budget the noise: a weighted reading of a noisy signal scatters by the root of the weight’s noise bandwidth, 1.15 for the triangle and 1.22 for Hann. For a converter that mostly reads clean mains-frequency waveforms with a drifting period, the trade is worth it by orders of magnitude. For one that mostly reads noise, it costs a fifth of the averaging time.
How the numbers were obtained
Each waveform is a unit-RMS sampled period — the sine, and a half-wave rectified sine built from it — and its square is interpolated linearly between samples. The weighted mean square over a window of periods is integrated by the midpoint rule at four hundred points a period, with the weight evaluated at each point’s position along the window, and compared with the true mean square; the worst is taken over sixty to ninety starting phases. Slopes are least-squares fits of the logarithms. The noise records are seeded Gaussian samples, sixty-four a period over eight periods, sixteen hundred of them per weight; the equivalent noise bandwidths are computed from the weights themselves.
What it leaves out
The period that drifts during the sum. Every window here has a period that is wrong but constant. A mains frequency that wanders over the window puts the sliver’s size and position in motion, and whether a taper’s advantage survives a drift — or whether the drift’s history matters more than its mean — is the earlier essay’s second open question and still open.
Discrete sampling. The windows here are integrated finely. A real converter samples a finite number of points a period, and a weight evaluated at those points has its own discrete transform, whose zeros are where the continuous one’s are only if the sampling is synchronous. An asynchronous sampler adds its own sliver at the sample level.
Weights not considered. Many other weights exist, including flat-top windows that trade noise bandwidth for amplitude flatness and families with an adjustable parameter; the bandwidth a bin is not measured how differently such windows spend their noise bandwidth. The four here span the relevant behaviours: first and second order, and zeros beginning at one, two and four cycles per window.
Still open: the drifting period, the noise and the signal together, and the weight that tracks the period
A frequency that drifts during the sum. A mains period that changes by a few parts per million over ten cycles gives a window right on average and wrong at its end. The taper weighs the end least, so it should suppress a drift’s error more than a constant one’s; measuring it would say whether a weighted window makes period tracking unnecessary for a slowly drifting supply.
A periodic signal in noise. A reading of a sine plus noise through a weighted window has the taper’s small period error and its larger noise scatter together. There is a signal-to-noise ratio at which the rectangle’s jitter from the period and the taper’s extra scatter from the noise are equal, and below it the plain sum is the better window.
A weight that follows a measured period. A converter that measures each period as it goes can stretch its weight to fit, so that its zeros stay on the square’s lines. Whether that recovers the plain sum’s exactness under drift, and at what cost in the period measurement’s own noise, is the question that joins this essay to the averager that the average a square root pulls low began with.
Part 5 on RMS and average
One argument about RMS and average, 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:
The objects named here
The third axis, after the field and the idea: the things themselves, and every essay that touches each one.
Crest factorMeasurement errorNoise bandwidthSample rateTrue-RMSWindowing
- Every tooth the same height crest factor, measurement error
- The current that sizes the transformer crest factor, true-rms