pygsti.tools.chi2fn

pygsti.tools.chi2fn(N, p, f, minProbClipForWeighting=0.0001)

Computes the chi^2 term corresponding to a single outcome.

The chi-squared term for a single outcome of a multi-outcome measurement using a clipped probability for the statistical weighting.

Parameters:
  • N (float or numpy array) – Number of samples.
  • p (float or numpy array) – Probability of 1st outcome (typically computed).
  • f (float or numpy array) – Frequency of 1st outcome (typically observed).
  • minProbClipForWeighting (float, optional) – Defines clipping interval (see return value).
Returns:

N(p-f)^2 / cp , where cp is the value of p clipped to the interval (minProbClipForWeighting, 1-minProbClipForWeighting)

Return type:

float or numpy array