POVMPostProcessor

class POVMPostProcessor(povm_sample: POVMPubResult, dual: BaseDual | None = None)[source]

Bases: object

A common POVM result post-processor.

Initialize the POVM post-processor.

Parameters:
  • povm_sample (POVMPubResult) – a result from a POVM sampler run.

  • dual (BaseDual | None) – the subclass of BaseDual that will be used to build the dual frame to the POVM of povm_sample. The dual frame is then used to compute the decomposition weights of any observable.

Raises:

ValueError – If the provided dual is not a dual frame to the POVM used to produce povm_sample.

Attributes

dual

Return the dual that is used.

Warning

If the dual frame is not already built, this could be computationally demanding.

povm

Return the POVM that was used to sample outcomes.

Methods

get_decomposition_weights(observable: SparsePauliOp, outcome_set: set[Any]) dict[Any, float][source]

Get the decomposition weights of observable into the elements of self.povm.

Given an observable \(O\) which is in the span of a given POVM, one can write the observable \(O\) as the weighted sum of the POVM effects, \(O = \sum_k w_k M_k\) for real weights \(w_k\) and where \(k\) labels the outcomes.

Parameters:
  • observable (SparsePauliOp) – the observable to be decomposed into the POVM effects.

  • outcome_set (set[Any]) – set of outcome labels indicating which decomposition weights are queried. An outcome of a ProductPOVM is labeled by a tuple of integers for instance. For a MultiQubitPOVM, an outcome is simply labeled by an integer.

Returns:

A dictionary mapping outcome labels to decomposition weights.

Return type:

dict[Any, float]

get_expectation_value(observable: SparsePauliOp, loc: int | tuple[int, ...] | None = None) tuple[ndarray, ndarray] | tuple[float, float][source]

Return the expectation value of a given observable and standard deviation of the estimator.

Parameters:
  • observable (SparsePauliOp) – the observable whose expectation value is queried.

  • loc (int | tuple[int, ...] | None) – this argument is relevant if multiple sets of parameter values were supplied to the sampler in the same POVMSamplerPub. The index loc then corresponds to the set of parameter values that was supplied to the sampler through the PUB. If None, the expectation value (and standard deviation) for each set of circuit parameters is returned.

Returns:

A tuple of (estimated) expectation value and standard deviation of the estimator if a single value is queried. If all values are queried a tuple of two numpy.ndarray is returned, the first containing the expectation values and the second the standard deviations.

Return type:

tuple[ndarray, ndarray] | tuple[float, float]