  Random numbers are at the heart of diverse fields, ranging from simulations
of stochastic processes to classical and quantum cryptography. The requirement
for true randomness in these applications has motivated various proposals for
generating random numbers based on the inherent randomness of quantum systems.
The generation of true random numbers with arbitrarily defined probability
distributions is highly desirable for applications, but it is very challenging.
Here we show that single-photon quantum walks can generate multi-bit random
numbers with on-demand probability distributions, when the required ``coin''
parameters are found with the gradient descent (GD) algorithm. Our theoretical
and experimental results exhibit high fidelity for various selected
distributions. This GD-enhanced single-photon system provides a convenient way
for building flexible and reliable quantum random number generators. Multi-bit
random numbers are a necessary resource for high-dimensional quantum key
distribution.
