Shortcuts

mthree.classes.QuasiDistribution

class QuasiDistribution(data, shots=None, mitigation_overhead=None)[source]

A dict-like class for representing quasi-probabilities.

Parameters:
  • data (dict) – Input data.

  • shots (int) – Number shots taken to form quasi-distribution.

  • mitigation_overhead (float) – Overhead from performing mitigation.

Methods

expval([exp_ops])

Compute expectation value from distribution.

expval_and_stddev([exp_ops])

Compute expectation value and standard deviation estimate from distribution.

nearest_probability_distribution([...])

Takes a quasiprobability distribution and maps it to the closest probability distribution as defined by the L2-norm.

stddev()

Compute standard deviation estimate from distribution.

expval(exp_ops='')[source]

Compute expectation value from distribution.

Parameters:

exp_ops (str or dict or list) – String or dict representation of diagonal qubit operators used in computing the expectation value.

Returns:

Expectation value.

Return type:

float

Raises:

M3Error – Invalid type passed to exp_ops.

expval_and_stddev(exp_ops='')[source]

Compute expectation value and standard deviation estimate from distribution.

Parameters:

exp_ops (str or dict) – String or dict representation of diagonal qubit operators used in computing the expectation value.

Returns:

Expectation value. float: Estimate of standard deviation upper-bound.

Return type:

float

Notes

The dict operator format is a sparse diagonal format using bitstrings as the keys.

nearest_probability_distribution(return_distance=False)[source]

Takes a quasiprobability distribution and maps it to the closest probability distribution as defined by the L2-norm.

Parameters:

return_distance (bool) – Return the L2 distance between distributions.

Returns:

Nearest probability distribution. float: Euclidean (L2) distance of distributions.

Return type:

ProbDistribution

Notes

Method from Smolin et al., Phys. Rev. Lett. 108, 070502 (2012).

stddev()[source]

Compute standard deviation estimate from distribution.

Returns:

Estimate of standard deviation upper-bound.

Return type:

float

Raises:

M3Error – Missing shots or mitigation_overhead information.