def _stats_from_measurements(bs_results: np.ndarray, qubit_index_map: Dict,
                             setting: ExperimentSetting, n_shots: int,
                             coeff: float = 1.0) -> Tuple[float]:
    """
    :param bs_results: results from running `qc.run`
    :param qubit_index_map: dict mapping qubit to classical register index
    :param setting: ExperimentSetting
    :param n_shots: number of shots in the measurement process
    :param coeff: coefficient of the operator being estimated
    :return: tuple specifying (mean, variance)
    """
    # Identify classical register indices to select
    idxs = [qubit_index_map[q] for q, _ in setting.out_operator]
    # Pick columns corresponding to qubits with a non-identity out_operation
    obs_strings = bs_results[:, idxs]
    # Transform bits to eigenvalues; ie (+1, -1)
    my_obs_strings = 1 - 2 * obs_strings
    # Multiply row-wise to get operator values. Do statistics. Return result.
    obs_vals = coeff * np.prod(my_obs_strings, axis=1)
    obs_mean = np.mean(obs_vals)
    obs_var = np.var(obs_vals) / n_shots

    return obs_mean, obs_var