S10 · Lesson 31 · State estimation
Redundant meters with random errors, the weighted least-squares estimate and its gain matrix, the chi-square test that tells a good set of measurements from a bad one, normalized residuals that point to the bad meter, observability, and a Python estimator
A control room receives tens of thousands of measurements every few seconds: line flows, injections and voltages, sent over telemetry from meters with ordinary errors, plus the occasional gross one when a transducer fails or a breaker status is wrong. A power flow can't use them directly. It takes exactly one input per unknown, it has no place for the extra flow measurements, and a single bad input spoils its answer. What does the control room actually know about the state of its system, and how sure is it?
- The three-bus DC network of lesson 20 (lines 0.1, 0.2 and 0.25 pu) has five meters: the flows on lines 1–2, 1–3 and 2–3 (σ = 0.01 pu) and the injections at buses 2 and 3 (σ = 0.02 pu). The unknowns are the two bus angles.
- The x axis is the reading of the line 1–3 meter, with the other four fixed at good values. The curves are the weighted sum of squared residuals J and the line 1–3 meter's normalized residual.
- The estimate accepts readings that keep J below the chi-square threshold of 11.34 (3 degrees of freedom, 99%): roughly 0.63 to 0.72 pu. Outside that band the test flags bad data, and the normalized residual, above 3, points at the meter responsible.
Predict
Two meters read the same flow: one with σ = 0.01 pu reads 0.80, the other with σ = 0.02 pu reads 0.85. What's the weighted least-squares estimate?
Each reading is weighted by : weights 10,000 and 2,500, so the estimate is (10,000 × 0.80 + 2,500 × 0.85)/12,500 = 0.81. The better meter counts four times as much, but the other still contributes. A weight of instead would give 0.8167.
Name it
The measurement model
Collect the m measurements in z and the n unknowns (bus angles and voltage magnitudes) in x. Each measurement is a function of the state plus an error: . The errors are taken as independent, zero-mean Gaussians with variances . In the DC model h is linear, ; in the AC model H is the Jacobian of h and the solution iterates, just as Newton's power flow does.
Weighted least squares
The estimate minimizes the weighted sum of squared residuals
Setting its gradient to zero gives the normal equations and the estimate
G is the gain matrix. Its inverse is the covariance of the estimate, so it tells how well each state is known. Each measurement's error spreads into every state through , which is why a gross error can hide in the estimate unless the residuals are tested.
Is the estimate any good?
If the errors really are Gaussian with the assumed σ, the minimum follows a chi-square distribution with degrees of freedom. Its mean is . The test compares J with the value that a chi-square variable exceeds only 1% (or 5%) of the time: for 3 degrees of freedom, 11.34 at 99%. A larger J says some measurement is far worse than its σ claims.
Which meter is bad?
The residuals have covariance , where . The normalized residual is a standard normal variable for a good meter, so values above about 3 are suspicious, and the largest one usually marks the bad measurement. Remove it, estimate again, and test again.
Observability and redundancy
The state can be estimated only if G is invertible: the system is observable. With exactly n well-placed measurements, J is always zero and nothing can be tested. Redundancy (m well above n, typically 1.5 to 2.5 times) is what makes bad data detectable. A critical measurement, one whose loss would make the system unobservable, always has a zero residual, so an error in it can never be detected.
Worked example
Estimate the state of the three-bus network from readings 0.83, 0.67, 0.21, −0.62 and −0.88 pu (flows 1–2, 1–3, 2–3; injections at buses 2 and 3).
Show the solution
- Measurement functions. The flows are , and , and the injections and , which give H's rows.
- Gain matrix. With weights 10,000 for the flows and 2,500 for the injections:
- Solve the normal equations.
- Residuals. The estimated flows are 0.828, 0.673 and 0.207 pu, and the residuals are all a fraction of their σ.
- Test J. J = 0.21, far below the 11.34 threshold for 5 − 2 = 3 degrees of freedom, so the set is accepted.
- Compare with the truth. The true angles, from the loads of 0.6 and 0.9 pu, are −0.08182 and −0.13636: the estimate is within 0.002 rad.
Answer = −0.08283 and = −0.13456 rad, and J = 0.21 passes the test.
Worked example
The line 1–3 meter's reading is corrupted to 0.50 pu. What do the test and the residuals show?
Show the solution
- The shifted estimate. The estimate shifts to −0.0793 and −0.1195 rad: the bad reading has dragged both angles.
- Test J. J rises to 170, far above 11.34, so the set is rejected.
- Normalized residuals. They are 6.5, 13.0, 5.8, 0.8 and 7.4.
- Find the bad meter. Several exceed 3, because the error has spread through the estimate into the other residuals, but the largest, 13.0, belongs to the line 1–3 meter.
- Remove it and estimate again. From the remaining four, J = 0.06, well below the threshold for 2 degrees of freedom (9.21), and the angles are −0.0829 and −0.1350 rad, back near the true values.
Answer J = 170 rejects the set, and the largest normalized residual, 13.0, points to the line 1–3 meter.
Worked example
Three meters read the same flow: 1.00 (σ = 0.01), 1.03 (σ = 0.02) and 0.95 pu (σ = 0.04). Find the WLS estimate, its standard deviation and J, and test J at 95%.
Show the solution
- Weights. They are 10 000, 2500 and 625, one over each σ squared.
- Estimate.
- Its standard deviation.
- Weighted squared residuals.
- Test at 95%. With 3 − 1 = 2 degrees of freedom the 95% threshold is 5.99, so no bad data is flagged; the precise meter dominates the estimate.
Answer = 1.0033 pu with σ = 0.0087 pu, and J = 3.67 is under the 5.99 threshold, so no bad data is flagged.
Check
Meter A (σ = 0.015 pu) reads 0.8 and meter B (σ = 0.05 pu) reads 0.84 for the same flow. What's the weighted least-squares estimate, in per unit?
Check
For those two meters (σ = 0.01 and 0.02 pu), what's the standard deviation of the estimate, in per unit?
Check
An estimator has 30 measurements and 5 state variables. How many degrees of freedom does its chi-square test have?
Check
A residual is 0.03 pu and the residual's standard deviation is 0.006 pu. What's its normalized residual?
Check
A meter has σ = 0.01 pu, and its row of has diagonal entry 0.005² pu². What's the standard deviation of its residual, in per unit?
Check
A reading is off from its estimate by 0.3 pu with σ = 0.01 pu. How much does that one residual add to J?
Check
Write the estimator: wls(H, z, sigma) returns the estimate, the residuals and J, and find_bad(H, z, sigma) returns the index of the meter to discard, or None when the set passes the 99% chi-square test.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Two meters read the same flow: 0.98 pu (σ = 0.01) and 1.1 pu (σ = 0.05).
(a)
What is the WLS estimate?
(b)
What is J?
Check
Two meters of standard deviations s and t read a and b for the same quantity.
Step 1
What is the estimate?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is its standard deviation?
Step 3
What is J?
Explain why
Why does a state estimator need more measurements than unknowns, and why can't it find an error in a critical measurement?
With exactly as many independent measurements as unknowns, the estimate fits every reading perfectly, so every residual is zero whatever the errors are, and nothing can be tested. Extra measurements make the readings overdetermined: good meters then agree with each other within their σ, and a bad one leaves residuals that the chi-square test and the normalized residuals can see. A critical measurement is one the system can't do without; remove it and the state is unobservable. That means no other measurement checks it, so the estimate always bends to fit it exactly, its residual is always zero, and an error in it passes straight into the state undetected. Utilities place meters so that redundancy is high everywhere and critical measurements are rare.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.