Propagating a Missing Value Through a Calculation
A calculation should make clear whether incomplete inputs cause an unknown result, a partial result, or a documented substitution.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Decide what the total means
If a purchase record contains prices of seven, missing, and three, a sum of available values gives ten. The final total of the purchase is still unknown. Include an observed count of two and an expected count of three to preserve that distinction.
Make partial work typed
A program can return both a running total and a completeness flag. Its function contract governs whether a caller may display a provisional result. Treat zero and absence separately, since replacing the missing price with zero would claim a free item.[1][2]
Keep track of which part of a total is supported
Suppose three temperature readings were expected and only two arrived, 16 and 20 degrees. The sum of observed readings is 36 and their average is 18. The sum or average across every expected reading remains unknown without another rule. Filling the gap with zero yields 12 across the three positions, a different statement about the data. A structured result can return a measured total, the observed count, and the expected count so each caller can see the difference.
Choose a consistent rule at every downstream boundary
An analysis may show partial results with a clear completeness indication. A later calculation requiring complete inputs can skip that interval and preserve the reason. If a domain allows imputed values, keep that assumption visible and distinguish estimates from readings. See missing observations in a plot.
Test a complete series containing a real zero and an incomplete one containing an absent slot. Both might give the same subtotal, yet their completeness flags and denominators should differ. Decide what to return when every value is missing before choosing any averaging operation.