Test results#

All result objects are immutable, keyword-only data classes. The common base contains the statistic and presentation metadata; specialized subclasses add frequentist p-values, resampling evidence, distance normalization, or Bayes factors.

For an interpretation-oriented introduction, see Working with test results. This page is the exact field-level API.

Common result#

class pysht.StatisticalTestResult(*, statistic, method, alternative, data_name=None, statistic_name='statistic', calibration=None, diagnostics=())[source]#

Bases: object

Immutable common presentation metadata for a statistical procedure.

Parameters:
  • statistic (float)

  • method (str)

  • alternative (str)

  • data_name (str | None)

  • statistic_name (str)

  • calibration (str | None)

  • diagnostics (tuple[NamedDiagnostic, ...])

Named diagnostics are immutable (name, value) pairs. They record quantities such as a standardized statistic, estimator choice, projection dimension, or number of random subspaces without turning each method into a new result type.

Frequentist result#

class pysht.HypothesisTestResult(*, statistic, method, alternative, data_name=None, statistic_name='statistic', calibration=None, diagnostics=(), pvalue, df=None, confidence_interval=None, confidence_level=None, estimates=())[source]#

Bases: StatisticalTestResult

Immutable result of a frequentist hypothesis test.

Parameters:
  • statistic (float)

  • method (str)

  • alternative (str)

  • data_name (str | None)

  • statistic_name (str)

  • calibration (str | None)

  • diagnostics (tuple[NamedDiagnostic, ...])

  • pvalue (float)

  • df (DegreesOfFreedom | None)

  • confidence_interval (ConfidenceInterval | None)

  • confidence_level (float | None)

  • estimates (tuple[NamedEstimate, ...])

property p_value: float#

Alias for pvalue using the spelling common in prose.

Resampling result#

This subclass adds the enumeration or simulation budget and the number of statistics at least as extreme as the observed value. Exact enumeration uses \(b/B\). Monte Carlo tests use the nonzero correction \((b+1)/(B+1)\) and report both a conditional Monte Carlo standard-error estimate and a 95% exact binomial interval for the underlying tail probability.

class pysht.ResamplingTestResult(*, statistic, method, alternative, data_name=None, statistic_name='statistic', calibration=None, diagnostics=(), pvalue, df=None, confidence_interval=None, confidence_level=None, estimates=(), n_resamples, exceedances, exact=False, monte_carlo_standard_error=None, tail_probability_interval=None)[source]#

Bases: HypothesisTestResult

Immutable result with exact or Monte Carlo resampling diagnostics.

Monte Carlo results use a fixed 95 percent binomial interval. The field therefore has no independently mutable confidence-level parameter.

Parameters:
  • statistic (float)

  • method (str)

  • alternative (str)

  • data_name (str | None)

  • statistic_name (str)

  • calibration (str | None)

  • diagnostics (tuple[NamedDiagnostic, ...])

  • pvalue (float)

  • df (DegreesOfFreedom | None)

  • confidence_interval (ConfidenceInterval | None)

  • confidence_level (float | None)

  • estimates (tuple[NamedEstimate, ...])

  • n_resamples (int)

  • exceedances (int)

  • exact (bool)

  • monte_carlo_standard_error (float | None)

  • tail_probability_interval (ConfidenceInterval | None)

Distance-test result#

This subclass additionally records the normalized statistic and distance scale. These diagnostic fields preserve the distinction between the reported scientific statistic and the dimensionless quantity used for stable permutation ordering.

class pysht.DistanceTestResult(*, statistic, method, alternative, data_name=None, statistic_name='statistic', calibration=None, diagnostics=(), pvalue, df=None, confidence_interval=None, confidence_level=None, estimates=(), n_resamples, exceedances, exact=False, monte_carlo_standard_error=None, tail_probability_interval=None, normalized_statistic, distance_scale)[source]#

Bases: ResamplingTestResult

Resampling result retaining numerical distance normalization metadata.

Parameters:
  • statistic (float)

  • method (str)

  • alternative (str)

  • data_name (str | None)

  • statistic_name (str)

  • calibration (str | None)

  • diagnostics (tuple[NamedDiagnostic, ...])

  • pvalue (float)

  • df (DegreesOfFreedom | None)

  • confidence_interval (ConfidenceInterval | None)

  • confidence_level (float | None)

  • estimates (tuple[NamedEstimate, ...])

  • n_resamples (int)

  • exceedances (int)

  • exact (bool)

  • monte_carlo_standard_error (float | None)

  • tail_probability_interval (ConfidenceInterval | None)

  • normalized_statistic (float)

  • distance_scale (float)

Bayes-factor result#

class pysht.BayesFactorTestResult(*, statistic, method, alternative, data_name=None, statistic_name='statistic', calibration=None, diagnostics=(), component_log_bayes_factors)[source]#

Bases: StatisticalTestResult

Immutable result for a Bayes-factor procedure with no p-value.

Parameters:
  • statistic (float)

  • method (str)

  • alternative (str)

  • data_name (str | None)

  • statistic_name (str)

  • calibration (str | None)

  • diagnostics (tuple[NamedDiagnostic, ...])

  • component_log_bayes_factors (LogBayesFactors)

property max_log_bayes_factor: float#

The largest component log Bayes factor.

BayesFactorTestResult deliberately has no pvalue. Its primary statistic is the maximum log Bayes factor and its immutable component values remain in log space. pySHT does not exponentiate the maximum, manufacture a frequentist p-value, or choose an evidence threshold for the analyst.