Skip to main content
Advanced Statistical Methods

Run Test for Randomness

Published: 2026-08-11
Level: postgraduate
Audience: Postgraduate students in Advanced Statistical Methods

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • Statistical literacy and descriptive measures — how charts and comparisons mislead, and the mean, median, mode, and variance, were introduced in Lecture 1; the wrap-up and the median-based run test return to them
  • Normal distribution and Z-scores — the normal curve, standardizing with Z, and reading probabilities from the table were covered in Lectures 2 and 3; every test in this lecture's exam review leans on them
  • Hypothesis testing and the two types of error — null and alternative hypotheses, one- and two-tailed tests, and type 1 and type 2 errors from Lectures 3 and 4; the run test reuses the same skeleton
  • Chi-square tests — the chi-square distribution arrived in Lecture 5, and the tests of independence and goodness of fit were developed in Lecture 6; the review names both as exam material
  • One-way ANOVA — the between-group versus within-group variation decomposition and the F test were worked in Lectures 7 and 8
  • Regression: simple, multiple, and logistic — least squares and interpretation from Lectures 7 to 9, residual analysis and dummy variables in Lecture 10, and the full logistic model in Lecture 11, with R-squared, adjusted R-squared, and multicollinearity from Lectures 8 and 9
  • PCA and LDA — dimensionality reduction, the eigenvalue recipe, and discriminant analysis from Lectures 12 to 14; the exam tests interpretation of supplied values
  • Cluster analysis — the agglomeration schedule and dendrogram were read in Lecture 14, and the review expects the maximum-jump rule for the number of clusters

Run Test for Randomness

This final session closes the non-parametric part of the course with the run test — a simple procedure that checks whether a sample really is random — and then moves into a complete review for the comprehensive exam: which topics to focus on, how the question paper looks, and what to expect. The run test is the last technique in the non-parametric portion of the syllabus, which also includes the sign test. The session ends with a short wrap-up of the course and the ideas that matter most about using statistics honestly: data becomes information, information becomes insight, and a little statistical discipline protects us from the mistakes that make data lie.

16.1 What Is a Run?

16.1.1 Why Test for Randomness at All?

Hook. Every researcher says "this sample is random." How do you actually check that claim — without simply taking someone's word for it?

People routinely say "this is a random sample drawn from the population" and never verify the claim. The run test exists to validate that claim: it inspects the order in which the observations appear and asks whether that order looks like chance or like a hidden pattern. This is exactly the situation in production-line quality control — a machine turns out items one after another, and each item is recorded as defective or non-defective. The sequence of these two symbols carries the information, not just the total counts of each kind. Ten defectives out of a hundred means one thing if the defectives arrive together in a burst, and another if they are scattered evenly through the day; the order of the records is a fact about the process that the counts alone cannot see.

The run test belongs to the non-parametric family of procedures. It works with signs and symbols rather than with raw numbers, so it does not lean on the normality and sampling-theory assumptions that parametric tests use. The non-parametric part of the syllabus covers two procedures of this kind: the sign test (already done) and the run test (this topic). The run test is the useful technique whenever you want to justify that a given sample is random or not.

16.1.2 Definition of a Run

A run is a sequence of like elements. More carefully: a run is a maximal block of identical symbols in the sequence — as long as the same symbol repeats, the block stays inside one run; the moment the symbol changes, a new run begins.

Intuition + analogy — streaks of weather. Think of a week of daily weather reports: sunny, sunny, sunny, rainy, rainy, sunny. The three sunny days are one spell, the two rainy days are a second spell, and the last sunny day is a third spell. A run is exactly a spell of identical symbols in a row: the weather type is the symbol, and the number of spells is the number of runs. Where the analogy breaks: weather genuinely clusters (a rainy week tends to stay rainy), so finding few weather spells tells you nothing about randomness in the real sky — whereas in the run test, clustering is precisely the evidence of a pattern we are hunting for.

Use two symbols, for non-defective and for defective. In the arrangement , the five 's form one run and the four 's form another run — two runs in total. If the same nine items were laid out as , every single symbol would start a fresh run and the count would be far larger. The run count is a fingerprint of the ordering: it tells you whether the same symbols bunch together or scatter.

16.1.3 What Patterns Break Randomness

Common sense already points at the answer before any formal test, and two extreme patterns are suspicious:

  • Too many runs — the symbols alternate almost perfectly, like . A truly random process produces long stretches and short stretches by chance; it does not politely alternate forever. This is the alternation pattern.
  • Too few runs — the symbols cluster, all non-defectives in one place and all defectives in another, or all T's followed by all H's. This is the clustering pattern.

In both cases, we anticipate without any doubt that the sequence is not happening at random — there is either an alternating behavior or a clustering at work. A rough look, however, is not evidence. The run test turns this intuition into a decision rule with a stated level of significance: you count the runs, work out how many runs randomness would typically produce, and then decide.

Picture the difference on a simple chart. Draw the twenty symbol positions as a row of small squares along the horizontal axis, and shade each square by its symbol (say light for T, dark for H). Bracket the like-colored blocks with rounded bars underneath. In a clustering pattern, the row shows two large shaded blocks with a single boundary; in an alternation pattern, the row looks like a striped barber pole with a boundary between nearly every pair of squares. The landmark is the number of boundaries — that is the run count, and the visual message is: few big blocks or many thin stripes both smell non-random.

16.1.4 Counting Runs: A 20-Symbol Example

Worked example — count the runs in twenty symbols. Take this arrangement of twenty symbols of two kinds, T and H:

Walk through the sequence symbol by symbol and close a run whenever the symbol changes:

Run Symbols Length
1 T T 2
2 H H 2
3 T T 2
4 H H H 3
5 T T 2
6 H H 2
7 T T T T 4
8 H H H 3

Count them: run 1 = TT, run 2 = HH, run 3 = TT, run 4 = HHH, run 5 = TT, run 6 = HH, run 7 = TTTT, run 8 = HHH. Altogether that is eight runs in twenty observations. Sense-check: the total length is , exactly the number of symbols we started with, so no symbol was lost and none was invented.

The counting itself is a very simple procedure: identify the runs, count them, and use that number. But even with eight runs counted, the number alone is not yet concrete evidence about randomness. If the symbols alternate a lot you can get many runs; if all T's are clubbed at one end and all H's at the other, you get the minimum number of runs. Few runs and many runs both look non-random by common sense, yet we still need to know how many runs to expect when randomness really holds. That expectation comes from the sampling distribution of the number of runs, which is the heart of the formal test that follows.

Recap + bridge. A run is a maximal block of identical symbols; the run count is the fingerprint of the ordering — too many runs mean suspicious alternation, too few mean suspicious clustering. The number alone proves nothing until it is measured against what randomness would typically produce. That yardstick — the sampling distribution of the run count — is built in the next section.

In the field, the run test guards production quality: a bottling plant records filled/underfilled bottles in sequence, and a clustered run of underfilled bottles signals a worn valve that fails intermittently, while a strict alternation pattern can signal a counter that double-counts. The same check is used to validate random number generators in simulation software — if the output of a "random" generator shows too few runs, the generator is repeating patterns and every simulation that feeds on it is suspect.

16.2 The Run Test: Large-Sample Procedure

16.2.1 Stating the Hypotheses

Example setup: the following is an arrangement of defective and non-defective pieces produced in a given order by a certain machine. Decide whether the arrangement is random, at the 1% level of significance.

Step one, as with any hypothesis test: write the two logical statements.

  • (null hypothesis): the arrangement is random.
  • (alternative hypothesis): the arrangement is not random.

If the evidence supports the null hypothesis, the arrangement passes as random. If we reject , we conclude that a pattern is involved in the arrangement — clustering, alternation, or some other ordering — and that the pieces did not come in a purely random order. The level of significance is set first: . The same logic you already know from the Z test, the t test, and the chi-square test applies to this choice and to everything that follows from it: is the probability of wrongly rejecting a true — here, the chance of calling a genuinely random arrangement "patterned".

16.2.2 When the Normal Approximation Applies

Let = the number of symbols of the first kind (say ) and = the number of symbols of the second kind (say ). The test statistic is , the number of runs.

Thumb rule: if neither nor is less than 10, then the sampling distribution of is well approximated by a normal distribution, and we can test using the Z distribution and the normal tables. Why approximate to the normal at all? The same reason as everywhere else in the course: the normal tables let us read off probabilities and give a clean decision rule.

A note on the condition: it matters. The normal-approximation procedure applies only when both and ; smaller samples cannot use this procedure. This mirrors what you saw with the sign test: with fewer than 20 observations it goes to the binomial distribution, and only beyond that does it move to the normal large-sample case. In parametric procedures the conventional large-sample threshold is . The run test has its own specific condition, and you must check it before reaching for the Z test.

16.2.3 Mean and Standard Deviation of the Number of Runs

Under (randomness), the number of runs behaves as a normal random variable with mean and standard deviation . In words: "I need the value of mu and the value of sigma — the formula is given, and we plug in and ." The mean formula is:

Why this form? Think of the symbols laid in a row with boundaries between consecutive symbols. Write . The number of runs equals 1 plus the number of boundaries where the symbol changes. For a random arrangement, every arrangement of the N's among the positions is equally likely, so at any one boundary the probability of a change is:

(two orders — N-then-D and D-then-N — out of the ordered choices of symbols for the two positions). Adding up the boundaries gives the expected number of changes , and adding the 1 for the first run gives . Check the number: , so , as stated.

The variance formula is:

This is the standard large-sample variance of the run count (the combinatorial derivation follows the same counting over boundaries); here it is confirmed numerically against the value stated in the problem. Work the numbers for the example. The arrangement has runs, symbols of kind , and symbols of kind . Both counts satisfy the not-less-than-10 rule, so the normal approximation applies. With these values follows a normal distribution with mean and standard deviation . Check the mean: , so . The variance formula gives:

whose square root is , matching the stated value.

A notation note: the number of runs is written here; some books write . Either is fine.

16.2.4 The Z Test and the Decision

If is a normal random variable with mean and standard deviation , the way to find probabilities is to transform it: . In words, "take the value, subtract the mean, divide by the standard deviation." The same move applies to the number of runs:

Worked example — the machine arrangement, end to end. A machine produces pieces recorded in order as defective () or non-defective (); the recorded arrangement has runs, with N's and D's. Test randomness at .

  1. Hypotheses: : arrangement is random; : arrangement is not random.
  2. Condition: and , so the normal approximation applies.
  3. Mean and standard deviation: ; , so .
  4. Test statistic: .
  5. Critical values at , two-tailed: in each tail, so from the normal tables.
  6. Decision: , so lands in the left rejection region. Reject : the arrangement is not random — the defective and non-defective pieces are ordered in a pattern, not by chance.

Sense-check: under randomness we expect about 13.6 runs, but the machine's record shows only 6 — far fewer runs than chance would usually produce, which is the clustering signature of a process that is not behaving randomly.

At with a two-sided test, split the significance level between the two tails: in each tail. The critical values are plus 2.575 and minus 2.575. The observed value falls below , so it lands in the rejection region. If the Z value lies between and we accept ; outside it, we reject.

Picture the decision on the normal curve. Draw the horizontal axis in Z units (from about to ); the vertical axis is the probability density of the standard normal. The curve is a bell centered at 0. Mark and with vertical cut lines: the two outer regions each hold 0.005 of the total probability, and between the cuts sits 0.99. The observed value sits far left of the cut, inside the outer region. The takeaway: a run count this low happens by chance less than half of one percent of the time, so the pattern is real, not luck.

Pitfalls.

  1. Skipping the check. The normal approximation is invalid for small samples; using the Z test anyway gives misleading decisions. Check both counts before touching the tables.
  2. Mixing up the mean formula. The mean is , not . The counts the first run and is easy to drop under exam pressure.
  3. Using one-tailed critical values in a two-tailed test. At the critical value is (each tail holds ), not . The alternative hypothesis "not random" covers both directions, so both tails matter.
  4. Swapping and or . is the run count, and are the symbol counts; a run test with but is a different (and wrong) calculation.

