Generating Random Quantum States & Operators¶
QuTiP includes a collection of random state, unitary and channel generators for simulations, Monte Carlo evaluation, theorem evaluation, and code testing. Each of these objects can be sampled from one of several different distributions including the default distributions used by QuTiP versions prior to 3.2.0.
For example, a random Hermitian operator can be sampled by calling rand_herm function:
In [1]: rand_herm(5)
Out[1]:
Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = True
Qobj data =
[[ 0.02899876+0.j -0.13416343-0.22952874j 0.12840707+0.41050523j
-0.20370645+0.30698666j 0.00000000+0.j ]
[-0.13416343+0.22952874j 0.00000000+0.j 0.09407321+0.10234802j
0.00000000+0.j 0.00000000+0.j ]
[ 0.12840707-0.41050523j 0.09407321-0.10234802j 0.00000000+0.j
0.40961470-0.26592036j -0.74062964+0.07040012j]
[-0.20370645-0.30698666j 0.00000000+0.j 0.40961470+0.26592036j
0.29223638+0.j 0.00000000+0.j ]
[ 0.00000000+0.j 0.00000000+0.j -0.74062964-0.07040012j
0.00000000+0.j 0.00000000+0.j ]]
Random Variable Type | Sampling Functions | Dimensions |
---|---|---|
State vector (ket ) |
rand_ket, rand_ket_haar | \(N \times 1\) |
Hermitian operator (oper ) |
rand_herm | \(N \times 1\) |
Density operator (oper ) |
rand_dm, rand_dm_hs, rand_dm_ginibre | \(N \times N\) |
Unitary operator (oper ) |
rand_unitary, rand_unitary_haar | \(N \times N\) |
CPTP channel (super ) |
rand_super, rand_super_bcsz | \((N \times N) \times (N \times N)\) |
In all cases, these functions can be called with a single parameter \(N\) that dimension of the relevant Hilbert space. The optional
dims
keyword argument allows for the dimensions of a random state, unitary or channel to be broken down into subsystems.
In [2]: print rand_super_bcsz(7).dims
File "<ipython-input-2-aef77a269b21>", line 1
print rand_super_bcsz(7).dims
^
SyntaxError: invalid syntax
In [3]: print rand_super_bcsz(6, dims=[[[2, 3], [2, 3]], [[2, 3], [2, 3]]]).dims