circuit_knitting.cutting.reconstruct_expectation_values

reconstruct_expectation_values(results, coefficients, observables)[source]

Reconstruct an expectation value from the results of the sub-experiments.

Parameters:
  • results (SamplerResult | PrimitiveResult | dict[Hashable, SamplerResult | PrimitiveResult]) –

    The results from running the cutting subexperiments. If the cut circuit was not partitioned between qubits and run separately, this argument should be a SamplerResult instance or a dictionary mapping a single partition to the results. If the circuit was partitioned and its pieces were run separately, this argument should be a dictionary mapping partition labels to the results from each partition’s subexperiments.

    The subexperiment results are expected to be ordered in the same way the subexperiments are ordered in the output of generate_cutting_experiments() – one result for every sample and observable, as shown below. The Qiskit Sampler primitive will return the results in the same order the experiments are submitted, so users who do not use generate_cutting_experiments() to generate their experiments should take care to order their subexperiments as follows before submitting them to the sampler primitive:

    \([sample_{0}observable_{0}, \ldots, sample_{0}observable_{N-1}, sample_{1}observable_{0}, \ldots, sample_{M-1}observable_{N-1}]\)

  • coefficients (Sequence[tuple[float, WeightType]]) – A sequence containing the coefficient associated with each unique subexperiment. Each element is a tuple containing the coefficient (a float) together with its WeightType, which denotes how the value was generated. The contribution from each subexperiment will be multiplied by its corresponding coefficient, and the resulting terms will be summed to obtain the reconstructed expectation value.

  • observables (PauliList | dict[Hashable, PauliList]) – The observable(s) for which the expectation values will be calculated. This should be a PauliList if results is a SamplerResult instance. Otherwise, it should be a dictionary mapping partition labels to the observables associated with that partition.

Return type:

list[float]

Returns:

A list of floats, such that each float is an expectation value corresponding to the input observable in the same position

Raises:
  • ValueErrorobservables and results are of incompatible types.

  • ValueError – An input observable has a phase not equal to 1.