9.10 Distribution functions and confidence intervals
The shared numerical layer combines explicit algorithms with functions from a standard statistical library. Record the nlmx version and platform when validating tail probabilities.
Table 9.2. Selected functions and references
| Quantity | Implementation | Retained reference/check |
|---|---|---|
| Inverse normal | Acklam rational + Halley refinement | \(z_{0.975}=1.95996398454\) |
| Central chi-square upper tail | statrs::ChiSquared.sf |
\(P(\chi^2_1\ge3.84145882069)=0.05\) |
| Wilson interval | Explicit score formula | 5/10: [0.2365931, 0.7634069] |
| Type-7 quantile | Explicit interpolation | Q1 of 1…8 = 2.75 |
| SHA-256 | sha2 |
SHA256("abc")=ba7816…15ad |
The core chi2_sf returns 1 for zero degrees of freedom, non-finite/nonpositive statistics or construction failure. This defensive behavior should not be mistaken for a meaningful p-value from an invalid test.
Noncentral power
The older documentation outline suggested a general core noncentral chi-square function. Noncentral power calculations are implemented within the power command, with dedicated reference tests. Document them as a power-module implementation, not as a general-purpose statistical function.
Wilson intervals
For \(k\) successes in \(n\) trials and normal critical value \(z\), the Wilson interval is clipped to [0,1]. For n=0, it returns the uninformative interval [0,1].
Tail validation
Test central and extreme probabilities on a logarithmic scale. Absolute error alone can hide poor relative tail accuracy. Also test monotonicity, symmetry where applicable and inverse/forward round trips.
Common mistakes
- Attributing module-specific noncentral calculations to the shared core.
- Treating a defensive p-value of 1 as a valid test result.
- Validating only central probabilities.
Checklist
- Record function, dependency and version.
- Use published/reference values across the domain.
- Test tail relative error and inverse consistency.
Further reading
See random normal transforms, tolerance-based tests and Chapter 30's planned power theory.