# PauliChannel

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 Other toolboxes required PauliChannel Generates a Pauli channel none Pauli Superoperators

PauliChannel is a function that generates the Choi matrix of a Pauli channel (either a random Pauli channel on a specified number of qubits, or a specific Pauli channel requested by the user). The output of this function is sparse.

## Syntax

• PHI = PauliChannel(P)

## Argument descriptions

• P: Either a positive integer, indicating that the user wants a randomly-generated P-qubit Pauli channel. Otherwise, P should be a probability vector of length $4^q$ for some integer $q \geq 1$, whose entries specify the weights of the Pauli operators in the channel's Kraus decomposition. More specifically, the weight of the $j$-th Pauli operator (in lexicographical order) in the Kraus operator representation of this channel will be $\sqrt{P(j)}$.

## Examples

### A random 1-qubit Pauli channel

The following code returns the Choi matrix a randomly-generated 1-qubit Pauli channel:

>> Phi = full(PauliChannel(1)) % generate the random Pauli channel

Phi =

0.5737         0         0    0.1346
0    0.4263    0.3196         0
0    0.3196    0.4263         0
0.1346         0         0    0.5737

>> celldisp(KrausOperators(Phi)) % look at its Kraus operators

ans{1} =

0    0.6107
0.6107         0

ans{2} =

0.5951         0
0    0.5951

ans{3} =

0.4686         0
0   -0.4686

ans{4} =

0    0.2310
-0.2310         0

### A specific Pauli channel

The following code generates a Pauli channel with Kraus operators $\left\{\tfrac{1}{\sqrt{15}}I,\tfrac{2}{\sqrt{15}}X,\tfrac{3}{\sqrt{15}}Y,\tfrac{4}{\sqrt{15}}Z\right\}$, where $I,X,Y,Z$ are the usual Pauli operators:

>> Phi = full(PauliChannel([1,2,3,4]/15))

Phi =

0.3333         0         0   -0.2000
0    0.3333   -0.0667         0
0   -0.0667    0.3333         0
-0.2000         0         0    0.3333

>> celldisp(KrausOperators(Phi)) % look at its Kraus operators

ans{1} =

-0.5164    0.0000
0    0.5164

ans{2} =

-0.0000    0.4472
-0.4472   -0.0000

ans{3} =

-0.0000    0.3651
0.3651   -0.0000

ans{4} =

-0.2582   -0.0000
0   -0.2582

## Source code

Click on "expand" to the right to view the MATLAB source code for this function.

1. %%  PAULICHANNEL   Generates a Pauli channel
2. %   This function has one required argument:
3. %     P: either a probability vector or a scalar indicating a number of
4. %        qubits
5. %
6. %   PHI = PauliChannel(P) is the Choi matrix of a Pauli channel. If P is a
7. %   scalar then P is a random P-qubit Pauli channel. If P is a probability
8. %   vector then it must have length 4^Q for some integer Q (which is the
9. %   number of qubits that PHI acts on), and the weight of the J-th Pauli
10. %   operator (in lexicographical order) in PHI's Kraus decomposition is
11. %   sqrt(P(J)). The output of this function is sparse.
12. %
13. %   URL: http://www.qetlab.com/PauliChannel
14. 
15. %   requires: ChoiMatrix.m, RandomProbabilities.m, update_odometer.m
16. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
17. %   package: QETLAB
18. %   last updated: December 16, 2014
19. 
20. function Phi = PauliChannel(p)
21. 
22. len_p = numel(p);
23. if(len_p == 1) % P is a scalar, so generate a random P-qubit Pauli channel
24.     q = p;
25.     len_p = 4^q;
26.     p = RandomProbabilities(len_p);
27. 
28. % Otherwise, do some error checking to make sure that P is a probability
29. % vector.
30. else
31.     % Let the user enter either a single vector P or a 4-by-4-by-...-by-4
32.     % array P.
33.     p = reshape(p,len_p,1);
34. 
35.     tol = len_p*eps^(3/4);
36.     if(isa(p,'cvx') == 0 && (min(p) < -tol || sum(p) > 1+tol))
37.         error('PauliChannel:InvalidP','P must be a probability vector: its entries must be non-negative and sum to 1.');
38.     end
39. 
40.     % Make sure that its length is a power of 2.
41.     [pow_of_2,double_q] = log2(len_p);
42.     if(abs(pow_of_2 - 1/2) > tol || mod(double_q,2) == 0)
43.         error('PauliChannel:InvalidP','P must contain 4^Q entries for some positive integer Q, since there are 4^Q Pauli operators on Q qubits.');
44.     end
45.     q = (double_q-1)/2; % number of qubits
46. end
47. 
48. % Finally, construct the channel.
49. Phi = sparse(len_p,len_p);
50. ind = zeros(1,q);
51. b4ones = 4*ones(1,q);
52. for j = 1:len_p
53.    Phi = Phi + p(j)*ChoiMatrix({Pauli(ind)});
54.    ind = update_odometer(ind,b4ones); % this loops over all base-4 strings of length Q
55. end