Exam note. Expect a run test question that walks through exactly this structure — the hypotheses, the normal-approximation condition, and , the Z value, and the decision at a stated level of significance. Write the steps in this order and the arithmetic follows mechanically.

Recap + bridge. The large-sample run test compares the observed run count with its expected value under randomness via , using the normal tables for the decision. The formula works only when both symbol counts are at least 10. Next: the same procedure when the data arrive as raw numbers rather than ready-made symbols — the median does the conversion.

The same procedure runs daily in manufacturing quality control: an assembly line records each unit as pass or fail in order, and a clustered run of failures flags a tool that is wearing out, while alternating pass/fail patterns flag an inspection counter that is out of step. The two-tailed logic matters there too — either extreme tells the line manager something different about the process.

16.3 Numeric Data: The Median Approach

16.3.1 The Problem with Numeric Data

Hook. The symbols were handed to you in the defective/non-defective example. But what do you do when the data are just numbers — lifetimes in hours, prices in rupees, waiting times in minutes — and someone still asks "is this sequence random?"

Sometimes the symbols are handed to you directly — the defective/non-defective arrangement above is one example. But a problem can also come as raw numbers. Example: the data listed below are the lifetimes, in hours, of batteries produced by ZEDA, and you must decide whether the sample came from the batteries produced by this company in a random way.

When the data are numbers, the run test still needs symbols, so the first task is to decide how to build them. Before showing the standard way, try to guess: how would you assign symbols to numerical values? The standard approach is to use the median as the reference point: first find the median of all the observations, then compare every value with it. Anything above the reference becomes one symbol, anything below becomes the other symbol, and the sequence of symbols is what the run test counts.

16.3.2 Finding the Median

Step 1: calculate the median of all the observations. Recall the two median rules.

If is odd, the median is the value at position after arranging the data in ascending order:

If is even, the median is the average of the two middle values:

In words: "if it is an odd number of observations, the median is the (n+1)/2-th position after arranging the entire data in ascending order; if n is even, the median is the average of the n/2-th and the (n/2 + 1)-th positions." Every symbol means the -th smallest value in the sorted list, so sorting smallest to largest is a mandatory first move.

Worked with the battery data: the sample has observations, which is odd, so the median sits at position — the 28th value after sorting smallest to largest. Sorting the ZEDA lifetimes puts 266 at that 28th position, so the median is 266.

Side example, only to practice the position rule: with observations, the median is at position . Suppose the 27th ordered value is 266; then the median is 266. The value 266 was a stand-in to illustrate the rule — what matters is the position arithmetic, not the number itself.

16.3.3 Converting Values into A and B Symbols

Step 2: use the median as the reference and compare every observation with it.

  • an observation above the median becomes ;
  • an observation below the median becomes ;
  • an observation equal to the median is discarded — it carries no above/below information.

Why discard the ties? A value exactly equal to the median is on neither side of the divider, so it cannot honestly be called above or below. Forcing it into one of the symbols would smuggle a decision the data do not support — so it is dropped from the symbol sequence, and the symbol counts and are tallied from the remaining values. With the ZEDA data, the two values equal to 266 are discarded, leaving 53 observations for the run test.

With 266 as the reference: 270 is above 266, so it becomes ; 280 is above, so ; 248 is below, so . Values equal to the median are discarded. Repeating this for every value turns the whole numeric list into a symbol string like , and once the string exists, the rest of the procedure is the run test from 16.2.

16.3.4 Finishing the Test

With the A/B string in hand, the steps are:

  1. Count the runs in the string.
  2. Count = number of 's and = number of 's, and check that neither is less than 10.
  3. Compute and with the formulas from 16.2.3.
  4. Compute .
  5. Compare with the critical value at the given and decide whether the sample is random.

Worked example — the ZEDA battery lifetimes, completed. The 55 lifetimes are sorted; the 28th ordered value is 266, so the median is 266. The two batteries with lifetime exactly 266 are discarded, leaving 53 observations: 26 above the median and 27 below. Converting each value into (above) or (below) gives the symbol string

Counting runs in this string: runs — the same counting procedure as the T/H example in 16.1. Now run the large-sample test:

  1. Hypotheses: : the lifetime sequence is random; : it is not random.
  2. Condition: and , so the normal approximation applies.
  3. Mean: .
  4. Standard deviation: , so .
  5. Test statistic: .
  6. At (two-tailed), the critical values are . Since , the value lands in the rejection region. Reject : the sequence of battery lifetimes is not random.

Sense-check: a random sequence of 53 values with 26 A's and 27 B's would typically produce about 27.5 runs; the observed 17 runs means the lifetimes cluster — long-lasting and short-lasting batteries bunch up instead of mixing evenly, which is exactly the pattern the run test is designed to catch.

Exam note. The odd/even median rules are a likely starting point for a numeric run-test problem — know them by heart, including the position. The conversion of numbers into A and B symbols is the common first move, so practice turning a raw list into a symbol string quickly and accurately.

16.3.5 Student Questions

Q: Is the median value given in the question? A: It is not given. The median is an approach we chose to build the symbol arrangement — a reference point we adopt so the numbers become symbols. There is no hard-and-fast rule that fixes the choice. Working with symbols rather than raw numbers is what non-parametric testing is about: we never lean on the numeric values themselves, only on which side of the reference each one falls.

Pitfalls.

  1. Forgetting to sort before locating the median. The -th position refers to the sorted list, not the order the data were recorded in.
  2. Discarding or keeping ties inconsistently. Every value equal to the median is dropped — and dropped before the symbol counts and are tallied, since the discarded values take part in neither symbol.
  3. Using the wrong median position for even . With even the median is the average of the -th and -th values; the formula is not .
  4. Counting runs before the string is complete. A single missed run shifts by one and can flip the decision, so re-count the A/B string once before computing .

Recap + bridge. When the data are numbers, the median is the reference: above becomes , below becomes , ties are discarded, and the resulting symbol string feeds the identical large-sample run test from 16.2. The natural next question — why the median rather than the mean, and whether other references are allowed — is answered next.

