# quantum random number generator implementation in quantum lab

How can I generate and print a 32 bit sequence of 0s and 1s in Qiskit or IBM Q experience quantum lab using quantum random number generator implementation?

• Have you got any thoughts about how you want to go about doing this? Do you want to randomly generate a bit at a time, where the randomness comes from measurement outcomes, or would you rather do something more complicated, like generate a large random unitary and act with that on some input state? Sep 11 '20 at 15:38
• i am looking to generate bit using randomness in measurement and also like to observe the bit sequence obtained for randomness for different cases using 1/2/3/4/6 qubit measurement Sep 12 '20 at 2:52

Qiskit 0.21 has qiskit-ibmq-provider 0.9. This new provider comes with a connector to the RNG service in IBMQ. From the release notes:

You can now access the IBMQ random number services, such as the CQC randomness extractor, using the new package qiskit.providers.ibmq.random. Note that this feature is still in beta, and not all accounts have access to it. It is also subject to heavy modification in both functionality and API without backward compatibility.

You can find the documentation here and here.

I suppose you want to generate uniformly distributed sequence of bits. In such case you can apply a Hadamard gates on $$n$$ qubits, where $$n$$ is number of bits you want to have in your sequence.

Application of Hadamard gates on $$n$$ qubits in state $$|0\rangle$$ will lead to state $$H^{\otimes n}|0\rangle ^{\otimes n} = \frac{1}{\sqrt{2^n}}\sum_{i=0}^{2^n-1}|i\rangle,$$ i.e. you get equally distributed superposition of all bit strings of length $$n$$.

After measurement you will get a random sequence of $$n$$ bits.

• what should i do if i want a 512 bit random sequence as number of qubits available are less. is there a way of repeating the measurements so that i can generate a larger bit sequence using less qubits. Sep 19 '20 at 10:17
• @parth: Just idea, run the circuit many times, extract $n$ random bits in each run and them put them in one serie. Sep 20 '20 at 6:36