impurity

forest.benchmarking.distance_measures.impurity(rho: numpy.ndarray, dim_renorm=False, tol: float = 1000) → float

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

As stated above the lower value of the impurity depends on the dimension of ρ’s Hilbert space. For some applications this can be undesirable. For this reason we introduce an optional dimensional renormalization flag with the following behavior

If the dimensional renormalization flag is FALSE (default) then 0 ≤ L ≤ 1/dim. If the dimensional renormalization flag is TRUE then 0 ≤ L ≤ 1.

where dim is the dimension of ρ’s Hilbert space.

Parameters:
  • rho – Is a dim by dim positive matrix with unit trace.
  • dim_renorm – Boolean, default False.
  • tol – Tolerance in machine epsilons for np.real_if_close.
Returns:

L the impurity of the state.