The median-based run test is standard practice in reliability engineering: battery and component lifetimes are recorded in production order, and a clustered sequence of short lifetimes flags a bad raw-material batch that entered the line at one point in time. The same conversion to symbols lets engineers run a randomness check on data that never came with symbols attached.

16.4 Why the Median? Reference Points in Non-Parametric Tests

16.4.1 The Median as a Positional Average

Hook. In parametric tests the mean does all the work. Why does the non-parametric run test quietly replace it with the median?

Why does the run test lean on the median rather than the mean? The mean is the engine of parametric statistics: in parametric procedures the sample mean is used to represent the population mean and the sample standard deviation is used to represent the population standard deviation. Those moves have theoretical justifications drawn from sampling theory. When we step into non-parametric procedures, the underlying assumptions do not hold, so those justifications fall away.

The median is a positional average: it depends on position in the sorted data, not on the size of the values. It splits the ordered data into two equal halves, which is exactly the property the sign test and the run test need. Picture the sorted data as a line of dots along a number line; the median is the dot that divides the row into two equal groups — half the dots to its left, half to its right. The sizes of the values do not matter; only the position of the divider does. Some non-parametric procedures go further and use ranks instead of signs or runs — the same spirit, different material: replace the raw numbers with their positions, signs, or ranks, and test on those.

16.4.2 The Sign-Test Connection

This is the same logic you saw in the sign test: the whole data set is divided into two halves with the help of the median. Because the median splits the distribution into two equal halves, the probability of a value landing on either side is . The run test inherits the same reference point: the median is the natural divider, and the A/B symbols are nothing but a record of which side of the divider each value falls on.

So the two non-parametric procedures share one mental picture: a vertical cut through the sorted data at the median, a record of which side each observation lands on, and a test built from those records — the sign test counts the sides, the run test watches how the sides alternate.

16.4.3 Median, Mean, or Mode — All Can Work

The median is the customary reference, but it is not the only one, and no hard rule forces it. You could take the mode as the reference and compare every value against it. You could even take the mean: compute the average of all the data, label each observation above the average as and each one below as , and count the runs the same way. It is not a mistake to do this — the runs still carry the ordering information. The median is standard because it is a positional average that splits the data into halves, but other reference points give a workable symbol arrangement too.

16.4.4 Student Questions

Q: Why do we use the median rather than the mean in these non-parametric tests? A: The mean belongs to parametric procedures, where it has a theoretical justification drawn from sampling theory: the sample mean estimates the population mean, and the sample standard deviation estimates the population standard deviation. Those justifications do not carry over when we drop the parametric assumptions. The median is a positional average — it splits the ordered data into two equal halves, which is all the reference point needs to do in the non-parametric setting. For that reason the median suffices as our reference. Some non-parametric procedures go one step further and use ranks instead of signs or runs.

Q: Could we use the mean or the mode as the reference instead? A: Yes. Take the average of the data and compare each value with it — above average becomes A, below average becomes B — and the runs follow in exactly the same way. It is not a mistake to do this. The median is the customary reference, but no strict rule forces it: any reference that splits the data into two groups produces a valid symbol arrangement, and the run count still carries the ordering information.

Pitfalls.

  1. Assuming the median is mandatory. It is customary, not compulsory; the mean or mode as reference also gives valid runs. On the exam, use the median as taught, but do not mark a mean-based solution wrong in principle.
  2. Expecting the mean's sampling properties to survive. The mean's justification (sample mean represents population mean) depends on parametric sampling theory; in the non-parametric setting that support is gone, which is precisely why the positional median is preferred.
  3. Forgetting that the 0.5 probability comes from the split. The sign test's works only because the median divides the distribution into two equal halves; a skewed reference would not give that probability.

Recap + bridge. The median is the non-parametric reference because it is a positional average that splits the data into two equal halves — the property the sign test (p = 0.5) and the run test (A/B symbols) both lean on — while the mean's sampling-theory justification does not carry into non-parametric settings. Median, mean, or mode all produce workable symbols; the median is customary, not mandatory. The next section steps back and asks what other routes exist for testing randomness.

In practice, this median-based logic shows up whenever analysts work with skewed data — income, property prices, or response times — where the mean is pulled by outliers and the median is the stable divider. Business reports that split customers into above-median and below-median spenders are using exactly this positional split, and randomness checks on those sequences protect the conclusions drawn from them.

16.5 Other Ways to Test Randomness

16.5.1 Parametric First

If you can address the randomness question with any parametric procedure, the first priority goes to that procedure. The chi-square distribution, for example, can validate randomness — a chi-square test can check whether the observed pattern fits a random arrangement. When such a parametric route is available, use it first. The run test is the non-parametric route for the same question, used when the parametric path is not suitable or when the data arrive as symbols.

Why the ordering? Parametric tests are built on stronger assumptions (normality, known or estimated population parameters) and, when those assumptions hold, they are more powerful — they need less data to detect a real pattern. Non-parametric tests trade that power for safety: they assume almost nothing, so they work on data and questions the parametric machinery cannot touch.

Dimension Parametric route (e.g., chi-square) Non-parametric route (run test)
Data form Counts of observations in categories A sequence of symbols or converted numbers
Assumptions Expected counts large enough (chi-square conditions) Only for the normal approximation
Question answered Does the pattern fit a random arrangement? Does the order of the sequence look random?
Priority First, when applicable Used when the parametric path is not suitable or data arrive as symbols

When to pick which: if a parametric procedure can answer the question, use it first; the run test is the fallback non-parametric route, not the default.

16.5.2 Two Forms of the Problem: Symbols or Numbers

Problems come in two forms:

  1. Symbols given directly — like the defective/non-defective arrangement, where the sequence is presented as and and you count runs immediately.
  2. Raw numbers given — like battery lifetimes in hours, where you first convert the numbers into symbols (median to A/B, or any chosen reference) and then count runs.

Both feed the same procedure. Non-parametric tests work with symbols rather than raw numbers: signs for the sign test, runs for the run test, and ranks in other procedures. The material changes — signs, runs, or ranks — but the move is the same in every case: throw away the numeric values, keep only the ordering information, and test on that.

