chi2_penalty#

chi2_penalty(n_samples: int, n_params: int = 1) float[source][source]#

Create a chi-square penalty.

The penalty is the default penalty for the CAPA algorithm. It is described as “penalty regime 1” in the MVCAPA article [1]. The penalty is based on a probability bound on the chi-squared distribution.

The penalty is given by n_params + 2 * sqrt(n_params * log(n_samples)) + 2 * log(n_samples), where n_samples is the sample size and n_params is the total number of parameters per segment in the model across all features.

Parameters:
n_samplesint

Sample size.

n_paramsint, default=1

Number of model parameters per segment.

Returns:
float

The chi-square penalty value.

References

[1]

Fisch, A. T., Eckley, I. A., & Fearnhead, P. (2022). Subset multivariate segment and point anomaly detection. Journal of Computational and Graphical Statistics, 31(2), 574-585.

Examples

>>> chi2_penalty(100, n_params=2)
27.536...