pygsti.tools.pdftools

Tools for manipulating classical probability distributions.

Module Contents

Functions

tvd(p, q)

Calculates the total variational distance between two probability distributions.

classical_fidelity(p, q)

Calculates the (classical) fidelity between two probability distributions.

pygsti.tools.pdftools.tvd(p, q)

Calculates the total variational distance between two probability distributions.

The distributions must be dictionaries, where keys are events (e.g., bit strings) and values are the probabilities. If an event in the keys of one dictionary isn’t in the keys of the other then that probability is assumed to be zero. There are no checks that the input probability distributions are valid (i.e., that the probabilities sum up to one and are postiive).

Parameters
  • p (dicts) – The distributions to calculate the TVD between.

  • q (dicts) – The distributions to calculate the TVD between.

Returns

float

pygsti.tools.pdftools.classical_fidelity(p, q)

Calculates the (classical) fidelity between two probability distributions.

The distributions must be dictionaries, where keys are events (e.g., bit strings) and values are the probabilities. If an event in the keys of one dictionary isn’t in the keys of the other then that probability is assumed to be zero. There are no checks that the input probability distributions are valid (i.e., that the probabilities sum up to one and are postiive).

Parameters
  • p (dicts) – The distributions to calculate the TVD between.

  • q (dicts) – The distributions to calculate the TVD between.

Returns

float