toqito.rand.random_states¶
Generates random quantum states using Qiskit.
Module Contents¶
- toqito.rand.random_states.random_states(n, d, seed=None)[source]¶
Generate a list of random quantum states.
This function generates a list of quantum states, each of a specified dimension. The states are valid quantum states distributed according to the Haar measure.
Examples
Generating three quantum states each of dimension 4.
```python exec=”1” source=”above” from toqito.rand import random_states
states = random_states(3, 4) print(f”length of states is {len(states)}”)
print(f”Shape of each state vector: {states[0].shape}”)
- for idx, state in enumerate(states):
print(f”nState {idx}:”) print(state)
It is also possible to pass a seed to this function for reproducibility.
```python exec=”1” source=”above” from toqito.rand import random_states
states = random_states(3, 4, seed=42)
- for idx, state in enumerate(states):
print(f”nState {idx}:”) print(state)
- Parameters:
n (int) – int The number of random states to generate.
d (int) – int The dimension of each quantum state.
seed (int | None) – int | None A seed used to instantiate numpy’s random number generator.
- Returns:
A list of n numpy arrays, each representing a d-dimensional quantum state as a column vector.
- Return type:
list[numpy.ndarray]