How do you create a random initial state by modifying the $2^{n}$ vector amplitudes instead of starting every simulation at $|0000...000\rangle$?
1 Answer
If you want a random computational basis state, set the input state to the integer random.randint(0, 2**qubits-1)
.
If you want a random superposition sampled from the Haar measure, there is a method cirq.testing.random_superposition(dim=2**qubits)
.
Once you have created your initial state, you pass it into the simulator like cirq.Simulator().simulate(circuit, initial_state=...)
. Note that run
methods do not support an initial state, because they are supposed to more closely mimic the hardware.