Basic Examples (3)
Two samples of size 20 drawn from the same uniform distribution:
Simplest low-level call: no ties, exact rational p-value:
Use the multiplicity vector to indicate how many pooled-sample values are tied at each distinct value; here m=120,n=150 with four groups of tied observations at q=11/60:
Applications (11)
Load the MTEX Forsterite EBSD (Electron Backscatter Diffraction) dataset. The dataset contains 178,403 crystallographic measurements from a polished peridotite thin section (Bachmann, Hielscher, Schaeben, 2010; GPL-2.0; available at https://github.com/mtex-toolbox/mtex/tree/develop/data/EBSD), including phase labels, spatial coordinates, Euler angles, and EBSD quality metrics (columns: Phase, x, y, Bands, Error, φ₁, φ₂, φ₃, MAD, BC, BS):
Extract the φ₁ Euler angle for each mineral phase. Column 6 contains φ₁ in degrees. Separate the measurements into Forsterite (phase 1) and Enstatite (phase 2) for subsequent comparison of their angular distributions:
Verify the number of measurements in each phase. The resulting subsets contain 152,345 Forsterite measurements and 26,058 Enstatite measurements:
List the eight most frequently repeated φ₁ values in the Forsterite data. Maximum repeat count is 44, indicating moderate concentration around particular orientations:
The full dataset (M = 152,345 Forsterite, N = 26,058 Enstatite) is too large to run the exact test directly. Draw a reproducible subsample of m = 1200 and n = 200, preserving the original ~6:1 phase ratio:
Approximately 2.3% of the pooled subsample observations are tied, confirming that exact tie-handling is necessary:
Compare the two circular φ₁ distributions using the two-sample Kuiper test, which is invariant to the choice of angular origin:
Exact p-value evaluated to 30 significant digits:
To assess the robustness of the exact tie-handling, round the subsample angles to 0.1° — within typical EBSD angular measurement precision — artificially increasing the proportion of tied observations while keeping the same data:
The tie proportion increases from 2.3% to 44.7% after rounding:
Apply the Kuiper test to the rounded subsample. The p-value is virtually unchanged despite the large increase in ties, confirming that exact tie-handling leaves the inference unaffected:
Properties and Relations (3)
The Kuiper statistic is invariant to cyclic shifts of the data. Shifting data1 and data2 by an arbitrary constant on the circle leaves the Kuiper statistic and p-value unchanged.
Four equally spaced mass points on[0, 2π) with unequal observation counts:
Shift every observation by π/3 on the circle and retest:
The Kuiper statistic and p-value are exactly preserved under the cyclic shift:
Possible Issues (4)
Random variables d2 and d3 are drawn from the same seed so they have nearly identical Kuiper statistics against d1; the timing difference is due to LCM[m,n] alone:
Confirm the statistics are close:
Complexity is O(mn*r), where r= LCM[m,n]. When m=n,LCM[m,n]=m so complexity is O(m3). When m and n are coprime (e.g. m=n+1), LCM[m,n]=mn and complexity is O(m2n2), which is much larger. For larger samples consider the R package KSgeneral which uses a compiled C++ implementation:
Timing and p-values for both cases: