A wearable export lists a sample counter as 250, 254, 2 and 6. The smaller number might look like a restart or a time reversal. It could also be an ordinary counter completing its finite cycle. The record needs a counter definition before it needs a smoother graph.
The gold standard of wearable technology in this problem is a reconstructed sequence whose assumptions remain visible. A small stored counter is a repeating label. It is not, by itself, a complete elapsed-time record or a globally unique sample identity.
The short answer is to use modular differences only after establishing the counter’s range, what makes it increment, whether the device restarted, how records are ordered and how large an unseen gap could be. If several cycle counts fit the evidence, retain that ambiguity rather than silently choosing the shortest one.
This guide uses invented device records for students, parents and teachers exploring data integrity. No counter width or sample rate below describes a particular commercial wearable. The examples do not interpret medical signals. Start with The Gold Standard of Wearable Technology, and connect the learning method through The Gold Standard of Education.
eduKateSG · Wearable Technology
Find your next learning step
Reconstruct wrapping sample counters using session evidence, modular differences, gap bounds and original wearable timing examples without hiding ambiguous cycles.
Chapter contents
Understand the question · Chapters 1–5
Work the original cases · Chapters 6–10
Test the boundaries · Chapters 11–15
Repair and transfer · Chapters 16–20
Check and continue · Chapters 21–25
CHAPTER 1 OF 25 · Understand the question
1. Read the counter contract before subtracting
A counter definition should say which values are possible and what event advances it. An eight-bit unsigned counter can represent integers from zero through 255. If it increments once and wraps normally, the value after 255 is zero.
That description still leaves an important question: does it increment once per acquired sample, once per packet, once per internal clock tick or once per reported event? The same numerical difference can represent different physical quantities under those contracts.
For the first worked case, stipulate a counter that advances once per acquired sample at an exact teaching rate of 100 samples per reference second. It wraps modulo 256 and does not restart during the interval. Later chapters deliberately remove these assumptions.
Keep the raw field name and definition beside the data. A column renamed “time” can conceal that the original values were sample labels. Clear names help the reader distinguish observed counter values from reconstructed sample positions and from inferred time coordinates.
If N is an unbounded sample-position integer and the stored counter is c, the relation is c = N modulo 256 in this example. Positions N = 14, 270 and 526 all produce stored label 14.
The counter has not recorded which cycle produced the label. That information must come from retained state, session metadata, independent timing or constraints on the possible gap. A finite label is useful because it is compact, but compactness comes with this ambiguity.
An analogy is a clock face. Seeing the minute hand at ten does not by itself identify the hour, day or total elapsed duration. The repeating display can be interpreted when surrounding information supplies the missing cycle count.
Do not stretch the analogy into a claim that every counter behaves like a wall clock. A device may reset, skip labels or advance by packet length. The mathematical repetition is the common feature; the actual increment rule must come from the record’s specification.
CHAPTER 3 OF 25 · Understand the question
3. Calculate the forward modular difference
For stored values c1 and c2 with modulus M, the nonnegative forward residue is r = (c2 − c1) modulo M, chosen between zero and M − 1. In the first example, c1 = 250, c2 = 14 and M = 256.
Ordinary subtraction gives −236. Adding 256 gives the forward residue r = 20. If the actual advance is known to be nonnegative and less than 256 increments, then twenty is the unique advance compatible with those conditions.
With exactly 100 increments per reference second, the interval between those sample positions is 20/100 = 0.20 seconds. This is a conditional result: it uses the counter contract, no-reset assumption, ordering and gap bound.
The modular calculation alone does not establish that the true advance was twenty. It establishes only its residue. Keeping that distinction explicit prevents a convenient arithmetic operation from being mistaken for evidence about an unseen interval.
Take the ordered raw sequence 250, 254, 2, 6, and stipulate that every successive advance is less than 256 increments. Its forward modular differences are four, four and four.
Choose an extended starting position of 250 for convenience. Add the differences to obtain 250, 254, 258 and 262. Each extended position reduces modulo 256 to its original raw label, which supplies a simple reconstruction check.
| Record in acquisition order | Raw counter | Extended position under the stated bound | Elapsed time from first record at 100 Hz |
|---|---|---|---|
| 1 | 250 | 250 | 0.00 s |
| 2 | 254 | 254 | 0.04 s |
| 3 | 2 | 258 | 0.08 s |
| 4 | 6 | 262 | 0.12 s |
The chosen starting position is not an absolute device lifetime count. Adding a common multiple of 256 would produce another extended sequence with the same raw labels and relative intervals. The exercise reconstructs the local progression, not a missing global session origin.
CHAPTER 5 OF 25 · Understand the question
5. Keep sample positions separate from observed sample counts
The extended sequence advances by twelve sample intervals from first record to last. At 100 Hz that spans 0.12 seconds. The export contains only four listed records.
If the contract says the counter increments once per acquired sample and the stream was intended to retain every sample, a difference of four between listed records implies three intermediate sample positions are absent from this export. It does not provide their sensor values.
Between extended positions 250 and 262 inclusive, there are thirteen integer sample positions. There are twelve intervals between those endpoints. Confusing positions with intervals is an off-by-one error that can distort duration calculations.
Ask for three separate answers: how many records are listed, how many sample-position intervals separate the endpoints and how long that interval represents under the exact-rate model. The answers are four, twelve and 0.12 seconds. A correct solution keeps the different denominators attached.
The raw pair 250 and 14 has forward residue twenty, but nonnegative advances 20, 276, 532 and so on all reproduce the same pair. They differ by full cycles of 256 increments.
At the stipulated rate of 100 increments per second, those advances correspond to 0.20, 2.76 and 5.32 seconds. The raw pair alone cannot tell them apart. Selecting twenty because it is smallest is an assumption about the gap.
This ambiguity remains even if the subtraction is performed with more numerical precision. The missing information concerns which cycle occurred, rather than rounding error in the arithmetic.
For a classroom counterexample, give two fictional devices the same raw pair but declare that one interval was short and the other exceeded two seconds. The same counter labels can legitimately describe different elapsed times. The learner should ask for the gap evidence before writing one duration as though it were observed directly.
CHAPTER 7 OF 25 · Work the original cases
7. Use an independent bound to select a cycle
Suppose an independent reference establishes that the interval contains between 200 and 400 counter increments. Candidate advances are 20 + 256k for nonnegative integers k. Only 276 lies in that interval, so the cycle count is resolved under the stated evidence.
The corresponding interval at exactly 100 increments per second is 2.76 seconds. This conclusion uses both the residue and the independent bound. Neither source alone supplies the same result.
If the bound instead permits between ten and 300 increments, both twenty and 276 remain possible. Report the two candidates or the unresolved cycle count. Do not average them into 148 increments and describe that average as a reconstructed sample interval; it is not compatible with the raw residue.
This is a useful example of a discrete inverse problem. The answer may be one permitted integer, several permitted integers or no permitted integer. An empty candidate set means the supplied assumptions conflict and need review. It should not be repaired by choosing the nearest convenient number without explanation.
A counter drop does not establish rollover. Suppose a raw record ends at 250 and the next begins at three. A continuous modulo-256 counter could have advanced nine increments. A restarted session could also begin with a small counter value.
If the device reset its acquisition system, joining the two records as a continuous nine-increment interval may invent timing and identity information. A session identifier, boot counter, restart log or reliable external time can help distinguish the explanations.
The correct evidence depends on the device. A connection loss does not always mean an acquisition restart, and an application restart does not necessarily reset the hardware counter. Follow the actual field definitions rather than inferring every lifecycle event from the screen’s behaviour.
For teaching, supply two versions of the same numerical record: one with a continuous-session flag and one with a documented restart. Ask why the arithmetic residue is the same but the permitted interpretation changes. The counter’s surrounding contract is part of the data.
CHAPTER 9 OF 25 · Work the original cases
9. Separate acquisition order from arrival order
A wireless connection can deliver records out of order or in batches. The order in which packets arrive is therefore not automatically the order in which their samples were acquired.
Suppose acquisition order is 250, 254, 2, 6, but arrival order is 250, 2, 254, 6. An algorithm that treats every decrease as a new cycle may assign a later record to the wrong cycle when the delayed 254 arrives.
If extended position 258 has already been established for raw label two, a slightly earlier raw 254 may belong to extended position 254, rather than 510. Identifying that possibility requires a justified reordering window or another ordering field.
Keep arrival timestamps and acquisition identifiers in separate columns. Arrival time is useful evidence about delivery. It becomes acquisition time only under additional justified assumptions. The earlier two-marker clock-calibration guide explains why processing and delivery delays should remain distinct from clock-coordinate conversion.
CHAPTER 10 OF 25 · Work the original cases
10. Understand the half-range comparison condition
For a repeating range of size M, a bounded signed comparison can represent differences smaller in magnitude than M/2. With M = 256, raw values separated by exactly 128 are intrinsically ambiguous under that symmetric comparison rule.
For example, label ten and label 138 are half a cycle apart. Moving forward 128 increments or backward 128 increments reaches the other label. The raw pair does not prefer one direction.
The RFC 1982 serial-number arithmetic specification defines finite sequence-space comparisons in its DNS setting. It is an authoritative example of why ordinary integer ordering is insufficient for wrapping labels. It is not a wearable-device specification.
Our simple forward reconstruction uses a different explicit condition: known forward acquisition order and an advance smaller than one full modulus. A bidirectional ordering problem involving delayed records needs stronger constraints. Do not apply a half-range rule without naming the ordering assumptions or claim that one formula solves arbitrary packet history.
CHAPTER 11 OF 25 · Test the boundaries
11. Keep duplicate detection conditional on the session
Two records with raw counter fourteen may be duplicate deliveries of the same sample. They may also be different samples separated by one or more full counter cycles. The raw label alone is not globally unique.
Reliable duplicate handling needs a suitable identity, such as a session plus extended sample position established under valid constraints. Other fields can contribute, but their meaning must be documented. Equal sensor values are not proof of duplicate identity; a stationary signal can legitimately repeat.
Conversely, differing arrival times do not prove that records are different acquisitions. A delayed retry can deliver the same payload later. Delivery identity and sample identity are related but distinct.
For an original ledger exercise, give learners two records with equal raw labels, equal payloads and different receipt times. Then provide either the same extended session identity or evidence of a full-cycle separation. Ask them to revise the duplicate conclusion only when the new evidence warrants it.
CHAPTER 12 OF 25 · Test the boundaries
12. Distinguish a sample counter from a packet counter
Suppose a packet contains ten samples, while its packet counter advances once per transmitted packet. A packet-counter difference of four does not mean four sample intervals. It describes four packet-position increments under that contract.
If every packet is stipulated to contain ten consecutive samples with no overlap, additional packet layout information may connect the packet progression to sample positions. Variable packet sizes, retransmissions or partial payloads require a more detailed account.
The problem is especially easy to hide when both fields are named “sequence”. A sound record should say whether a counter indexes samples, packets, bytes, events or clock ticks. Units and identity semantics belong to the schema, not merely to comments added after analysis.
An effective diagnostic asks the learner to state what one increment means before doing a subtraction. If that sentence is unavailable, a duration inferred from the counter is premature. The arithmetic cannot supply a missing acquisition contract.
CHAPTER 13 OF 25 · Test the boundaries
13. Add clock-rate calibration after unwrapping
An extended sample position is not automatically an exact reference-time coordinate. The sample clock may differ from its nominal rate, and the timing of the first sample still needs an origin.
Suppose independent markers show that 10,001 sample intervals correspond to 100 reference seconds. The estimated constant interval rate is 100.01 intervals per reference second. A gap of 1,000 intervals then represents 1,000/100.01 seconds, approximately 9.999 seconds, under that fitted model.
Using the nominal 100 Hz label would give exactly ten seconds. The difference is small here, but its size does not decide whether the assumptions are justified. Calibration and counter reconstruction solve different parts of the timing problem.
First identify the extended sample positions and any unresolved cycles. Then fit the mapping from those positions to a suitable reference using independent evidence. A clock fit based on incorrectly unwrapped positions can produce a convincing line while preserving a wrong cycle assignment.
CHAPTER 14 OF 25 · Test the boundaries
14. Choose a range that matches the logging assumptions
In an invented 16-bit sample counter, the modulus is 65,536. At an exact 100 increments per second, one full cycle lasts 655.36 seconds. The example says nothing about which counter a commercial device uses.
A wider range postpones repeated labels but does not eliminate lifecycle questions. A restart can occur before a counter wraps. A long outage can still hide one or more cycles, and out-of-order delivery still needs appropriate treatment.
The useful design question is whether the retained metadata and observation bounds are sufficient over the intended gaps and session duration. “The number is large” is not a complete identity guarantee.
The RFC 9187 discussion of sequence-number extension describes retaining additional endpoint state under explicit bounded-reordering conditions. Its setting is network protocols. The transferable lesson is that extending a finite sequence relies on stated constraints and maintained state, rather than on arithmetic that can reconstruct arbitrary missing history.
CHAPTER 15 OF 25 · Test the boundaries
15. Bound a reconstruction rather than pretending to know it
Suppose the raw advance residue is twenty and independent timing permits a reference interval between 2.5 and 3.0 seconds. Under an exact 100 Hz counter, candidate advances must lie between 250 and 300, leaving only 276.
Now suppose the timing window is 0.1 to 3.0 seconds. Advances twenty and 276 both fit. A report can preserve them as discrete alternatives with corresponding intervals 0.20 and 2.76 seconds. A continuous range alone may hide that the intervening values are not compatible with the raw counter pair.
If the rate is also uncertain, convert the time bounds into a justified range of possible increments before selecting candidates. For instance, with rate bounded between 99 and 101 increments per second and duration between 2.5 and 3.0 seconds, a conservative increment range is 247.5 to 303. Candidate 276 still fits uniquely in this construction.
These are deterministic compatibility checks, not confidence intervals. They do not assign probabilities to the surviving candidates. A probability model would need further assumptions about rate, time evidence and missing intervals.
CHAPTER 16 OF 25 · Repair and transfer
16. Preserve the raw and reconstructed records together
A useful reconstruction ledger retains raw counter value, counter width or modulus, increment meaning, session identifier, acquisition ordering evidence, receipt time, extended-position candidate and the assumptions used to select it.
Keep the original export unchanged and place reconstructed fields in additional columns. If a later restart log changes the interpretation, the original evidence remains available. Record the reconstruction version and the reason for a revised cycle assignment.
Use explicit states such as resolved, ambiguous and incompatible with current assumptions. A blank extended position should not quietly become zero. Likewise, “no valid candidate” should trigger review rather than an undocumented repair.
Ask another reader to reconstruct one interval from the ledger alone. They should be able to find the modulus, raw pair, permitted cycle count and timing conversion without guessing how the analyst handled a decreasing value. This is a practical test of whether the explanation is reproducible.
CHAPTER 17 OF 25 · Repair and transfer
17. Diagnose three attractive but unreliable shortcuts
Shortcut one: whenever the counter decreases, add one full modulus. This works only under suitable ordered, bounded-gap conditions. Reordering, restarts and multiple hidden cycles can invalidate it.
Shortcut two: treat repeated counter labels as duplicates. This ignores cycle reuse and session identity. A duplicate decision needs more than a repeating finite label.
Shortcut three: divide a modular difference by the advertised sample rate and report the result as observed elapsed time. This hides both the cycle-count assumption and the rate model. The output is an inference, not a directly measured duration.
For each shortcut, supply a small counterexample before presenting a more elaborate algorithm. The learner should identify which condition failed. A complicated spreadsheet that repeats an unjustified shortcut across thousands of rows is less useful than a small ledger that preserves the unresolved cases correctly.
Use a fictional counter with modulus 1,000 and known forward acquisition order. Raw labels are 990, 5, 20 and 35. Stipulate that every successive advance is less than 1,000 increments and that no restart occurs.
Each modular advance is fifteen. Taking the first extended position as 990 gives 990, 1,005, 1,020 and 1,035. Reducing each modulo 1,000 returns the raw sequence.
At an exact 50 increments per second, the elapsed intervals from the first record are zero, 0.30, 0.60 and 0.90 seconds. The span contains 45 increment intervals, while the export lists four observations.
Now remove the gap bound between the first two records. Advances fifteen, 1,015 and 2,015 are all compatible with the raw pair. The earlier 0.30-second interpretation is no longer established. This changed-condition step is the real transfer test: a valid method can become underdetermined when one supporting assumption is removed.
Task A: M = 256, c1 = 240 and c2 = eight. Find the forward residue. Answer: 24. State the additional bound required before equating that residue with the true advance.
Task B: at an exact 80 increments per second, what interval does a confirmed advance of 24 represent? Answer: 0.30 seconds. Do not infer the interval until the advance and rate assumptions are supplied.
Task C: M = 256 and the raw residue is forty. The true advance is between 250 and 350. Which candidate fits? Answer: 296. The candidates are forty plus integer multiples of 256.
Task D: two labels differ by exactly half of an even modulus. Can a symmetric bounded comparison infer a preferred direction from those labels alone? Answer: no. The two half-cycle directions are equally compatible.
Task E: a packet counter advances by one and its payload contains twenty sensor samples. Does one counter increment mean one sample interval? Answer: not under that packet-counter contract. Read the packet layout and acquisition definition.
CHAPTER 20 OF 25 · Repair and transfer
20. Build a repair, stabilisation and extension pathway
For repair, begin with a small cycle such as zero through nine. Count forward from eight to two and compare ordinary subtraction with the forward residue. Keep the physical meaning as abstract increments until the modular idea is secure.
For stabilisation, give an ordered short sequence and require a reconstructed extended sequence plus a modulo round-trip check. Add a declared rate only after the sample-position differences are correct.
For extension, introduce a long gap, a documented restart or delayed arrival. Ask which additional evidence could resolve the ambiguity and which cases remain unresolved. The learner should not be rewarded for producing one smooth timeline at the expense of the data contract.
Parents can ask, “What does one count represent?” Teachers can ask, “How many full cycles could have occurred without changing these two labels?” Both questions locate the reasoning before the software. This reflects the first-principles progression in the learning guide: explain the method’s boundary, then change one condition and test whether the method still applies.
Does a smaller counter mean time went backwards? No. It may indicate normal rollover, a restart, reordering or another change. The surrounding evidence determines which interpretation is justified.
Can unwrapping recover missing sensor values? No. It can help reconstruct sample positions under valid assumptions. Values not present in the export remain unobserved unless another source supplies them.
Does a wider counter solve the whole problem? No. It changes the cycle length but does not establish session continuity, acquisition order or an exact clock rate.
Should ambiguous intervals be deleted? Their treatment depends on the analysis question. Preserve their status and assess how the uncertainty affects the conclusion rather than silently replacing or excluding them.
Are these examples instructions for a particular device? No. They are invented contracts for learning. A real export must be interpreted using its own specification and validated behaviour.
CHAPTER 22 OF 25 · Check and continue
22. Interpret a packet timestamp with its sample layout
Suppose a fictional packet contains four consecutive samples at extended positions 500, 501, 502 and 503. Its timestamp is documented as belonging to the last sample. At an exact 100 Hz rate, a last-sample reference time of 10.030 seconds places the other samples at 10.000, 10.010 and 10.020 seconds.
Assigning 10.030 seconds to every sample would collapse their timing. Treating the packet timestamp as the first sample’s time would shift the entire packet by three intervals. Both mistakes can occur even when the counter unwrapping is correct.
If the timestamp instead belongs to packet transmission or receipt, those sample times cannot be inferred through the same rule without additional latency and acquisition information. The timestamp contract and the payload layout must be read together.
For an extension, let successive packets contain different numbers of samples. A packet-counter increment still does not determine how many sample intervals have elapsed. The payload’s first or last sample position, length and continuity information become relevant.
Ask learners to draw a short sample-position line and attach the timestamp to the endpoint named by the contract. Then reverse the contract from last sample to first sample and identify which values change. The exercise makes a common off-by-one timing shift visible without requiring a real device or a large dataset.
This also clarifies what a packet provides as evidence. It may contain several valid acquired samples even though only one delivery event occurred. Counting deliveries, sample positions and observed sensor values answers three different questions. Preserve all three quantities when evaluating completeness or timing.
CHAPTER 23 OF 25 · Check and continue
23. Test a proposed gap repair against every retained field
Suppose a reconstruction chooses an advance of twenty for the raw pair 250 to fourteen. An independent session log then establishes that at least two reference seconds elapsed, while the stipulated counter rate remains exactly 100 Hz.
The proposed 0.20-second repair conflicts with that log. Candidate 276, representing 2.76 seconds, may fit if the log also limits the interval below three seconds. The appropriate correction is to revise the cycle assignment and retain the reason, rather than change the log merely to keep the original smooth timeline.
Now suppose a separate acquisition record states that the device generated exactly 150 sample intervals between those endpoints. No candidate 20 + 256k equals 150. At least one retained field, counter definition or continuity assumption is incompatible with the others.
The contradiction is useful. It narrows the next investigation to definitions, restart state, record matching or the reliability of the independent count. Silently choosing 150 because it lies between two modular candidates would destroy the raw-counter relation rather than reconcile the evidence.
For learning, require a repair proposal to pass three checks: reducing reconstructed positions modulo M returns every raw label; the increment count fits the independent gap bounds; and the resulting time mapping fits the relevant reference evidence. Passing only one check is insufficient.
Keep the original and revised reconstructions as separate versions when a material ambiguity is resolved later. A report might say, “The shortest-gap interpretation was rejected by the session log; a single additional full cycle is now supported.” This is a concrete explanation of the evidence change, rather than a vague statement that the data were cleaned.
The method should also state when the available fields cannot be reconciled. A useful scientific record can end with a defined unresolved interval. Inventing a complete timeline may make a chart easier to read while making its timing claims less defensible.
CHAPTER 24 OF 25 · Check and continue
24. Check the reconstruction through a second representation
A useful independent representation is a table of cumulative increments from the first retained record. For the raw sequence 250, 254, two and six, the confirmed local increments are zero, four, eight and twelve. Adding the initial raw position returns 250, 254, 258 and 262 before reduction modulo 256.
This table makes the arbitrary cycle origin visible. Replacing the initial extended position 250 with 506 shifts every extended position by 256, but leaves the local increments and inferred relative durations unchanged. The record’s absolute cycle number remains unknown while its bounded local progression can still be useful.
Ask the learner which conclusion changes under that shift. A claim about lifetime sample number changes; a claim about the 0.12-second local span does not, under the same exact-rate and gap assumptions. This separates information that the reconstruction supplies from information it never contained.
For a final check, reduce the shifted positions 506, 510, 514 and 518 modulo 256. They return the same raw labels. Agreement with the raw sequence is necessary for a reconstruction, but the existence of these alternative global origins shows why that agreement alone cannot establish a unique lifetime history.
CHAPTER 25 OF 25 · Check and continue
25. Report the reconstruction and continue learning
A useful report says: “Under a modulo-256, no-reset, acquisition-ordered sample-counter model with successive advances below 256, labels 250, 254, two and six unwrap to relative positions zero, four, eight and twelve. At the stipulated exact 100 Hz rate, the span is 0.12 seconds. Larger gaps or restarts require additional evidence.”
For device context, return to Wearable Technology. For the next timing stage, read two-marker clock calibration. For a separate incomplete-record problem, use time-of-day wear coverage.
The primary sequence-space references are RFC 1982 and RFC 9187. Their protocol settings are distinct from the invented wearable examples. Continue through Learning That Transfers into Life and How X Works with one question: which assumption makes the reconstructed timeline unique?