qcmet.utils.fidelities.fidelity#

qcmet.utils.fidelities.fidelity(P1, P2)[source]#

Compute the fidelity between two probability distributions.

Fidelity is defined as the square of the sum of the square roots of the product of corresponding probabilities in the two distributions.

Parameters:
  • P1 (list | np.ndarray) – First probability distribution.

  • P2 (list | np.ndarray) – Second probability distribution. Must be the same length as P1.

Returns:

Fidelity value between the two distributions.

Return type:

float

Raises:

AssertionError – If the input distributions are not of the same length.