16.5.3 Student Questions

Q: Can we test the same randomness question with a parametric test? A: If the problem can be addressed with a parametric procedure, that gets first priority — the chi-square test, for example, can be used to validate randomness. The run test is the non-parametric route for the same question, used when the parametric path is not suitable.

Q: Will the problems always give us the symbols directly? A: Two forms of the problem appear. In one form the symbols are given directly — like the defective and non-defective arrangement. In the other form the data are raw numbers, like battery lifetimes in hours, and you must convert them into symbols first, using the median as your reference.

Recap + bridge. Randomness questions have a priority order: a parametric procedure (such as chi-square) goes first when it applies, and the run test is the non-parametric route. Problems arrive in two forms — symbols ready-made or raw numbers to convert — and both converge on the same run-counting machinery. With the run test complete, the rest of the session turns to the comprehensive exam: which topics to revise and how the paper is built.

In industry, this priority rule plays out daily: data teams first check randomness with chi-square-type goodness-of-fit tests on aggregated counts, and only fall back to sequence-based run tests when the process records are individual observations in order — for example, validating that the order of transactions in a trading system shows no exploitable pattern.

16.6 Comprehensive Exam: Topic Focus

16.6.1 Normal Distribution and Tables

First priority: revisit the normal distribution and the normal distribution tables. How to calculate the value of Z and how to find probabilities is very, very important — it supports every other discussion in the course. This is why the course opened with the normal distribution: everything downstream leans on it.

The one move to rehearse: given a value from a normal distribution with mean and standard deviation , transform it as

and read the probability from the standard normal table — the table gives the area under the bell curve up to (or beyond, depending on the table format) the computed . Practice both directions: from a to a probability, and from a probability (or tail area) back to a , because the critical values used in every decision rule come from that reverse reading.

16.6.2 Hypothesis Testing

Know how to construct the two logical statements — the null and the alternative — for any given problem. Know what a type 1 error is and what a type 2 error is, and how to handle them. Hypothesis testing frames almost every procedure in the course, and the run test from 16.2 is a direct example: the two statements, the level of significance, the test statistic, and the decision.

The two errors are easy to confuse, so fix the mapping once: a type 1 error rejects a true null hypothesis (a false alarm, controlled by ); a type 2 error accepts a false null hypothesis (a missed detection, related to , which grows when the sample is small). Every test in the course — Z, t, chi-square, F, and the run test — is the same skeleton wearing different clothes: null and alternative, a test statistic with a known sampling distribution, a rejection region at level , and a conclusion.

16.6.3 Chi-Square Tests

Two chi-square tests are very important: the test of independence and the goodness-of-fit test. Both were discussed in the course and both are likely exam material. Exam note: chi-square also appears as the parametric alternative for randomness questions, as in 16.5.

Recall the shared engine: observed frequencies are compared with expected frequencies under the null hypothesis through

with the sum running over all cells (for the test of independence, over the cells of the contingency table; for goodness of fit, over the categories). Large gaps between observed and expected inflate ; if it exceeds the table value at the chosen (with the right degrees of freedom), the null hypothesis is rejected.

16.6.4 Analysis of Variance

Focus on the one-way analysis of variance (ANOVA). The two-way analysis and factor analysis follow the same logic, so mastering one-way ANOVA gives you the pattern for the others. The core idea: variation between the groups versus variation within the groups — the way that split is measured and decided is how the whole procedure works. Exam note: expect one-way ANOVA as the focus, with the between/within logic as the conceptual center.

The mental model is a one-liner: if the gaps between the group averages are large compared with the scatter inside the groups, the groups are different. The F statistic is the ratio of those two variations — between-group variation over within-group variation — and a big F lands in the rejection region.

16.6.5 Regression

Three regressions must be known: simple, multiple, and logistic. All three are important. Around them, focus on residual analysis, the coefficient of determination (), the adjusted (R-squared), and multicollinearity — these are the key aspects whenever you need to make an inference. If you understood simple linear regression, the remaining regressions are very similar; the difference is mainly in the way you interpret the results.

Interpretation depends on the variables. If is categorical, the reading of the regression output changes. If is a categorical variable, the interpretation is completely different — that is the logistic setting. Knowing the outputs is not enough; the way you interpret them for the problem at hand is what makes sense of the results. In particular: residuals tell you whether the model's assumptions hold (patterns in the residual plot mean the model is missing something); tells you the share of variation explained; adjusted penalizes extra predictors; and multicollinearity means correlated predictors, which inflates the standard errors and makes individual coefficients unreliable.

16.6.6 Dimensionality Reduction: PCA and LDA

Focus on PCA and LDA as they were discussed: what was calculated and on what basis. At this point, do not expect to calculate the eigenvalues or eigenvectors yourself, and do not expect to represent eigenvectors in a geometric perspective — every piece of information will be given. The skill being tested is how you make use of those given values and interpret them. The same understanding built on simple datasets extends to higher-level datasets.

In other words: if a problem hands you the eigenvalues and eigenvectors of the covariance matrix, the tested skill is the interpretation — which direction carries the most variation, how much of the total variation each component explains (eigenvalue divided by the sum of eigenvalues), and what the components mean for the problem. The computation itself is supplied, not examined.

16.6.7 Cluster Analysis

In cluster analysis the practice is to give you the agglomeration schedule and the dendrogram; if they are not given, answer whatever is asked from the given output. Typical questions: the number of individuals; what the cluster is at a given stage (say stage 5); how many clusters you identify; list the clusters. Use the maximum jump or maximum variation in the output to decide where the clusters separate.

The logic to rehearse: hierarchical clustering starts with every individual as its own cluster and merges the two closest clusters at each stage; the agglomeration schedule records those merges and the distances at which they happen. The dendrogram draws the same story as a tree, with merge distances on one axis. Where the merge distances jump — the biggest vertical gap — is where the natural number of clusters is read off.

16.6.8 Sign Test and Run Test

