Power, and the part that does no work

The window that forgives the period

A converter that sums a waveform's square over whole periods reads its RMS exactly, and one that sums over periods 1.3% too long reads a sine 0.6% wrong — δ/2, for any number of periods — because the extra sliver of period counts at full weight. Weight the window down to zero at its ends and the sliver barely counts. Over eight periods a triangular weight reads the same sine 79 ppm wrong and a Hann weight 23 ppm; and they are different kinds of cure. The triangle is the only one that changes the error's order, from first to second in δ, so it wins when the period is nearly right; the Hann weight keeps first order but falls with the number of periods, about as its inverse square, so it wins over long windows. Both cost nothing with the period exact — from two periods up. Over one, a Blackman–Harris weight reads even a sine 10% wrong. The price is noise: a Hann-weighted reading of noise scatters √1.5 as widely.

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 NN periods of an assumed length a fraction δ\delta too long holds NδN\delta 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 δ/2\delta/2, and it stays δ/2\delta/2 however many periods are summed, until NδN\delta 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 1−cos⁡1 - \cos. 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 NN assumed periods a fraction δ\delta 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% long, eight periods read a sine 0.599% wrong through a rectangle, 79.4 ppm through a triangle, 22.8 ppm through a Hann windowIntegrated over each weighted window, the worst over every starting phase. The error in a sine's root-mean-square summed over N assumed periods 1.3% too long, against N, for four weights across the window. The rectangle is the plain sum: 0.640% at two periods and flat in N, δ/2 as the earlier measurement found. The triangle is flat in N too but 75 times smaller at eight periods. The Hann window falls with N, as the −2.67 power: 414 ppm at two periods, 0.293 ppm at thirty-two. The four-term Blackman–Harris is below 4.85 ppm at every count from two. A weight that falls to zero at the window's ends counts the extra sliver of period at almost nothing.1n10n100n1µ10µ100µ1m10m10periods summed, Nworst error in the sine's reading (fraction)rectangle0.599% at N = 8triangle79.4 ppm at N = 8Hann22.8 ppm at N = 8Blackman–Harris0.594 ppm at N = 8every weighted window, every startthe sliver, weighed at its end
Fig. 1 The worst error in a sine’s RMS summed over N periods assumed 1.3% too long, against N, for four weights. The rectangle is 0.64% at two periods and flat; the triangle flat and 75 times smaller at eight periods; the Hann weight falls from 414 ppm at two periods to 0.29 ppm at thirty-two; Blackman–Harris is below 5 ppm from two.

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 NN, 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 triangle alone changes the order of the error: second order in δ, where the rectangle, Hann and Blackman–Harris stay first order. Integrated over each weighted window. The worst error in a sine's reading over ten assumed periods against how much too long the period is, for four weights: fitted slopes 0.96 (rectangle), 1.97 (triangle), 0.95 (Hann), 0.85 (Blackman–Harris). The rectangle's sliver enters at full weight, so its error is proportional to the sliver. The triangle's weight is itself proportional to the distance from the window's end, so a sliver of length Nδ enters with a weight of order Nδ and its contribution is second order. The Hann window's weight is second order at its ends, but its transform at the square's line has a slope, so the error is first order with a small coefficient that falls as the number of periods grows; Blackman–Harris likewise, with a coefficient smaller again.
Fig. 2 The worst error over ten periods against how much too long the assumed period is, for four weights: fitted slopes 0.96 for the rectangle, 1.97 for the triangle, 0.95 for Hann and 0.85 for Blackman–Harris.

The rectangle’s error is first order in δ\delta — 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 NδN\delta lying at the edge enters with a weight that is itself of order NδN\delta, 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 δ\delta and the error follows. Its coefficient is small, and it falls with the number of periods — as the inverse square at small δ\delta, −2.01-2.01 fitted at 0.13 per cent — because the Hann transform’s slope at its kk-th zero falls as 1/k31/k^3 while the line’s distance from that zero grows only as kδk\delta, and the product falls as 1/k21/k^2. 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 δ\delta is tiny at any NN. The Hann weight is the better one when the period is poorly known and the window long, because its first-order error falls with NN. 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.

