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.00000000+0.j -0.61443139+0.5565611j 0.00000000+0.j
-0.07695716+0.33797916j 0.00000000+0.j ]
[-0.61443139-0.5565611j 0.00000000+0.j -0.58658376+0.47851684j
0.00000000+0.j 0.29087032-0.04403322j]
[ 0.00000000+0.j -0.58658376-0.47851684j -1.48253672+0.j
0.14821531-0.00900551j 0.21133530-0.4525358j ]
[-0.07695716-0.33797916j 0.00000000+0.j 0.14821531+0.00900551j
0.00000000+0.j 0.08601466-0.31579196j]
[ 0.00000000+0.j 0.29087032+0.04403322j 0.21133530+0.4525358j
0.08601466+0.31579196j 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