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.21008894+0.j -0.46056584-0.47165765j 0. +0.j
-0.15248215-0.48974871j 0. +0.j ]
[-0.46056584+0.47165765j 0.18241967+0.j 0. +0.j
-0.20212601+0.15804465j 0.01329707-0.42871682j]
[ 0. +0.j 0. +0.j 0. +0.j
0. +0.j -0.0608447 +0.38781155j]
[-0.15248215+0.48974871j -0.20212601-0.15804465j 0. +0.j
0. +0.j 0.02299724+0.33505856j]
[ 0. +0.j 0.01329707+0.42871682j -0.0608447 -0.38781155j
0.02299724-0.33505856j 0. +0.j ]]
Random Variable Type |
Sampling Functions |
Dimensions |
---|---|---|
State vector ( |
rand_ket, rand_ket_haar |
\(N \times 1\) |
Hermitian operator ( |
rand_herm |
\(N \times 1\) |
Density operator ( |
rand_dm, rand_dm_hs, rand_dm_ginibre |
\(N \times N\) |
Unitary operator ( |
rand_unitary, rand_unitary_haar |
\(N \times N\) |
CPTP channel ( |
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)
[[[7], [7]], [[7], [7]]]
In [3]: print(rand_super_bcsz(6, dims=[[[2, 3], [2, 3]], [[2, 3], [2, 3]]]).dims)