Runs Test Calculator

Check order patterns using flexible numeric or binary inputs. See runs, thresholds, graphs, and summaries. Make better randomness judgments using transparent formulas and outputs.

Calculator Inputs

Separate values with commas, spaces, or new lines.
Use exactly two categories only, such as A/B, H/L, or 0/1.

Example Data Table

This example uses a numeric sequence and the median as the classification threshold.

Position Value Median comparison Code
112AboveA
29BelowB
315AboveA
413AboveA
58BelowB
616AboveA

Formula Used

The runs test checks whether the order of two categories appears random. A run is a consecutive block of the same category.

Expected runs: μ = 1 + (2 n₁ n₂) / (n₁ + n₂) Variance: σ² = [2 n₁ n₂ (2 n₁ n₂ - n₁ - n₂)] / [(n₁ + n₂)² (n₁ + n₂ - 1)] Standardized statistic without continuity correction: z = (R - μ) / σ With continuity correction: z = (R - μ ± 0.5) / σ

Where:

  • R = observed number of runs
  • n₁ = count in category A
  • n₂ = count in category B
  • μ = expected runs under randomness
  • σ² = variance of runs
  • z = standardized test statistic

How to Use This Calculator

  1. Choose numeric mode for measured values or binary mode for two-category sequences.
  2. For numeric mode, select median, mean, or a custom threshold.
  3. Choose how ties should be handled when a value equals the threshold.
  4. Select the alternative hypothesis and significance level.
  5. Paste your sequence into the appropriate input box.
  6. Press Run Test to see the result above the form.
  7. Review the table, graph, p values, and decision summary.
  8. Use the CSV or PDF buttons to export the report.

FAQs

1. What does the runs test measure?

It checks whether the order of two categories looks random. It does not measure average size, only how values alternate or cluster through the sequence.

2. When should I use numeric mode?

Use numeric mode when you have measured values and want to convert them into above-threshold and below-threshold groups using the mean, median, or a custom cut point.

3. Why are ties important?

Ties occur when a value equals the threshold. Different tie rules change category assignments, which can slightly change run counts, z scores, and p values.

4. What does a low number of runs mean?

Too few runs usually suggests clustering, persistence, or trend behavior. Similar categories stay together longer than randomness would predict.

5. What does a high number of runs mean?

Too many runs usually suggests rapid alternation between categories. The sequence switches more often than expected under random ordering.

6. Should I rely on the exact or normal p value?

For small samples, exact p values are preferable because they use the discrete distribution directly. Larger samples commonly rely on the normal approximation.

7. Does the test need equal group sizes?

No. The formulas already account for unequal counts in the two categories. Very unbalanced groups can still reduce sensitivity.

8. Can this prove a process is perfectly random?

No. It only checks one aspect of randomness: ordering. A sequence may pass the runs test yet still fail other randomness checks.

Related Calculators

brunner munzel testspearman rank correlation calculatorkolmogorov smirnov test calculatoriqr calculatorkernel density estimatorfisher exact test calculatorgoodman kruskal gammacramer v calculatortheil sen estimatorkruskal wallis test calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.