shots_to_obs_moments

forest.benchmarking.observable_estimation.shots_to_obs_moments(bitarray: numpy.ndarray, qubits: List[int], observable: pyquil.paulis.PauliTerm, use_beta_dist_unbiased_prior: bool = False) → Tuple[float, float]

Calculate the mean and variance of the given observable based on the bitarray of results.

Parameters:
  • bitarray – results from running qc.run, a 2D num_shots by num_qubits array.
  • qubits – list of qubits in order corresponding to the bitarray results.
  • observable – the observable whose moments are calculated from the shot data
  • use_beta_dist_unbiased_prior – if true then the mean and variance are estimated from a beta distribution that incorporates an unbiased Bayes prior. This precludes var = 0.
Returns:

tuple specifying (mean, variance)