Exact CU KS critical value and rejection of pooled actual arrivals
DefinitionNHPPArrivals_LinearRate_Supplement_KSTestFor observations , put . Let have the product law of independent uniforms on . The exact null critical value is
For and , continuity of the null statistic's distribution gives tail probability at this quantile. This is not the numerical approximation . For a process on divided into equal pieces, retain every observed arrival, rescaled within its piece by . With the actual random total , reject exactly on
The rejection probability is the probability of this event; the test does not reject at zero arrivals. Fixed endpoints and subinterval boundaries have probability zero under an NHPP with integrable intensity. The infimum set is nonempty (it contains ) and bounded below by at all significance levels used in Theorem 6. The model uses the published degree function, without changing it.
import Mathlib
import Definitions.Def_NHPPArrivals_LinearRate_Supplement_EmpiricalCdf
namespace NHPPArrivals.LinearRate.Supplement
open MeasureTheory ProbabilityTheory
noncomputable def ks {n : ℕ} (x : Fin n → ℝ) : ℝ :=
degree (empiricalCdf x)
/-- The null law of m independent uniforms. The unit interval has volume one. -/
noncomputable def uniformSampleLaw (m : ℕ) : Measure (Fin m → ℝ) :=
Measure.pi (fun _ : Fin m => volume.restrict (Set.Icc (0 : ℝ) 1))
/-- Exact upper-tail critical value, not the asymptotic 1.36/sqrt(m).
For m>0 and 0<alpha<1 the null KS distribution is continuous and this
quantile has upper-tail probability alpha. At m=0 no test is performed. -/
noncomputable def criticalValue (m : ℕ) (alpha : ℝ) : ℝ :=
sInf {d : ℝ | d ∈ Set.Icc (0 : ℝ) 1 ∧
(uniformSampleLaw m).real {x | d < ks x} ≤ alpha}
/-- Fold every actual arrival into its own subinterval and retain every point.
Endpoints can be assigned to the interval on their right: they have zero law. -/
noncomputable def pooledVector {Ω : Type*} (N : ℝ → Ω → ℕ)
(X : ℕ → Ω → ℝ) (T : ℝ) (k : ℕ) (ω : Ω) : Fin (N T ω) → ℝ :=
fun i => Int.fract ((k : ℝ) * X (i : ℕ) ω / T)
noncomputable def rejectionEvent {Ω : Type*} (N : ℝ → Ω → ℕ)
(X : ℕ → Ω → ℝ) (T : ℝ) (k : ℕ) (alpha : ℝ) : Set Ω :=
{ω | 0 < N T ω ∧
criticalValue (N T ω) alpha < ks (pooledVector N X T k ω)}
noncomputable def rejectionProbability {Ω : Type*} [MeasurableSpace Ω]
(P : Measure Ω) (N : ℝ → Ω → ℕ) (X : ℕ → Ω → ℝ)
(T : ℝ) (k : ℕ) (alpha : ℝ) : ℝ :=
P.real (rejectionEvent N X T k alpha)
end NHPPArrivals.LinearRate.Supplement