def _stats_from_measurements(
    bitstrings: np.ndarray,
    qubit_to_index: Mapping[cirq.Qid, int],
    observable: cirq.PauliString,
    atol: float,
) -> tuple[float, float]:
    """Return the mean and squared standard error of the mean for the given
    observable according to the measurements in `bitstrings`."""
    obs_vals = _obs_vals_from_measurements(bitstrings, qubit_to_index, observable, atol=atol)
    obs_mean = np.mean(obs_vals)

    # Terminology: This isn't technically the variance. It's the
    # standard error of the mean, but squared.
    # Wikipedia uses the term "variance of the sampling distribution
    # of the sample mean"
    # `ddof` is the delta degrees of freedom. Please read numpy documentation
    # for details. Note that we use ddof=1 everywhere. This is the default for
    # np.cov, but *not* the default for `np.var. We use 1 for both for
    # consistency.
    obs_err = np.var(obs_vals, ddof=1) / len(obs_vals)
    return obs_mean.item(), obs_err.item()
Return the mean and squared standard error of the mean for the given
    observable according to the measurements in `bitstrings`.
cirq-core/cirq/work/observable_measurement_data.py