With the period right, a taper costs nothing from two periods up — and over one, Blackman–Harris reads a sine 10.384% wrong. Integrated over each weighted window with the assumed period exactly right. The worst error in the reading of a sine and of a half-wave rectified sine, over 1 to 4 periods, for four weights. The rectangle is exact everywhere. The triangle and the Hann window are exact for the sine at every count; the Hann window reads the half-wave current 61.119% wrong over one period, because that current's square has a line at the fundamental, one cycle per window, where the Hann transform is not zero. The Blackman–Harris weight is not zero until four cycles per window, so over one period it reads even a sine 10.384% wrong and the half-wave current 81.013%; from two periods every taper is exact. A taper keeps the plain sum's exactness only when the window holds enough periods to put the square's lines on its transform's zeros.
Fig. 3 The worst error with the assumed period exact, over 1 to 4 periods, for a sine and a half-wave rectified sine, for the four weights. Every weight is exact from two periods up. Over one period the Hann weight reads the half-wave current 61% wrong, and Blackman–Harris reads even a sine 10.4% wrong.

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 NN or 2N2N 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 price of the taper is noise: a Hann window's reading of noise scatters 1.225 times as widely as the plain sum's. computed by solving, not by drawing, over 1600 seeded records of white noise, 8 periods of 64 samples. The relative scatter of the weighted mean square of noise, for four weights, as a multiple of the rectangle's (bars), against √ENBW, the root of each window's equivalent noise bandwidth in bins (marks): rectangle 1.000 against 1.000, triangle 1.163 against 1.155, Hann 1.203 against 1.225, Blackman–Harris 1.390 against 1.416. A weight that falls to zero at its ends uses the samples near them less, so fewer samples effectively count and the noise's own fluctuation is averaged less. What the taper removes from the period's mistake it charges to the reading's randomness, and the exchange rate is the window's noise bandwidth.
Fig. 4 The relative scatter of the weighted mean square of white noise over 1,600 seeded records, eight periods of 64 samples, as a multiple of the rectangle’s (bars), against the root of each weight’s equivalent noise bandwidth (marks): triangle 1.163 against 1.155, Hann 1.203 against 1.225, Blackman–Harris 1.390 against 1.416.

The scatter of a weighted mean square of white noise is 2 ENBW/M\sqrt{2\,\mathrm{ENBW}/M} for MM samples, where the equivalent noise bandwidth of the weight is M∑w2/(∑w)2M\sum w^2/(\sum w)^2, 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 ENBW\sqrt{\mathrm{ENBW}} 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 2N2N periods is exactly what two plain sums in cascade produce: summing over NN periods, then summing the running result over another NN, 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 — δ/2\delta/2, and flat in the number of periods. Through a triangle, whose error is second order and flat in NN, 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 NN, 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.

Over ten periods 1.3% long, the rectangle's reading swings ±0.574% with the starting phase and the tapers' barely move. Integrated over each weighted window. The error in a sine's reading over ten assumed periods 1.3% too long, against where in the waveform the window starts, for four weights. The rectangle swings ±0.574% as the extra sliver falls on the square's peak or its trough; the triangle ±77.9 ppm, the Hann window ±14 ppm, Blackman–Harris ±0.0641 ppm. The swing with phase is what makes a plain sum's reading of an unsynchronised waveform jitter from one reading to the next, and the taper flattens it along with the error.
Fig. 5 The error in a sine’s reading over ten periods assumed 1.3% too long, against where the window starts, for four weights: the rectangle swings ±0.574% with the starting phase, the triangle ±78 ppm, Hann ±14 ppm and Blackman–Harris ±0.06 ppm.

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 N(1+δ)N(1 + \delta) 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