pygsti.tools.hypothesis

Tools for general statistical hypothesis testing

Module Contents

Functions

bonferroni_correction(→ float)

Calculates the standard Bonferroni correction.

sidak_correction(→ float)

Sidak correction.

generalized_bonferroni_correction(→ float)

Generalized Bonferroni correction.

pygsti.tools.hypothesis.bonferroni_correction(significance: float, numtests: int) float

Calculates the standard Bonferroni correction.

This is used for reducing the “local” significance for > 1 statistical hypothesis test to guarantee maintaining a “global” significance (i.e., a family-wise error rate) of significance.

Parameters

significancefloat

Significance of each individual test.

numtestsint

The number of hypothesis tests performed.

Returns

The Boferroni-corrected local significance, given by significance / numtests.

pygsti.tools.hypothesis.sidak_correction(significance: float, numtests: int) float

Sidak correction.

Convert a significance level for an individual test repeated independently, numtest times into a significance level for the whole family of tests.

https://en.wikipedia.org/wiki/sidak_correction

Parameters

significancefloat

Significance of each individual test.

numtestsint

The number of hypothesis tests performed.

Returns

float

pygsti.tools.hypothesis.generalized_bonferroni_correction(significance: float, weights: numpy.ndarray, numtests: int | None = None, nested_method: Literal['bonferroni', 'sidak'] = 'bonferroni', tol: float = 1e-10) float

Generalized Bonferroni correction.

Parameters

significancefloat

Significance of each individual test.

weightsarray-like

An array of non-negative floating-point weights, one per individual test, that sum to 1.0.

numtestsint

The number of hypothesis tests performed.

nested_method{‘bonferroni’, ‘sidak’}

Which method is used to find the significance of the composite test.

tolfloat, optional

Tolerance when checking that the weights add to 1.0.

Returns

float