psum_chisq#

superglm.psum_chisq(
q: float,
weights: NDArray,
df: NDArray | None = None,
sigma: float = 0.0,
lim: int = 10000,
acc: float = 0.0001,
) → tuple[float, int]#

P[sum(w_j * chi²(d_j)) + sigma * N(0,1) > q] via Imhof (1961).

Parameters:
qfloat

Test statistic value.

weightsarray of float

Weights w_j in the linear combination. Must be non-zero.

dfarray of float, optional

Degrees of freedom for each chi² term. Default is all 1.

sigmafloat

Standard deviation of additional normal component.

limint

Maximum number of integration subdivisions for quad.

accfloat

Requested absolute accuracy of the inversion, clamped to [50 * eps, 1e-10]. A looser request is ignored: certifying a far tail needs an absolute tolerance well below the probability being reported, and the default of 1e-4 predates that contract.

Returns:
p_valuefloat

Upper tail probability P[Q > q].

ifaultint

0 = the returned probability is certified. 1 = it is not, either because the integration did not converge or because a converged value cannot be certified: a tail below the resolution of the tolerance in use, a one-sided support boundary, or components too disparate in scale. 4 = invalid input.