mthree.classes.ProbDistribution

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

A generic dict-like class for probability distributions.

Parameters:
Raises:

M3Error – Input not derived from discrete samples.

Methods

expval([exp_ops])

Compute expectation value from distribution.

expval_and_stddev([exp_ops])

Compute expectation value and standard deviation from distribution.

stddev()

Compute standard deviation from distribution.

expval(exp_ops='')[source]

Compute expectation value from distribution.

Parameters:

exp_ops (str or dict or list) – String 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

Notes

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

expval_and_stddev(exp_ops='')[source]

Compute expectation value and standard deviation 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: Standard deviation.

Return type:

float

Notes

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

stddev()[source]

Compute standard deviation from distribution.

Returns:

Standard deviation.

Return type:

float

Raises:

M3Error – Distribution is missing info.

Notes

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