The sign test and the run test as discussed are enough for the exam — take a simple look into those problems. For the run test, everything is in 16.1–16.5. For the sign test: the binomial logic for small samples, the normal approximation beyond, and the median-based splitting with .

The sign test in one sentence: count how many observations fall above the median (or a stated reference), treat each as a sign, and test the count against the binomial with — exact binomial probabilities for small samples, the normal approximation (via ) when the sample is large enough. The run test is the companion: instead of counting signs, count runs in the symbol sequence.

Recap + bridge. The comprehensive exam concentrates on eight blocks: normal distribution and tables, hypothesis testing with type 1/type 2 errors, the two chi-square tests, one-way ANOVA, the three regressions with residual analysis and , PCA/LDA interpretation, cluster analysis with the agglomeration schedule and dendrogram, and the sign and run tests. All of them are refinements of the same hypothesis-testing skeleton — which is why the run test in 16.1–16.5 is a complete, familiar example of the pattern. Next: the model paper — how the exam is actually laid out.

16.7 Comprehensive Exam: Model Paper and Question Style

16.7.1 Text-Box Format

Hook. The exam will not ask for long written solutions. How do you prepare for a paper where the answer is a text box?

The model paper shows how answers will be given: instead of writing long solutions, you give brief answers in text boxes. A single problem may be split into two questions — for example, one question asks you to find the test statistic, and the next asks for the corresponding p-value for that test statistic. Your rough work also goes into the given text boxes. The question paper is mixed so that you avoid huge amounts of calculation, and the exact mode of answering will be shared by the division. The complete paper itself stays sealed — it cannot be shared.

What this means for revision: short, decisive answers are the skill — a test statistic, a p-value, a one-line inference. Practice writing conclusions that fit in a single box.

16.7.2 Outputs You Will Be Given

Expect questions where an output is provided and you must interpret it: Excel outputs or R outputs for regression; the full information for PCA and LDA; the agglomeration schedule and the dendrogram for cluster analysis; and q-q plots or normal plots, where you explain your inferences by observing the plot. For every question there will be a text box — you just give your answer, briefly.

A q-q plot is a scatter of the ordered data values against the values you would expect under normality: points that hug the straight line mean the data look normal, while systematic bowing away from the line means they do not. The tested skill across all these outputs is the same — read the given material, say what it shows, and answer in one or two sentences.

16.7.3 Practice Resources

There is no substitute for the textbook. The Deepak Chawla textbook contains the sign test and the run test, and you can refer to it. These two tests also appear in any standard book. Four sample questions showing how the paper looks will be shared, along with detailed worked solutions for the sign test and the run test, and the datasets used in the course.

16.7.4 Student Questions

Q: Will the agglomeration schedule and the dendrogram be supplied with the question? A: Yes — the agglomeration schedule and the dendrogram will be supplied, and every piece of information needed to answer will be with the question. Nothing has to be memorized from the outputs; you work from what is given.

Q: Are all the topics we could imagine going to appear on the exam? A: Only what was actually discussed in the course matters — that is enough for the exam. Topics that were not covered will not be expected, so revision should follow the course outline, not an open-ended list of possibilities.

Q: Where can we find practice problems for the sign test and the run test? A: Any standard textbook covers them. The Deepak Chawla textbook includes the sign test and the run test, so you can refer to that. Four sample questions will be shared, and worked solutions for the sign test and run test will be given in the files, along with the datasets.

Q: Can you reveal the full question paper? A: The complete paper stays sealed — that cannot be shared. The model paper shows the exact style and format, and the division will share the mode of answering.

Recap + bridge. The model paper runs on text boxes: brief answers, split sub-questions (test statistic first, then p-value), and supplied outputs — R or Excel tables, PCA/LDA information, the agglomeration schedule, the dendrogram, and q-q plots — that you interpret rather than compute. Practice is available in any standard textbook, and the Deepak Chawla textbook covers the sign test and the run test. One last stop before the exam review ends: the course wrap-up and the honest use of statistics.

In the field, this "output plus text box" format mirrors real data work: analysts rarely compute from scratch — they read the output of statistical software, check the diagnostics, and write the interpretation. Practicing the exam style is practicing the professional skill itself.

16.8 Course Wrap-Up: Using Statistics Honestly

16.8.1 Where We Started: Misuse of Statistics

The course opened with the common types of misuse of statistics. In the COVID example, by torturing the data — comparing the numbers in the wrong way — you can reach a conclusion like "doctors are more dangerous than gun owners," which shows how data can be made to say anything. The polling example and the practice of truncating the axis in charts work the same way: a truncated axis gives completely meaningless inferences and misleads the reader about the data. A chart meant to show decreasing cases can be drawn to exaggerate or hide the drop. The whole course — knowingly or not — was about avoiding these errors, and with that knowledge we can minimize the mistakes we make with data.

The lesson carries a simple guard: always look at the axes before believing a chart, always ask what comparison the numbers actually support, and never let a visual artifact — a cut axis, a rescaled baseline, a cherry-picked window — stand in for the evidence.

16.8.2 From Data to Insight

Where there is data smoke, there is business fire. Everyone has a bunch of data available; the ultimate objective is to find the insight in that data — to turn data into information, and information into insight. Look at how the descriptive measures help with this: the mean looks simple, but the significance of the variance is very important, because the spread often carries the real story in real-life problems. Real-world: business reports, polling, and media charts all live on this data-to-insight path, and descriptive statistics are the first step on it.

The chain to remember: data → information → insight. Raw numbers are the smoke; the fire is the decision they point to. Two series with the same average can tell opposite stories once their variances are compared — which is why the course kept returning to spread, not just center.

16.8.3 Quotes to Carry Forward

"It is easy to lie with statistics, and it is hard to tell the truth without statistics." Mark Twain's saying — "lies, damn lies, and statistics" — is famous, but the aim of this course was the other direction: learning how to tell the truth with statistics. "There are two kinds of statistics: the kind you look up and the kind you make up." And from the mathematician Simon Poisson: "Life is good for only two things: discovering mathematics and teaching mathematics."

16.8.4 The Fresh-Fish Story: Sharks Keep Us Alive

