quimb.gen.rand#
Functions for generating random quantum objects and states.
Functions
|
|
|
Generate many random Haar states, recycling a random unitary operator by using all of its columns (not a good idea?). |
|
|
|
Fast multithreaded generation of random normally distributed data using |
|
Generate a random state of dimension d according to the Haar distribution. |
|
Generate a random hermitian operator of order d with normally distributed entries. |
|
Generate a random isometry of shape |
|
Generates a ket of length d with normally distributed entries. |
|
Generate a random matrix of order d with normally distributed entries. |
|
Generate a random matrix product state (in dense form, see |
|
Generate a random mera state of |
|
Constructs a random mixed state by tracing out a random ket where the composite system varies in size between 2 and d. |
|
Generate a random matrix product state (in dense form, see |
|
Generate random complex numbers distributed on the unit sphere. |
|
Generate a random positive operator of size d, with normally distributed entries. |
|
Generates a ket of n many random pure qubits. |
|
|
|
Generate a random positive operator of size d with normally distributed entries and unit trace. |
|
Generate a random, mixed, seperable state. |
|
Generate a random unitary operator of size d, distributed according to the Haar measure. |
|
Fast multithreaded generation of random normally distributed data using |
|
Modify |
|
See the random number generators, by instantiating a new set of bit generators with a 'seed sequence'. |
|
Set the core bit generator type to use, from either |
- quimb.gen.rand.gen_rand_haar_states(d, reps, dtype=<class 'complex'>)[source]#
Generate many random Haar states, recycling a random unitary operator by using all of its columns (not a good idea?).
- quimb.gen.rand.rand(shape=(), dtype=<class 'float'>, scale=1.0, loc=0.0, num_threads=None, seed=None, dist='normal')[source]#
Fast multithreaded generation of random normally distributed data using
randomgen
.- Parameters
dtype ({'complex128', 'float64', 'complex64' 'float32'}, optional) – The data-type of the output array.
scale (float, optional) – The width of the distribution (standard deviation if
dist='normal'
).loc (float, optional) – The location of the distribution (lower limit if
dist='uniform'
).num_threads (int, optional) – How many threads to use. If
None
, decide automatically.dist ({'normal', 'uniform', 'exp'}, optional) – Type of random number to generate.
- quimb.gen.rand.rand_haar_state(d, dtype=<class 'complex'>)[source]#
Generate a random state of dimension d according to the Haar distribution.
- quimb.gen.rand.rand_herm(d, sparse=False, density=None, dtype=<class 'complex'>)[source]#
Generate a random hermitian operator of order d with normally distributed entries. In the limit of large d the spectrum will be a semi-circular distribution between [-1, 1].
See also
- quimb.gen.rand.rand_iso(n, m, dtype=<class 'complex'>)[source]#
Generate a random isometry of shape
(n, m)
.
- quimb.gen.rand.rand_ket(d, sparse=False, stype='csr', density=0.01, dtype=<class 'complex'>)[source]#
Generates a ket of length d with normally distributed entries.
- quimb.gen.rand.rand_matrix(d, scaled=True, sparse=False, stype='csr', density=None, dtype=<class 'complex'>, seed=None)[source]#
Generate a random matrix of order d with normally distributed entries. If scaled is True, then in the limit of large d the eigenvalues will be distributed on the unit complex disk.
- Parameters
d (int) – Matrix dimension.
scaled (bool, optional) – Whether to scale the matrices values such that its spectrum approximately lies on the unit disk (for dense matrices).
sparse (bool, optional) – Whether to produce a sparse matrix.
stype ({'csr', 'csc', 'coo', ...}, optional) – The type of sparse matrix if
sparse=True
.density (float, optional) – Target density of non-zero elements for the sparse matrix. By default aims for about 10 entries per row.
dtype ({complex, float}, optional) – The data type of the matrix elements.
- Returns
mat – Random matrix.
- Return type
qarray or sparse matrix
- quimb.gen.rand.rand_matrix_product_state(n, bond_dim, phys_dim=2, dtype=<class 'complex'>, cyclic=False, trans_invar=False)[source]#
Generate a random matrix product state (in dense form, see
MPS_rand_state()
for tensor network form).- Parameters
n (int) – Number of sites.
bond_dim (int) – Dimension of the bond (virtual) indices.
phys_dim (int, optional) – Physical dimension of each local site, defaults to 2 (qubits).
cyclic (bool (optional)) – Whether to impose cyclic boundary conditions on the entanglement structure.
trans_invar (bool (optional)) – Whether to generate a translationally invariant state, requires cyclic=True.
- Returns
ket – The random state, with shape (phys_dim**n, 1)
- Return type
- quimb.gen.rand.rand_mera(n, invariant=False, dtype=<class 'complex'>)[source]#
Generate a random mera state of
n
qubits, which must be a power of 2. This usesquimb.tensor
.
- quimb.gen.rand.rand_mix(d, tr_d_min=None, tr_d_max=None, mode='rand', dtype=<class 'complex'>)[source]#
Constructs a random mixed state by tracing out a random ket where the composite system varies in size between 2 and d. This produces a spread of states including more purity but has no real meaning.
- quimb.gen.rand.rand_mps(n, bond_dim, phys_dim=2, dtype=<class 'complex'>, cyclic=False, trans_invar=False)#
Generate a random matrix product state (in dense form, see
MPS_rand_state()
for tensor network form).- Parameters
n (int) – Number of sites.
bond_dim (int) – Dimension of the bond (virtual) indices.
phys_dim (int, optional) – Physical dimension of each local site, defaults to 2 (qubits).
cyclic (bool (optional)) – Whether to impose cyclic boundary conditions on the entanglement structure.
trans_invar (bool (optional)) – Whether to generate a translationally invariant state, requires cyclic=True.
- Returns
ket – The random state, with shape (phys_dim**n, 1)
- Return type
- quimb.gen.rand.rand_phase(shape, scale=1, dtype=<class 'complex'>)[source]#
Generate random complex numbers distributed on the unit sphere.
- quimb.gen.rand.rand_pos(d, sparse=False, density=None, dtype=<class 'complex'>)[source]#
Generate a random positive operator of size d, with normally distributed entries. In the limit of large d the spectrum will lie between [0, 1].
See also
- quimb.gen.rand.rand_product_state(n, qtype=None, dtype=<class 'complex'>)[source]#
Generates a ket of n many random pure qubits.
- quimb.gen.rand.rand_rho(d, sparse=False, density=None, dtype=<class 'complex'>)[source]#
Generate a random positive operator of size d with normally distributed entries and unit trace.
See also
- quimb.gen.rand.rand_seperable(dims, num_mix=10, dtype=<class 'complex'>)[source]#
Generate a random, mixed, seperable state. E.g rand_seperable([2, 2]) for a mixed two qubit state with no entanglement.
- quimb.gen.rand.rand_uni(d, dtype=<class 'complex'>)[source]#
Generate a random unitary operator of size d, distributed according to the Haar measure.
See also
- quimb.gen.rand.randn(shape=(), dtype=<class 'float'>, scale=1.0, loc=0.0, num_threads=None, seed=None, dist='normal')[source]#
Fast multithreaded generation of random normally distributed data using
randomgen
.- Parameters
dtype ({'complex128', 'float64', 'complex64' 'float32'}, optional) – The data-type of the output array.
scale (float, optional) – The width of the distribution (standard deviation if
dist='normal'
).loc (float, optional) – The location of the distribution (lower limit if
dist='uniform'
).num_threads (int, optional) – How many threads to use. If
None
, decide automatically.dist ({'normal', 'uniform', 'exp'}, optional) – Type of random number to generate.
- quimb.gen.rand.random_seed_fn(fn)[source]#
Modify
fn
to take aseed
argument (so as to seed the random generators once-only at beginning of function not everyrandn
call).