# Distance Measures¶

It is often the case that we wish to measure how close an experimentally prepared quantum state
is to the ideal, or how close an ideal quantum gate is to its experimental implementation. The
forest.benchmarking module `distance_measures.py`

allows you to explore some quantitative measures of comparing quantum states and processes.

Distance measures between states or processes can be subtle. We recommend thinking about the *operational interpretation* of each measure before using the measure.

## Distance measures between quantum states¶

`fidelity` (rho, sigma, tol) |
Computes the fidelity \(F(\rho, \sigma)\) between two quantum states rho and sigma. |

`infidelity` (rho, sigma, tol) |
Computes the infidelity, \(1 - F(\rho, \sigma)\), between two quantum states rho and sigma where \(F(\rho, \sigma)\) is the fidelity. |

`trace_distance` (rho, sigma) |
Computes the trace distance between two states rho and sigma: |

`bures_distance` (rho, sigma) |
Computes the Bures distance between two states rho and sigma: |

`bures_angle` (rho, sigma) |
Computes the Bures angle (AKA Bures arc or Bures length) between two states rho and sigma: |

`quantum_chernoff_bound` (rho, sigma, tol) |
Computes the quantum Chernoff bound between rho and sigma. |

`hilbert_schmidt_ip` (A, B, tol) |
Computes the Hilbert-Schmidt (HS) inner product between two operators A and B. |

`smith_fidelity` (rho, sigma, power) |
Computes the Smith fidelity \(F_S(\rho, \sigma, power)\) between two quantum states rho and sigma. |

`total_variation_distance` (P, Q) |
Computes the total variation distance between two (classical) probability measures P(x) and Q(x). |

`purity` (rho[, dim_renorm]) |
Calculates the purity \(P = tr[ρ^2]\) of a quantum state ρ. |

`impurity` (rho[, dim_renorm]) |
Calculates the impurity (or linear entropy) \(L = 1 - tr[ρ^2]\) of a quantum state ρ. |

## Distance measures between quantum processes¶

`entanglement_fidelity` (pauli_lio0, …) |
Returns the entanglement fidelity (F_e) between two channels, E and F, represented as Pauli Liouville matrix. |

`process_fidelity` (pauli_lio0, pauli_lio1) |
Returns the fidelity between two channels, E and F, represented as Pauli Liouville matrix. |

`process_infidelity` (pauli_lio0, pauli_lio1) |
Returns the infidelity between two channels, E and F, represented as a Pauli-Liouville matrix. |

`diamond_norm_distance` (choi0, choi1) |
Return the diamond norm distance between two completely positive trace-preserving (CPTP) superoperators, represented as Choi matrices. |

`watrous_bounds` (choi) |
Return the Watrous bounds for the diamond norm of a superoperator in the Choi representation. |