The fresh-fish story. The Japanese have always loved fresh fish, but the waters close to Japan held few fish for decades. To feed the population, fishing boats grew bigger and went farther than ever. The farther the fishermen went, the longer the trip, and fish that took more than a few days to return were not fresh. So the fishing companies installed freezers on the boats: they could catch the fish and freeze them at sea, going farther and staying longer. But the Japanese could taste the difference between fresh and frozen fish, and the frozen fish sold at lower prices.

Then the companies installed fish tanks: fish were caught and kept in tanks, where, after a little thrashing around, they stopped moving — tired and dull, but alive. The Japanese could still taste the difference: they preferred lively fish, not sluggish ones. The fix came from a small shark in the tank: the shark eats a few fish, but the rest stay alert and arrive lively.

The story maps onto the course. As the course winds down, we may feel tired and dull — but we are alive. The sharks here are the question papers, tests, evaluations, and assignments that keep us alert and alive. "Keep calm and be significant." And wherever you go, mathematics and statistics will follow — there is no escaping that, and no need to.

Recap + close. The course began with how data are misused — truncated axes, tortured comparisons, misleading polls — and ends with the tools to use data honestly: descriptive measures that separate signal from noise, tests like the run test that check whether the data behave as claimed, and the discipline to turn data into information and information into insight. The shark in the tank is the exam itself: it keeps learners sharp, and a little pressure is what keeps us significant.

Exam Guidance Summary

Consolidated guidance for the comprehensive exam:

  • Normal distribution: revisit the normal distribution tables; compute Z values and probabilities. This is the foundation for everything — very important.
  • Hypothesis testing: construct the two logical statements; know type 1 and type 2 errors and how to handle them.
  • Chi-square: the test of independence and the goodness-of-fit test — both very important.
  • ANOVA: focus on the one-way analysis; two-way and factor analysis follow the same logic of variation between groups and variation within groups.
  • Regression: simple, multiple, and logistic regression; residual analysis; the coefficient of determination; the adjusted R-squared; multicollinearity. Interpretation changes when x or y is categorical.
  • PCA and LDA: no eigenvalue or eigenvector computation is expected; the values will be supplied; the skill tested is using and interpreting them.
  • Cluster analysis: the agglomeration schedule and the dendrogram will be supplied; identify the number of clusters, list the clusters, and find the stage with the maximum jump.
  • Sign test and run test: what was discussed is enough. Run test structure: hypotheses → normal-approximation condition → and → Z value → decision at the stated level of significance. Sign test structure: count signs against the median, binomial with for small samples, normal approximation beyond.
  • Model paper: answers go into text boxes; problems split into small questions (find the test statistic, then the p-value); outputs such as R tables, Excel tables, and q-q plots are given for interpretation.
  • Resources: there is no substitute for the textbook. The Deepak Chawla textbook covers the sign test and run test; sample questions, detailed solutions, and datasets will be shared.

Key Industry Applications

  • Production quality control: machine output is recorded as defective or non-defective in order; the run test checks whether defects cluster or alternate instead of appearing at random, flagging worn tools, failing valves, or out-of-step inspection counters (16.2).
  • Product lifetime testing: battery lifetimes in hours (for example, the ZEDA problem) are checked for randomness via the median-based run test; clustered short lifetimes point to a bad raw-material batch that entered the line at one point in time (16.3).
  • Media and polling: truncated axes and misleading charts distort conclusions (COVID reporting, polling examples); knowing descriptive statistics protects against misreading charts (16.8).
  • Business analytics: data smoke, business fire: raw data becomes information and then insight, using the mean and especially the variance, since the spread often carries the real story (16.8).
  • Non-parametric methods in practice: used when parametric assumptions such as normality cannot be justified; signs, runs, and ranks replace raw numbers — for example, checking that the order of transactions in a trading system shows no exploitable pattern (16.5).

ASM Lecture 16 notes · Run Test for Randomness

Advanced Statistical Methods· postgraduate· 2026-08-11

Sections Breakdown

116.1 What Is a Run?

Defines a run as a maximal block of identical symbols, shows why the order of observations matters for randomness, and counts runs in a 20-symbol worked example.

216.2 The Run Test: Large-Sample Procedure

The complete recipe: hypotheses, the condition that both symbol counts be at least 10, the mean and variance of the run count, and the Z test decision at a stated level of significance.

316.3 Numeric Data: The Median Approach

Converting raw numbers into A and B symbols using the median (odd and even position rules, ties discarded), then running the same large-sample test; the ZEDA battery-lifetime example.

416.4 Why the Median? Reference Points in Non-Parametric Tests

The median as a positional average, its connection to the sign test's p = 0.5, and why the mean or the mode also produce valid references.

516.5 Other Ways to Test Randomness

Parametric procedures such as chi-square get first priority for randomness questions; problems arrive either as symbols or as raw numbers to convert.

616.6 Comprehensive Exam: Topic Focus

The eight revision blocks: normal distribution tables, hypothesis testing with type 1 and type 2 errors, chi-square, one-way ANOVA, the three regressions, PCA and LDA, cluster analysis, and the sign and run tests.

716.7 Comprehensive Exam: Model Paper and Question Style

Text-box answers, split sub-questions, supplied outputs (R and Excel tables, PCA and LDA information, the agglomeration schedule, dendrograms, q-q plots), and practice resources.

816.8 Course Wrap-Up: Using Statistics Honestly

Misuse of statistics (truncated axes, tortured comparisons), the data-to-information-to-insight chain, quotes to carry forward, and the fresh-fish story.

9Exam Guidance Summary

Consolidated guidance for the comprehensive exam: what to revise across the course and how the run test and sign test are structured.

10Key Industry Applications

Real-world uses of the run test and course ideas: production quality control, battery lifetime testing, media and polling chart literacy, and business analytics.

Postgraduate students in Advanced Statistical Methods

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

What Is a Run?

Must-know: A run is a maximal block of like elements: the same symbol repeats inside one run, and a run ends the moment the symbol changes. Too many runs mean alternation and too few runs mean clustering, both signs of non-randomness; the raw run count alone is not evidence until compared with the expectation under randomness.

