elbow_helper.null_test module
Phase 8 — the no-knee null test.
Asks: how often does the entire search procedure find a knee at least as
strong as the observed one when the data really have no knee? The null model is
a monotonic straight line carrying the observed residual structure. The test
statistic is the search-adjusted lexicographic tuple from search, and
the p-value is the usual (1 + #{null >= observed}) / (B + 1).
- elbow_helper.null_test.no_knee_null_test(prepared, observed_statistic, knee_x_norm, config)[source]
Monte-Carlo test of the observed knee against a straight-line null.
The null model is a straight line (the shape under “no knee”) carrying noise of the magnitude estimated from the accepted broken-line fit — not from the straight-line fit, whose residuals on a genuinely kinked curve are the knee signal itself and would inflate the null distribution.
- Parameters:
prepared (PreparedCurve) – The observed normalized curve.
observed_statistic (tuple) – The search statistic of the accepted knee (from
run_search()).knee_x_norm (float) – The accepted knee, used to estimate the true noise scale.
config (RobustKneeConfig) –
null_replicates,max_null_p_valueandrandom_seed.
- Returns:
The Monte-Carlo p-value and a pass flag (with reason on failure).
- Return type: