qml.math.mutual_info

mutual_info(state, indices0, indices1, base=None, check_state=False, c_dtype='complex128')[source]

Compute the mutual information between two subsystems given a state:

\[I(A, B) = S(\rho^A) + S(\rho^B) - S(\rho^{AB})\]

where \(S\) is the von Neumann entropy.

The mutual information is a measure of correlation between two subsystems. More specifically, it quantifies the amount of information obtained about one system by measuring the other system. It supports all interfaces (NumPy, Autograd, Torch, TensorFlow and Jax).

Each state must be given as a density matrix. To find the mutual information given a pure state, call dm_from_state_vector() first.

Parameters
  • state (tensor_like) – (2**N, 2**N) or (batch_dim, 2**N, 2**N) density matrix.

  • indices0 (list[int]) – List of indices in the first subsystem.

  • indices1 (list[int]) – List of indices in the second subsystem.

  • base (float) – Base for the logarithm. If None, the natural logarithm is used.

  • check_state (bool) – If True, the function will check the state validity (shape and norm).

  • c_dtype (str) – Complex floating point precision type.

Returns

Mutual information between the subsystems

Return type

float

Examples

The mutual information between subsystems for a state vector can be returned as follows:

>>> x = np.array([1, 0, 0, 1]) / np.sqrt(2)
>>> x = qml.math.dm_from_state_vector(x)
>>> qml.math.mutual_info(x, indices0=[0], indices1=[1])
1.3862943611198906

It is also possible to change the log basis.

>>> qml.math.mutual_info(x, indices0=[0], indices1=[1], base=2)
2.0

Similarly the quantum state can be provided as a density matrix:

>>> y = np.array([[1/2, 1/2, 0, 1/2], [1/2, 0, 0, 0], [0, 0, 0, 0], [1/2, 0, 0, 1/2]])
>>> qml.math.mutual_info(y, indices0=[0], indices1=[1])
0.4682351577408206

Contents

Using PennyLane

Development

API

Internals