The Qunatum Depolarizing Channel is parametrized by a single real variable $\lambda, 0 \leq \lambda \leq 1$.

I have a system of $n$ qubits. I'd like to generate random errors from that channel. These would be strings of length $n$ with entries from $(0,1,2,3)$ with the right distribution. $(0,1,2,3)$ correspond to $(I,X,Z,Y)$ errors; $I$ error actually means no error applied to that qubit; the others mean $X,Z$ or $Y$ operators applied. For example $n=7$, error $e=(0,1,0,0,3,0,2)$ means $X$ is applied to qubit 2, $Y$ to qubit 5, $Z$ to qubit 7.

Does anyone know of a tried and tested method for doing that. Python or any other language (or even pseudo-code) are fine.


I will assume you want a symmetric depolarizing channel that acts globally on an $n$-qubit system and applies one of $4^n-1$ nontrivial Paulis with equal probability. Note that we can generalize and slightly modify the Kraus representation given in the Wikipedia link to:

\begin{equation}\label{eq:depol_kraus} \Delta_\lambda(\rho) = \sum_{j \in \{0,1, 2, 3\}^n} p_j K_j \rho K_j \end{equation}

where $p_0 = 1 - (1 - 4 ^{-n})\lambda$ and $p_j = 4^{-n} \lambda$ for $j\neq 0^n$ otherwise, and each $K_j = \sigma_{j_1} \otimes \dots \otimes \sigma_{j_n}$ is a Paulistring. So one strategy to do this might be

  1. Sample $j \in \{0, 1, 2, 3\}^n$ according to the distribution $p$ (or just sample integer $x \in \{0, 1, \dots, 4^n - 1\}$ and then convert it to base 4).

  2. For $i=1, \dots, n$ apply $\sigma_{j_i}$ to qubit $i$

If you are trying to apply this in a circuit model you could maybe make step 2 more efficient by inserting parameterized gates $X^{b_{i0}} Z^{b_{i1}}$ after each qubit $i$ wherever you want to place this channel in some fixed circuit. Then you can draw however many events $j$ as you need and then simulate the circuit by inserting the parameters $b_{i0} b_{i1} = \text{bin}(j)$. I know that Cirq supports this kind of parameterization for example.

If you just want single-qubit depolarizing channels then the above procedure can be done independently for each local system.

  • $\begingroup$ for step 1, I'm thinking of drawing random uniformly distributed samples from 1 to 1000 and setup intervals with endpoints at 1,1-3p/4,1-2p/4,1-p/4,1000. If the sample falls in (1,1-3p/4) I use 0, (1-3/4,1-2p/4) I use 1, ...(1-p/4,1000) I use 3. I think this will give the right distribution of 0,1,2,3. I don't have a direct way to sample from an arbitrary distribution but this should work to convert a uniform distribution to an arbitrary one. I repeat the process $n$ times for the $n$ qubits. $\endgroup$
    – unknown
    Oct 3 at 15:52
  • $\begingroup$ Sorry I don't really understand the sampling scheme you've described or its purpose. Maybe another approach: Sample $X\sim \text{Uniform}(0,1)$. If $X \leq 1-3p/4$, apply $I$ ($\sigma_0$). Otherwise if $X \geq 1 - 3p/4$, sample $P$ from the set $\{1,2,3\}$ and then apply $\sigma_P$. You can generalize this for greater than one qubit. This describes a coinflip as to whether an error occured, then a uniform choice of which pauli error to apply if there is an error. $\endgroup$
    – forky40
    Oct 3 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.