# Quantum random number generator

Can we generate quantum random numbers through Qiskit? I want to try the random number generator without using optics or noise.

• Quantum computer can be used as random numbers generator by principle. Try to prepare superposition with Hadamards, measure results and then classically convert binary numbers to decimals. You can divide the result by max. number to normalize on interval 0 to 1. If repeated many tunes, the distribution of random numbers gained in this way should be uniform. Dec 5 '19 at 7:20
• I will point out that the numbers are not truly uniform in distribution due to measurement errors and energy relaxation. So one would need to account for that, otherwise smaller numbers would be more favored. Dec 8 '19 at 13:34

Hadamard Gates together with Quantum Bloom Filters and a Verifiable Random Functions can prove to be a simple but elegant implementation of Quantum Algorithmic Randomness.

This technique can be seen as a way to reduce the dimensionality of high-dimensional data; high-dimensional input items can be reduced to low-dimensional versions while preserving relative distances between items. While we reduce the dimensionality from a high dimensional data the elements of order are replaced by entropies of randomness.

We can generate Quantum Random Numbers in IBM QIS Kit by implementing a Hadamard Gate. The Hadamard gate is the simplest method for generating a random bit in a qubit. It generates a quantum state which is a superposition of a 0 and a 1, with equal probability. If you then attempt to measure that qubit the quantum state collapses into either a 0 or a 1 with equal probability, generating a single random bit.

Execute n Hadamard (H) gates, either on the same or distinct qubits, measure the qubit state after executing each H gate, and you have n-bits of random number. Please find a sample code from IBM QIS Kit for executing a Hadamard gate through a register with a specific backend.

from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
from qiskit import execute
from qiskit import IBMQ
from qiskit.tools.jupyter import *
from qiskit.providers.ibmq import least_busy
IBMQ.backends()
backend = least_busy(IBMQ.backends(simulator=False))
%%qiskit_job_status
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q, c)
qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q, c)
job_exp = execute(qc, backend=backend, shots=1024, max_credits=3)

• the code gives out the error mentioned. - 'IBMQFactory' object has no attribute 'load_accounts'. Dec 28 '20 at 5:09