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. +0.j 0. +0.j -0.07903194+0.04842048j
-0.08160606+0.47629143j 0. +0.j ]
[ 0. +0.j 0. +0.j 0. +0.j
-0.1919832 -0.22178051j 0.28831061-0.27313483j]
[-0.07903194-0.04842048j 0. +0.j 0. +0.j
0.42183113+0.00672673j 0.81327946-0.46667892j]
[-0.08160606-0.47629143j -0.1919832 +0.22178051j 0.42183113-0.00672673j
0. +0.j 0.32721563-0.41352091j]
[ 0. +0.j 0.28831061+0.27313483j 0.81327946+0.46667892j
0.32721563+0.41352091j 0.8523009 +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-ab0324dc4f28>", 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