Expand description
Detection-theory primitives for the spoof monitor.
A clock-aided spoof monitor forms a test statistic y — the discrepancy
between the GNSS-asserted time and the clock’s own coasted prediction over a
window — with 1σ uncertainty σ. The two hypotheses are
H0 (no spoof): y ~ N(0, σ²)
H1 (spoof): y ~ N(μ, σ²)where μ is the spoof offset present at the decision. Because the spoof can
drag time in either direction, the deployed detector is the two-sided energy
test T = (y/σ)² > λ, with T ~ χ²₁ under H0 — so the threshold λ is read
straight off the inverse χ²₁ CDF for a target false-alarm probability P_fa.
For a known-sign shift this is the Neyman–Pearson-optimal test (the
log-likelihood ratio llr is monotone in |y|); the two-sided form keeps it
optimal against either attack direction.
From the threshold the operating characteristics are closed form:
γ = σ · Φ⁻¹(1 − P_fa/2) (the |y| detection boundary)
P_md = Φ((γ−μ)/σ) − Φ((−γ−μ)/σ) (missed detection at offset μ)monte_carlo_pfa_pmd re-derives P_fa and P_md empirically by drawing
noise-only and signal-plus-noise realisations and applying the same test, so
the analytic and simulated probabilities can be cross-checked.
Functions§
- analytic_
pd - Closed-form detection power
P_d = 1 − P_md. - analytic_
pmd - Closed-form missed-detection probability for a spoof offset
muagainst noisesigmawith the two-sided boundarygamma:P_md = Φ((γ−μ)/σ) − Φ((−γ−μ)/σ). - chi2_
1_ threshold - The χ²₁ energy-detector threshold
λfor a targetP_fa:λ = [Φ⁻¹(1−P_fa/2)]², so thatP(χ²₁ > λ) = P_fa. Detect when(y/σ)² > λ. - chi2_
inv_ cdf - Inverse CDF (quantile) of the χ² distribution with
dofdegrees of freedom, via the Wilson–Hilferty cube-root-normal approximation:χ²_p(k) ≈ k·(1 − 2/(9k) + z·√(2/(9k)))³, withz = Φ⁻¹(p). - detection_
boundary - The two-sided |y| detection boundary
γ = σ·Φ⁻¹(1 − P_fa/2)for a target false-alarm probability — equivalentlyσ·√λfor the χ²₁ energy thresholdλ. - erf
- Error function via Abramowitz & Stegun 7.1.26 (max abs error 1.5e-7).
- llr
- Log-likelihood ratio
log[p(y|H1)/p(y|H0)]for a mean shiftmuin Gaussian noise of standard deviationsigma(equal variance under both hypotheses):LLR(y) = (y − 0)²/(2σ²) − (y − μ)²/(2σ²) = (μ·y)/σ² − μ²/(2σ²). Monotone iny, so thresholding the LLR is equivalent to thresholdingy(the deployed detector uses the two-sided energy form to catch either-sign offsets). - monte_
carlo_ pfa_ pmd - Monte-Carlo estimate of
(P_fa, P_md)for the two-sided detector: drawnnoise-only (H0) andnsignal-plus-noise (H1, meanmu) realisations of aN(·, σ²)statistic and apply|y| > gamma. Deterministic inseed. - normal_
cdf - Standard normal cumulative distribution function Φ(x).
- normal_
inv_ cdf - Standard normal inverse CDF (probit) Φ⁻¹(p) for
p ∈ (0,1)— Acklam’s rational approximation (relative error ≲ 1.15e-9). Saturates at ±∞ forpat the ends.