channels.pauli_channel

Generates and applies Pauli Channel to a matrix.

Functions

pauli_channel(prob[, return_kraus_ops, input_mat])

Generate and apply a Pauli channel to a matrix.

Module Contents

channels.pauli_channel.pauli_channel(prob, return_kraus_ops=False, input_mat=None)

Generate and apply a Pauli channel to a matrix.

Generates the Choi matrix of a Pauli channel with given probabilities and optionally applies it to an input matrix. The Pauli channel is defined by the set of Pauli operators weighted by the probability vector. For a given probability vector \((p_0, \ldots, p_{4^q -1 })\), the channel is defined as shown below. Where, $q$ is the number of qubits.

\[\Phi(\rho) = \sum_{i=0}^{4^q - 1} p_i P_i \rho P_i^*\]

where \(P_i\) are Pauli operators generated by a lexographically increasing sequence of pauli operators of length strictly equal to \(q\), and \(p_i\) is the corresponding probability of that operator. For example, when \(q = 2\),

\(P_{0} = I \otimes I\), \(P_{1} = I \otimes X\), \(P_{2} = I \otimes Y\), \(P_{3} = I \otimes Z\), \(P_{4} = X \otimes I\), \(P_{5} = X \otimes Y , \ldots P_{15} = Z \otimes Z\)

If prob is a scalar, it generates a random prob-qubit Pauli channel. The length of the probability vector (if provided) must be \(4^q\) for some integer \(q\) (number of qubits).

Examples

Generate a random single-qubit Pauli channel:

from toqito.channels import pauli_channel

pauli_channel(prob=1)
matrix([[0.61240171+0.j, 0.        +0.j, 0.        +0.j, 0.11409068+0.j],
        [0.        +0.j, 0.38759829+0.j, 0.11336087+0.j, 0.        +0.j],
        [0.        +0.j, 0.11336087+0.j, 0.38759829+0.j, 0.        +0.j],
        [0.11409068+0.j, 0.        +0.j, 0.        +0.j, 0.61240171+0.j]])

Apply a specific two-qubit Pauli channel to an input matrix:

import numpy as np
from toqito.channels import pauli_channel

_, output = pauli_channel(
    prob=np.array([0.1, 0.2, 0.3, 0.4]), input_mat=np.eye(2)
)
print(output)
[[1.+0.j 0.+0.j]
 [0.+0.j 1.+0.j]]

References

Parameters:
  • prob (int | numpy.ndarray) – Probability vector for Pauli operators. If scalar, generates random probabilities for \(q =\) prob qubits. The probabilities correspond to Pauli operators in lexographical order of length strictly equal to \(q\) ,when prob is a vector.

  • return_kraus_ops (bool) – Flag to return Kraus operators. Default is False.

  • input_mat (numpy.ndarray | None) – Optional input matrix to apply the channel to. Default is None.

Raises:
  • ValueError – If probabilities are negative or don’t sum to 1.

  • ValueError – If length of probability vector is not 4^q for some integer q.

Returns:

The Choi matrix of the channel. If input_mat is provided, also returns the output matrix. If return_kraus_ops is True, returns Kraus operators as well.

Return type:

numpy.ndarray