⚠️ Top pitfall: Treating a run count as proof by itself (e.g., declaring an arrangement non-random just because it has few runs) without comparing it to the number of runs randomness would typically produce.

Self-check: In the arrangement N N D N N D N N D N N D, how many runs are there?

Connects to: The Run Test: Large-Sample Procedure.

The Run Test: Large-Sample Procedure

Must-know: Run test recipe: state H0 random vs H1 not random; verify n1 >= 10 and n2 >= 10; compute mu = 2n1n2/(n1+n2) + 1 and sigma as the square root of 2n1n2(2n1n2 - n1 - n2)/((n1+n2)^2 (n1+n2-1)); compute Z = (u - mu)/sigma and compare with the two-tailed critical value (e.g., plus/minus 2.575 at alpha = 0.01, plus/minus 1.96 at alpha = 0.05).

⚠️ Top pitfall: Using the normal approximation without checking that both n1 and n2 are at least 10, or dropping the +1 from the mean formula, or using the one-tailed critical value in this two-tailed test.

Self-check: If u = 6, n1 = 17, n2 = 10, what are mu, sigma, and Z?

Connects to: What Is a Run?, Numeric Data: The Median Approach.

Numeric Data: The Median Approach

Must-know: For odd n the median is the (n+1)/2-th ordered value; for even n it is the average of the n/2-th and (n/2+1)-th values. Convert numbers into symbols using the median: above becomes A, below becomes B, values equal to the median are discarded, then count runs and run the 16.2 large-sample test on the A/B string.

⚠️ Top pitfall: Forgetting to sort the data before locating the median position, or failing to discard values equal to the median before counting runs and talling n1 and n2.

Self-check: With 55 battery lifetimes, which position in the sorted data is the median, and what happens to values equal to the median?

Connects to: The Run Test: Large-Sample Procedure, Why the Median? Reference Points in Non-Parametric Tests.

Why the Median? Reference Points in Non-Parametric Tests

Must-know: The median is a positional average that splits the data into two equal halves; that is why the sign test uses p = 0.5 and why the run test uses median-based A/B symbols. The mean's sampling-theory justification belongs to parametric procedures and does not carry over; using the mean or mode as the reference is not a mistake, just less customary.

⚠️ Top pitfall: Believing the median is a compulsory reference and that mean- or mode-based symbols are wrong, or assuming the mean keeps its sampling-theory justification inside non-parametric tests.

Self-check: Why does the sign test work with probability 0.5?

Connects to: Numeric Data: The Median Approach, Other Ways to Test Randomness.

Other Ways to Test Randomness

Must-know: If a parametric procedure such as chi-square can address the randomness question, it gets first priority; the run test is the non-parametric alternative. Problems arrive either as symbols given directly or as raw numbers that must be converted into symbols (median to A/B) before counting runs.

⚠️ Top pitfall: Reaching straight for the run test when a parametric route (e.g., chi-square) applies, or forgetting the two-form distinction and trying to count runs on raw numbers without converting them to symbols.

Self-check: What gets first priority for a randomness question: a parametric procedure or the run test?

Connects to: Why the Median? Reference Points in Non-Parametric Tests, Comprehensive Exam: Topic Focus.

Comprehensive Exam: Topic Focus

Must-know: Eight revision blocks: normal tables and Z, hypothesis testing (type 1 and type 2 errors), chi-square test of independence and goodness of fit, one-way ANOVA with between/within variation logic, simple/multiple/logistic regression with residuals, R-squared, adjusted R-squared and multicollinearity, PCA/LDA interpretation (eigenvalues given, no computation), cluster analysis (agglomeration schedule and dendrogram, maximum jump), and the sign test with p = 0.5 plus the run test.

⚠️ Top pitfall: Trying to compute eigenvalues or eigenvectors on the exam (they will be supplied; interpretation is the tested skill), or spending revision time on two-way/factor analysis instead of mastering one-way ANOVA.

Self-check: Which chi-square tests are emphasized for the exam, and what is the tested skill in PCA/LDA?

Connects to: The Run Test: Large-Sample Procedure, Comprehensive Exam: Model Paper and Question Style.

Comprehensive Exam: Model Paper and Question Style

Must-know: Answers go into text boxes; problems split into small sub-questions (test statistic first, then p-value); outputs such as R tables, Excel tables, q-q plots, PCA/LDA information, the agglomeration schedule and the dendrogram are supplied for interpretation. Only course-covered topics appear; practice comes from the Deepak Chawla textbook and four shared sample questions with solutions.

⚠️ Top pitfall: Writing long solutions in an exam built for text boxes, or trying to memorize outputs (agglomeration schedule, dendrogram, eigenvalues) that will always be supplied with the question.

Self-check: If the paper gives you a q-q plot, what skill is being tested?

Connects to: Comprehensive Exam: Topic Focus, Course Wrap-Up: Using Statistics Honestly.

Course Wrap-Up: Using Statistics Honestly

Must-know: Misused statistics (truncated axes, tortured comparisons like the COVID example) produce meaningless inferences; the course goal is to turn data into information and insight, and the fresh-fish story teaches that question papers, tests, evaluations and assignments are the shark that keeps learners alert.

⚠️ Top pitfall: Accepting charts without checking the axes: a truncated axis can exaggerate or hide a drop and give completely meaningless inferences.

Self-check: What does the shark in the fish tank represent for the course?

Exam Guidance Summary

Must-know: Run test structure: hypotheses, normal-approximation condition (both counts at least 10), mu and sigma, Z value, decision at the stated level of significance. Sign test: binomial with p = 0.5 for small samples, normal approximation beyond.

Connects to: The Run Test: Large-Sample Procedure, Numeric Data: The Median Approach, Comprehensive Exam: Topic Focus, Comprehensive Exam: Model Paper and Question Style.

Key Industry Applications

Connects to: The Run Test: Large-Sample Procedure, Numeric Data: The Median Approach, Other Ways to Test Randomness, Course Wrap-Up: Using Statistics Honestly.

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.