Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.quantum_info.hellinger_fidelity

hellinger_fidelity(dist_p, dist_q)

GitHub

Computes the Hellinger fidelity between two counts distributions.

The fidelity is defined as (1H2)2\left(1-H^{2}\right)^{2} where H is the Hellinger distance. This value is bounded in the range [0, 1].

This is equivalent to the standard classical fidelity F(Q,P)=(ipiqi)2F(Q,P)=\left(\sum_{i}\sqrt{p_{i}q_{i}}\right)^{2} that in turn is equal to the quantum state fidelity for diagonal density matrices.

Parameters

  • dist_p (dict) – First dict of counts.
  • dist_q (dict) – Second dict of counts.

Returns

Fidelity

Return type

float

Example

from qiskit import QuantumCircuit, execute, BasicAer
from qiskit.quantum_info.analysis import hellinger_fidelity
 
qc = QuantumCircuit(5, 5)
qc.h(2)
qc.cx(2, 1)
qc.cx(2, 3)
qc.cx(3, 4)
qc.cx(1, 0)
qc.measure(range(5), range(5))
 
sim = BasicAer.get_backend('qasm_simulator')
res1 = execute(qc, sim).result()
res2 = execute(qc, sim).result()
 
hellinger_fidelity(res1.get_counts(), res2.get_counts())
0.9999227399273289

References

Quantum Fidelity @ wikipedia Hellinger Distance @ wikipedia

Was this page helpful?
Report a bug or request content on GitHub.