microquantum.analysis.inference

Inferential statistics for experiment analysis.

HypothesisTest compares two outcome distributions with a chi-square statistic and a permutation p-value (exact, seedable, no special functions required); bootstrap_ci() builds percentile confidence intervals for any statistic via NumPy resampling.

Module Contents

class microquantum.analysis.inference.TestOutcome[source]

Result of a two-sample comparison.

statistic: float[source]
p_value: float[source]
significant: bool[source]
degrees_of_freedom: int[source]
metadata: dict[str, Any] | None = None[source]
to_dict()[source]

Serialize to a JSON-safe dictionary.

Return type:

dict[str, Any]

class microquantum.analysis.inference.HypothesisTest(alpha=0.05, permutations=1000, seed=None)[source]

Two-sample comparison with permutation p-values.

Parameters:
  • alpha (float) – Significance level.

  • permutations (int) – Permutation resamples for the p-value.

  • seed (Optional[int]) – RNG seed for reproducibility.

property alpha: float[source]

Significance level.

Return type:

float

compare(counts_a, counts_b)[source]

Compare two outcome distributions.

Parameters:
Return type:

TestOutcome

microquantum.analysis.inference.float_mean(values)[source]

Mean of a sequence (default bootstrap statistic).

Parameters:

values (collections.abc.Sequence[float])

Return type:

float

microquantum.analysis.inference.bootstrap_ci(samples, statistic=float_mean, confidence=0.95, resamples=1000, seed=None)[source]

Percentile bootstrap confidence interval for statistic.

Parameters:
Return type:

tuple[float, float]