1
$\begingroup$

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?

$\endgroup$
  • 3
    $\begingroup$ 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? $\endgroup$ – Mithrandir24601 Sep 11 at 15:38
  • $\begingroup$ 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 $\endgroup$ – parth Sep 12 at 2:52
1
$\begingroup$

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.

| improve this answer | |
$\endgroup$
1
$\begingroup$

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.

| improve this answer | |
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – parth Sep 19 at 10:17
  • 1
    $\begingroup$ @parth: Just idea, run the circuit many times, extract $n$ random bits in each run and them put them in one serie. $\endgroup$ – Martin Vesely Sep 20 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.