A small public garden records the number of people waiting at its front desk every ten minutes. Ten observations arrive in the spreadsheet, five on each side of the median. A manager who looks only at that split might see an unremarkable afternoon. But the five higher readings could have arrived all together during one sustained busy period, or each could have been separated by a low reading. Both arrangements have the same median, the same count above it, and the same underlying collection of queue lengths. They differ in something visitors actually experience: whether busy observations bunch together or recur as short peaks.

A run is a consecutive stretch of the same sign in an ordered sequence. Mark a count above a reference as high, and one below as low. A stretch of three highs followed by two lows contains two runs, not five. Counting runs is a way to ask about adjacency without asking how large the high values were. That loss of magnitude is both a strength and a limitation. A spectacularly long queue and a reading just over the reference receive the same label. Keep the counts and times beside any sign-only analysis so a useful indication of order doesn't become the entire story.
In this example the recorded order is the order of scheduled observations at a single desk. In other work it could be the actual order of trials on a workbench, or the order in which two conditions were assigned for a comparison. Those are not always interchangeable. A spreadsheet sorted by count is no longer a record of successive conditions. A log sorted by upload time can reverse readings that were entered late. The order should reflect what the question calls neighboring observations. If that order is uncertain, the run count is uncertain too.
The NIST/SEMATECH gallery of graphical techniques includes an index to ways of exploring a sequence and its distribution. The process modeling chapter distinguishes developing, fitting, and checking a model. For the specific binary count discussed here, the NIST/SEMATECH runs-test section gives the sign convention and the conditional mean and variance used in a standard runs test. The queue example and chart are invented. None of those sources supplies their values or approves an operating threshold for a garden desk.
Runs in three hypothetical sequence presentations
Illustrative only. The following counts are invented examples, not observations, official targets, or outputs drawn from any source dataset.
| Presentation | Runs |
|---|---|
| Sorted | 2 |
| Original | 5 |
| Strictly alternating | 10 |
Use these fictional queue lengths in original order: 1, 2, 8, 5, 7, 3, 0, 9, 6, 4 people waiting. The ordered numerical values are the integers from zero to nine, so the median is 4.5. That puts the five counts from zero to four below it and the five counts from five to nine above it, with no ties. Read the chronological signs as low, low, high, high, high, low, low, high, high, low. A convenient bracketing is two lows, three highs, two lows, two highs, and one low. There are five successive groups and thus five runs.
If sorted by queue length, the five lows come first and the five highs last. There are only two runs. If arranged to alternate signs at each step, every single observation begins its own run. There are ten runs. Neither rearrangement describes a second observed afternoon. The three bars use the same balance of highs and lows and demonstrate what each presentation does to adjacency. The extreme values are the attainable endpoints for ten positions with five of each sign. They are not control limits.
The count can be checked directly. Start with one run in a nonempty binary sequence. Scan adjacent pairs and add one whenever the sign changes. The original brackets show four switches, hence five runs. Do not add a switch back from the last reading to the first unless a circular order was actually part of the analysis. A morning shift does not join to its own start just because a spreadsheet wraps on screen. The endpoints are part of the design of the statistic.
The toy median isn't a service standard. A high label says the count exceeded 4.5 in this group, not that it was too high for the number of staff, or that the people waited an unacceptable time. Queue length is a snapshot of people waiting, not a direct measure of arrival rate or of any individual's waiting time. If the operating question concerns the time somebody spent waiting, a separate observation is needed. If it concerns recurring demand relative to times of day, a global median might not be the most useful reference.
What is the assignment order, and what was actually measured?
Write down the order as early as possible. For a regularly observed queue, keep the intended timestamp and the timestamp at which the observation occurred. A glance that was planned for noon but taken at 12:07 has a chronological location and a planned position. Both are worth recording. A visitor report about time actually observed probably uses the former; a check of missed observation slots uses the latter. If observations cannot be ordered within a tied timestamp, retain the ambiguity or obtain a justified ordering from the source, rather than letting a default sort key quietly choose the sequence.
The same caution applies to a workbench run. Suppose two gauge types are to be used in alternating order, but a delayed setup means both measurements of one type occur one after another. For troubleshooting a warming instrument, actual measurement order matters. For analyzing what was assigned, the scheduled order matters. A graph labeled “run order” should indicate which of the two it means. The discrepancy is evidence about execution. It should not vanish because one column is easier to plot.
To count contiguous runs, define what can interrupt the sequence. Ten time slots across a single afternoon might form one chain. Data drawn from ten afternoons at the same clock time could be a chain of days, a different question. If the first desk closes at night and reopens in the morning, concatenating the last reading on Tuesday with the first on Wednesday adds an adjacency that may be irrelevant to within-shift persistence. In a per-shift analysis, restart the count within each shift and calibrate any combined summary using rules that respect those boundaries.
A gap within a shift has a similar ambiguity. If the counter wasn't checked for an hour, the next known reading isn't evidence that the queue remained on the same side of the reference continuously. Removing the blank and joining the neighbors defines a sequence of observed nonmissing readings, which can be a reasonable analysis when that is the scope. Treating the gap as a break instead asks about continuity within covered time. Both can be useful. Neither legitimizes inventing the intervening signs. Show the missing window in the chronological display.
Repeated values also pose a question of identity. If two photographs came from the same scheduled instant, they might be duplicate measures of one queue, not independent successive readings. If two entrances were measured simultaneously, ordering one before the other by email arrival doesn't establish temporal adjacency. Decide whether the unit is an entrance, a timestamp, or their pair. A run across entrance labels is not an ordinary sequence through time. Save those details in separate fields so a tidy table cannot silently turn co-observations into persistence.
Useful field metadata may be as simple as a note that the first desk was temporarily closed and the marks refer to the substitute. That can explain a break in the observations without implying a change in all garden traffic. A file that stores geographies or desk names only in a title can make the new series look continuous. Ask whether an apparent change of sign coincides with a change in observer, gate, time rule or unit. Those are not statistical inconveniences. They are part of the process that generated the record.
What the null comparison actually holds fixed
For ten comparable positions with five highs and five lows, a simple reference regards every placement of that fixed set of labels as equally likely. There are 252 ways to choose five of ten positions for the highs. The count of highs is conditioned on, not repeatedly allowed to fluctuate in this particular reference. Different arrangements containing the same signs can have quite different run totals. Under the uniform arrangement assumption, many patterns have run counts near the middle, whereas an entirely sorted or entirely alternating presentation is unusual.
The expected count for five highs and five lows is six under that reference. A derivation is short. Any adjacent pair has a chance of consisting of high then low or low then high. In this example the first position has an even chance of either sign, and the chance the second is opposite after that draw is five ninths. So each of the nine adjacent pairs has a switch probability of five ninths. Adding five expected switches to the one initial run gives six. This calculation uses a linear order and does not require the switches themselves to be independent.
That last qualification is worth keeping. Neighboring switches share a position and a shuffle with fixed totals constrains the entire sequence. It would be a mistake to declare the switches nine independent coin tosses merely because each may have a known marginal probability. Counting all 252 arrangements gives an exact finite reference for this toy. For example, the two sorted sign orders, all high then all low or the reverse, are the only orders with exactly two runs. The two strict alternating sign orders are the only ones with exactly ten. Each endpoint has probability two out of 252 under this benchmark.
One can check the original count without assigning it an arbitrary large-sample z score. Exactly 48 arrangements have five runs. For an order starting and ending high, the five high positions must be split into three nonempty groups, which can be done by choosing two of four gaps, giving six choices. The five low positions must be split into two nonempty groups, giving four choices. There are therefore 24 arrangements beginning high and another 24 beginning low. This is the chance of exactly five runs, not a p-value. A test tail must be defined in terms of the question before using such counts.
For this symmetric toy distribution a two-sided comparison could count arrangements at least one run away from six, because the observed five is one below six. That is every arrangement except the 72 with exactly six runs, or 180 of 252, about 0.71. To verify 72, a six-run pattern places each sign in three nonempty groups. Each sign offers six ways to split its five observations, and either sign can start, giving twice six times six. A result near the middle is no surprise under exchangeability. It does not prove the queue behaves independently, even in the example, and a deliberately generated teaching sequence has no operational inference at stake.
Alternative tests need not all find the same evidence. A preplanned question about clustering might use the lower tail of the run-count distribution. One about a schedule creating alternation might use the upper tail. Selecting the tail after looking at whether the data clustered or alternated would make the advertised error rate untrustworthy. If the question is broad, report the two-sided definition or show the whole reference distribution. In a small sample, discrete counts also mean some thresholds are impossible to attain exactly. Do not round a reference calculation into stronger significance than the design permits.
When a permutation is not appropriate
Exchangeability in this setting means, for the reference question, that reordering the signs across the permitted positions does not change their joint probability. It is stronger than saying there was no causal influence of one observation on the next. If the first five positions are known opening slots with higher expected demand and the last five are closing slots with fewer expected arrivals, independent fluctuations around those distinct expectations do not give the uniform shuffle model. Some positions are more favorable to a high sign even in the absence of serial carryover. Unexpected runs relative to an inappropriate shuffle do not establish carryover.
The order may have been intentionally constrained. A comparison in which an organizer alternated assignment types does not have unrestricted permutations of those assignments under the original design. A test of assignment ordering would find the alternation the organizer put there. If the goal is to check outcomes under that assignment, use the structure that the experiment actually allowed. For a randomized design, the unit and allowed randomizations should come from the allocation record. For ordinary observation, there is no original randomization to appeal to, so the reference needs substantive justification rather than a label saying the test is nonparametric.
A block can be meaningful when comparing readings within slots with their own baseline conditions. For example, weekdays could be analyzed separately from weekend event days. That reduces one obvious source of differences in the expected pattern, but it does not automatically make within-block readings independent or exchangeable. One visitor might remain in line across consecutive checks, or a group arrival may reshape the next several observations. If the null reference permits shuffling only within certain blocks, define how runs are counted at their boundaries and simulate or enumerate the matching statistic under that restriction. Do not just plug total highs and lows into the unrestricted expectation.
Sometimes the safer report is descriptive. If there are only a few independently scheduled shifts, a visually clear run may be worth describing without estimating how unusual it is under an unconvincing model. A sentence such as “the above-reference observations at the main desk all occurred in the first half of the measured shift” can be strong and testable. A sentence claiming that a random process was disproved needs its actual probability argument. Respecting that difference does not prevent looking for the timing of an announced group tour or a desk closure; it avoids promoting those explorations to confirmed causes.
Ties are a feature of measurement, not a license to pick signs
Queue lengths are integers. Repeated readings at a sample median are likely rather than exceptional. A standard above-versus-below coding does not assign a sign to a value exactly at the reference. Decide in advance what the analysis should do. One option is to omit tied values and count runs on the sequence of remaining signs, explicitly reporting how many were omitted. That approach can be useful for a question about the order among non-tied observations. It has a cost: previously separated neighbors can become adjacent. The result should not be described as uninterrupted time on one side of the reference.
For example, read three observed counts as high, exactly equal, high. Omitting the tie yields one run in the reduced sign sequence. Treating the tie as a break yields two separate high stretches. Assigning it to the low side under a “strictly above versus at or below” rule gives the pattern high, low, high and three runs. All assignments can be made deliberately for distinct questions. They are not three ways to get a preferred answer to the same question. They change the sign definitions, the observations considered adjacent, or both, so the reference distribution must follow the rule.
A fixed operational reference may naturally include equality on one side. Suppose a team defines an alert as at least six people waiting. At a count of six the threshold has been reached. A runs analysis of alert status could reasonably code six as alert, but that is no longer a strict sign comparison around a median. It might be unbalanced, and the number of alerts might itself matter to management. Report the rule and total on each side. A paper calculating a conditional reference for balanced hypothetical signs is not a reason to discard data that answer a real operating question.
A third neutral state can also be useful in a display. A sequence of low, neutral and high observations can show the queue lingering at a reference. It is not automatically governed by a two-sign formula. Anyone who reports a formal test with a third category needs a reference that incorporates that state. It is perfectly reasonable to keep neutral marks in a plot while using an explicitly defined two-sign analysis in a companion table. That way the mathematical simplification does not suppress the recorded behavior.
When every value ties, a strict two-sided sign sequence may have no informative observations. When every usable value lies on the same side of a fixed threshold, it has one run and no transitions. Both findings can be meaningful about the queue level. Neither permits the ordinary two-group variability calculation to provide a useful randomness test. A blank test result with a reason is better than a division by zero or a claim that one run necessarily proves dependence. Under that composition there is no alternative order of the signs to count.
Decide separately how to treat a tied value and a missing value. Equality is a valid measured outcome. Missingness means the value was not known at the intended time. The same implementation might omit both, but they have different consequences for interpretation and future data collection. A concentration of ties may show that the reference sits at a common count. A concentration of missing values might indicate that the most difficult times to observe were also the busiest. Keep those counts separate even when the final sign calculation treats their slots alike.
Read the same sequence more than one way
A run sequence plot should keep the original values and their order. Mark the reference line and flag outages or changes in desk operation. This can show whether low and high groups represent a modest crossing of the reference or a large shift in queue length. A sign-only view can sit underneath to show adjacency more clearly. Both are valuable because a series of one-step oscillations may have a very different operational cost from isolated extreme counts, even when the same signs occur in the same places.
A lag plot puts a reading beside the next one intended for the comparison. High points tending to accompany high neighbors, and lows accompanying lows, may suggest a pattern to examine. Such a plot also uses magnitudes rather than just signs. Its interpretation depends on the duration between observations and which pairs were included. A gap of an hour should not be pictured as the same lag as a gap of ten minutes without noting it. Just as with runs, a global schedule can create apparent relation even when one reading does not directly influence the next.
Consider data collected at fixed ten-minute intervals and another set collected whenever a worker had a free moment. In the second, the absence of an observation could be related to how busy the desk was. Appending the two sets or treating all adjacent readings as comparable can create a misleading pattern. A larger time gap can permit much more change in a real queue, and systematic gaps can shift the observed median. Retain the timing protocol, distinguish scheduled slots from unscheduled records, and check whether a conclusion looks different among the consistently observed periods.
Magnitude checks can catch a second problem not visible to the run count. Suppose the ten queue readings in the toy are replaced by other counts that lie on the same respective sides of their reference. The runs remain unchanged even if several high readings now exceed the earlier ones by a wide margin. A single scalar diagnostic cannot establish constancy of mean, spread, or extremes. The original sequence plot, a distribution of values by planned context, and a record of operational thresholds serve different questions. Use the run count as one view rather than as an automatic quality signature.
What clustering and alternation might mean in practice
A low count of runs can appear when the level shifts once during a shift. It can appear if the same group remains in line across several observations. It can also appear if nominally unrelated readings are grouped by a known schedule that raises or lowers expected demand. The signs alone cannot distinguish those explanations. The first next step is usually a look at the time series and the events recorded alongside it. If the most plausible explanation is a scheduled group visit, check its timing against the run rather than inventing a latent condition to improve model fit.
A high count of runs can also have several sources. Perhaps two counters are effectively being sampled in alternation. Perhaps a work pattern revisits busy and quiet points on a fixed route. Perhaps short successive observations respond indirectly to staffing changes or just happen to alternate in a short sample. The chance patterns and the planned patterns belong in the discussion at the same time. A statement of surprise under an appropriate reference does not identify a mechanism, and the mere presence of an intuitive mechanism does not establish that it created the result.
The absence of either extreme is not a clean bill of independence. A process could have a repeating pattern every three observations that the median splits happen to hide. It could vary in how large the counts are while spending a normal-looking amount of time above and below the reference. Multiple distinct sequences share each possible run count, and adjacent behavior is only one kind of dependence. Retain an explicit “did not find evidence under this diagnostic” interpretation rather than turning one non-small result into permission to ignore the schedule.
The practical implication of dependence is broader than the diagnostic itself. Ten snapshots of one queue are not necessarily ten independent draws from a garden-wide distribution. If the same visitors remain in the queue, nearby snapshots repeat information. A conventional error bar that assumes independent measurements can misstate uncertainty, often making a persistent series look more precise than it is. Use units and an analysis consistent with how the observations were acquired. Several independently sampled shifts may support a different uncertainty calculation from dozens of tightly spaced counts within one shift.
Turn uncertainty about order into a usable review plan
A field review can begin by specifying the sequence before examining the strengths of any pattern. Name the desk or device, the observation window, the intended spacing, actual timing and boundaries between sessions. Identify a reference for signs and what a tie does. Keep the source values alongside derived signs. A second reviewer should be able to count switches without guessing which columns were sorted or whether hidden rows were ignored. A rule for boundaries and omissions belongs with the analysis, not only in the analyst's recollection.
A useful reconciliation writes the number of scheduled observations, the number actually recorded, the number unusable or ambiguous, and the number tied to the chosen reference. Then record highs and lows and show that they sum to the analyzed set. If the sequence was split, give the number of segments and how switches were summed. Suppose one of ten readings was missing and one tied. The diagram might still show ten scheduled positions, while the two-sign analysis uses eight. Both counts are valid if their scope is clear.
Someone should spot-check the ordering against the source. Pick a routine portion and an exceptional one, such as two readings entered in the same minute or a desk reopened after a closure. If the analytical order changes when the software is asked to preserve the original file order rather than sort by time, find out which order represents the intended observation. A stable sort in a program is not evidence for either physical chronology. In cases where chronology cannot be recovered, a descriptive comparison can say whether plausible resolutions change the run count, without assigning probability to unseen orders.
Before reporting a formal test, ask whether the reference could generate the ordered patterns the schedule permitted. If only particular permutations were possible, specify them and apply the same tie and gap rules to hypothetical sequences. If no plausible reference is supported, report a descriptive pattern instead. In particular, do not compare the sorted bar to a formal random null as though an analyst did not put the lows first. The sorting rule determines it. Likewise the alternating bar is the deliberate high end of the illustration, not an independent observation warranting a p-value.
Predefine where the reference value comes from when possible. A sample median is a convenient down-the-middle exploration of one series. A fixed threshold determined in advance can answer an operational question. A reference estimated separately for each time slot might be more appropriate for asking about unusual dependence after typical schedule effects are removed. But estimating a reference from the same observations can alter the interpretation, especially for small or tied groups. Apply coding to simulated or permuted data in the same way it was applied to the observed sample whenever that step is relevant to the reference construction.
Three ways a plausible shortcut can change the answer
First consider a queue history that crosses a lunch break. On the two observations just before the pause, the queue was high. The two immediately after the desk reopened are high as well. If the original spreadsheet omits the pause, the four observations form a single run. That is a well-defined run of recorded signs. The story that there was uninterrupted pressure across the break is not supported. The counter followed the same classification on either side, but the opportunities for seeing or serving a queue were interrupted. A reader comparing uninterrupted busy periods needs the boundary, even if another reader prefers a reduced sequence of signs.
Next consider a busy interval with an unusually tall queue followed by a second interval that was measured only after an observer returned from helping at the desk. That delay belongs to the data. Treating the two observed counts as exactly one planned interval apart could flatten a much longer gap. On the other hand, removing all delayed observations after identifying them as inconvenient could select out exactly the busier intervals. A better first report can show the planned and actual times together. If an analysis excludes delayed slots, describe the departure rule and which periods it affected before using the remaining run count to talk about the overall shift.
A third shortcut shows up when analysts rank values before coding them and forget to restore the original sequence afterward. They may have prepared the ranks simply to find the median. That is harmless. The problem is letting the sorting operation determine the analysis order. With any set containing observations on both sides of a strict threshold, a monotone sort puts them in two groups and generates two runs. An analyst who frequently gets exactly two runs should inspect the ordering pipeline before claiming widespread persistence. For a file built in several stages, a stable original position field lets the sorting needed for one calculation coexist with the chronology needed for the other.
It can also be useful to check an opposite scenario. An export alternates two front-desk columns by flattening all values across columns row by row. Suppose one desk has consistently higher counts than the other. The exported list now alternates high and low. The pattern could be striking even though no one desk alternated in time. The issue isn't an error in the switch count; it is a mismatch between the way the list was constructed and the way the result was described. A record keyed by desk and scheduled slot allows analysis of each desk or a paired comparison across desks without treating an export convention as visitor behavior.
Choose a follow-up that can distinguish competing explanations
A long busy run may invite a simple question: was the desk busy because arrivals stayed high, or because the service rate stayed low? The sign sequence cannot settle that. An authorized record of arriving groups, short observations of how many had been served, and a note about staff changes can give those possibilities separate evidence. If a queue remained high shortly after one scheduled group arrived, that timing would support a different investigation from a run that began when one station closed. Neither explanation should be declared from a permutation result alone.
If the suspected explanation is a stable daily schedule, collect several comparably observed days. First compare slot-level patterns, such as the opening period versus ordinary mid-afternoon under the same routine conditions. Then ask whether there is more clustering within the relevant series than that context would predict. A series gathered only on one special event might usefully identify a pressure point without representing a usual day. More observation on unrelated dates changes the scope of the evidence; it does not retrospectively transform the special day into an ordinary one.
A threshold sensitivity display can be useful if a reader is deciding whether persistence matters near an operational alert level. A median-based result and an alert-based result may differ. Brief flashing peaks above a high threshold can occur within a long run of counts above the median, and several successive alerts can occur without changing the broad sign pattern much. Present the two measures with their separate definitions. If several possible thresholds were explored after seeing the series, label the exercise exploratory. Choosing the level with the most extreme result and reporting it as the only planned analysis conceals the opportunity for a chance pattern.
Finally the next measurement may require a different clock. If the operational concern is how many minutes people face a long line, snapshots every ten minutes can only bracket stretches between observations unless there is evidence between them. A short sequence of more frequent readings might be informative if it can be acquired consistently without changing service at the desk. If the concern is how many shifts experience a prolonged busy period, a broader set of shifts could be more useful instead. Ask what extra observation can discriminate among the real explanations, rather than simply collecting more signs of the same kind.
A plain-language result worth keeping
For the fictional queue, a concise result would say: “Ten comparable ordered readings gave five above-median and five below-median signs, with no ties. The chronological order formed five runs. Sorting would produce two runs; deliberately alternating would produce ten. Under a uniform fixed-count order the expected number is six. The sorted and alternating cases are presentations of the same data, not additional records.” An actual report could then add the specific reference, a result for a predeclared tail if warranted, and limitations about scheduling and coverage.
A manager may prefer the concrete observation from one realized pattern even when formal inference is not strong. If the high readings happened together, show how long the period lasted at the observation scale and which condition preceded it. If the busy periods were not fully covered, avoid implying continuous knowledge. None of this requires arranging the values to improve a picture. The record's original order is part of its evidence. A comparable second shift provides a new observation; a new sort of the first shift does not.
A run count is useful because it makes a simple feature of order visible. It becomes misleading when the order, sign definition, or plausible alternatives remain hidden. Keep planned slots and actual observation times, name boundaries and ties, and compare only with the orders the chosen reference actually permits. Then the sequence can tell the reader something a median alone cannot say, without being asked to diagnose a cause that did not appear in the record.