pygsti.tools.chi2¶
-
pygsti.tools.
chi2
(dataset, gateset, gateStrings=None, returnGradient=False, returnHessian=False, minProbClipForWeighting=0.0001, clipTo=None, useFreqWeightedChiSq=False, check=False, memLimit=None)¶ Computes the total chi^2 for a set of gate strings.
The chi^2 test statistic obtained by summing up the contributions of a given set of gate strings or all the strings available in a dataset. Optionally, the gradient and/or Hessian of chi^2 can be returned too.
Parameters: - dataset (DataSet) – The data used to specify frequencies and counts
- gateset (GateSet) – The gate set used to specify the probabilities and SPAM labels
- gateStrings (list of GateStrings or tuples, optional) – List of gate strings whose terms will be included in chi^2 sum. Default value (None) means “all strings in dataset”.
- returnHessian (returnGradient,) – Whether to compute and return the gradient and/or Hessian of chi^2.
- minProbClipForWeighting (float, optional) – defines the clipping interval for the statistical weight (see chi2fn).
- clipTo (2-tuple, optional) – (min,max) to clip probabilities to within GateSet probability computation routines (see GateSet.bulk_fill_probs)
- useFreqWeightedChiSq (bool, optional) – Whether or not frequencies (instead of probabilities) should be used in statistical weight factors.
- check (bool, optional) – If True, perform extra checks within code to verify correctness. Used for testing, and runs much slower when True.
- memLimit (int, optional) – A rough memory limit in bytes which restricts the amount of intermediate values that are computed and stored.
Returns: - chi2 (float) – chi^2 value, equal to the sum of chi^2 terms from all specified gate strings
- dchi2 (numpy array) – Only returned if returnGradient == True. The gradient vector of length nGatesetParams, the number of gateset parameters.
- d2chi2 (numpy array) – Only returned if returnHessian == True. The Hessian matrix of shape (nGatesetParams, nGatesetParams).