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.85238103+0.j 0.00473610-0.26899532j 0.00000000+0.j
0.00000000+0.j 0.19439792-0.46184373j]
[ 0.00473610+0.26899532j 0.00000000+0.j 0.21699323-0.14122294j
-0.12734561+0.05322338j 0.00000000+0.j ]
[ 0.00000000+0.j 0.21699323+0.14122294j 0.00000000+0.j
-0.11379132+0.23186375j 0.00000000+0.j ]
[ 0.00000000+0.j -0.12734561-0.05322338j -0.11379132-0.23186375j
0.00000000+0.j -0.21668267-0.1563881j ]
[ 0.19439792+0.46184373j 0.00000000+0.j 0.00000000+0.j
-0.21668267+0.1563881j 0.49328238+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