# Observable Estimation and Error Mitigation¶

The module observable_estimation is at the heart of forest benchmarking. It provides a convenient way to construct experiments that measure observables and mitigate errors associated with readout (measurement) process.

## Data structures¶

 ObservablesExperiment(settings, …) A data structure for experiments involving estimation of the expectation of various observables measured on a core program, possibly with a collection of different preparations. ExperimentSetting(in_state, observable) Input and output settings for an ObservablesExperiment. ExperimentResult(setting, expectation, …) An expectation and standard deviation for the measurement of one experiment setting in an ObservablesExperiment. TensorProductState([states]) A description of a multi-qubit quantum state that is a tensor product of many _OneQStates states. _OneQState(label, index, qubit) A description of a named one-qubit quantum state. to_json(fn, obj) Convenience method to save forest.benchmarking.observable_estimation objects as a JSON file. read_json(fn) Convenience method to read forest.benchmarking.observable_estimation objects from a JSON file.

## Functions¶

 estimate_observables(qc, obs_expt, …) Standard wrapper for estimating the observables in an ObservableExperiment. calibrate_observable_estimates(qc, …) Calibrates the expectation and std_err of the input expt_results and updates those estimates. generate_experiment_programs(obs_expt, …) Generate the programs necessary to estimate the observables in an ObservablesExperiment. group_settings(obs_expt, method) Group settings that are diagonal in a shared tensor product basis (TPB) to minimize number of QPU runs. shots_to_obs_moments(bitarray, qubits, …) Calculate the mean and variance of the given observable based on the bitarray of results. ratio_variance(a, numpy.ndarray], var_a, …) Given random variables ‘A’ and ‘B’, compute the variance on the ratio Y = A/B. merge_disjoint_experiments(experiments, …) Merges the list of experiments into a single experiment that runs the sum of the individual experiment programs and contains all of the combined experiment settings. get_results_by_qubit_groups(results, …) Organizes ExperimentResults by the group of qubits on which the observable of the result acts.