Generation of True Quantum Random Numbers with On-Demand Probability Distributions via Single-Photon Quantum Walks

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.


Introduction
Random numbers are important for science research and engineering applications, such as Monte-Carlo simulations [1,2], cryptography [3,4] and tests of fundamental physics [5,6].For example, quantum key distribution (QKD) technology highly relies on the availability of true random numbers to protect its communication security [7][8][9][10].Theoretically, pseudo-random number generators, due to their deterministic and predictable nature, cannot satisfy the requirement for building perfectly secure communication systems.Therefore, the inherent randomness of a quantum system makes it a promising platform for generating faithful random numbers.This is known as quantum random number generator (RNG) [11].
The applications of a RNG strongly rely on the probability distribution used.Different distributions are indispensable in various fields.Uniformly distributed random numbers are most desirable and particularly useful in practical applications [11] because these avoid inherent bias.A Gaussian distributed RNG is of most significance in the modulation of coherent states in continuous-variable QKD systems [34][35][36], simulations of communication channels, and stochastic processes (e.g.noise) [37].
It is highly valuable to develop a quantum RNG with an on-demand probability distribution.Based on quantum walks, significant efforts have been made for this task [33,38].However, it is challenging to find the proper parameter numbers for a complex system to generate true random numbers with a given distribution.In contrast, the gradient descent (GD) algorithm, as a highly adaptive optimization algorithm that has been widely utilized in many fields [39][40][41][42], can provide a more general and efficient way to accomplish this challenging task.
In this work, we propose a GD-enhanced quantum walk for realizing quantum RNG with, in principle, an on-demand probability distribution.Our GD-based scheme can be implemented by using a linear optical system without the need of time-bin encoding and dynamical modulation.We further experimentally demonstrate the generation of true random numbers with various selected probability distributions by using quantum walks of heralded single photons.

System and model
In quantum walks, the walker is located in the Hilbert space H ≡ H p ⊗ H c , where H p is position space and H c is the coin space.The coin space contains two basis vectors {|⟩, |⟩}, which represent the eigenstate of the coin.Therefore, the definite position and classical coins are both replaced by position states and coin operators in a quantum walk system.
In a one-dimensional (1D) discrete-time quantum walk system, the quantum walker's state can be described by a product state |Ψ⟩ = |⟩ ⊗ |⟩, where |⟩ =   |⟩ +   |⟩ is the coin state and |⟩ =    |⟩ is the position state.Each walking step consists of a unitary operator Û = Ŝ Ĉ, where Ŝ is the conditional shift operator and Ĉ is the coin operator.The coin operator Ĉ rotates the coin state and its most general form can be expressed as where ,  ∈ [0, 2] and  ∈ [0, /2] are the parameters of the rotation and  fixes the global phase.The conditional shift operator Ŝ moves the walker either to the left or right depending on the coin state and has the form It leads to the conditional shift operation Ŝ|, ⟩ = | + 1, ⟩ and Ŝ|, ⟩ = | − 1, ⟩.In the following, we fix the parameters  = /2 and  =  = −/2, so that we obtain the coin determined by one parameter .If  = /4, the coin then becomes the Hadamard coin : After  walking steps, the state of a quantum walk system becomes |Ψ  ⟩.The quantum walker remains in a superposition of many positions until the final measurement is performed.The measured probability for the walker being at   after  walking steps can be written as ( The probability distribution is determined by the choice of coin parameter set in each walking step.It is difficult to adjust the coin parameters to obtain desired probability distributions because the number of coin parameters grows rapidly when increasing the walking steps.In this work, we exploit the gradient descent algorithm to solve this challenging problem.

Algorithm
Generally, a GD algorithm consists of three elements [43]: a system function , system parameters {  } ( = 1, 2, ..., ), and a loss function L. The system function  defines the input-output relation of the system and is parameterized by the parameters {  } ( = 1, 2, ..., ).The loss function L evaluates the system output and compares it to the target.Here, we write the system function  as  =  ( ;  1 ,  2 , ...,   ), where  and  are the input and output of the system, respectively.Hereafter we use the mean square error function L = 1 2 ( − ) 2 as the loss function, where  is the target.Therefore, the loss function L is also parameterized by {  } ( = 1, 2, ..., ) and can be written as L ({  }).Essentially, the gradient descent method minimizes the loss function L ({  }) by updating {  } in the opposite direction of the gradient of the loss function.In each iteration of the gradient descent method, the parameters   are updated according to [43], where  ∈ (0, 1] is the learning rate. A 1D discrete-time quantum walk process is depicted in Fig. 1 (a).The blue circles denote different position states, and the red arrows indicate the directions of the walk starting from different position states in each walking step.Without loss of generality, we assume the coin bias ratio can be adjusted for every coin operation at different position states in different walking steps.This assumption can be experimentally realized in a linear optical system [44].
The specific description of quantum state transfer in a quantum walk system is shown in Fig. 1(b).The letters  and  represent the complex amplitude and coin bias ratio, respectively.The notation  ()  , (  , ) represents the complex amplitude of the coin state |⟩ (|⟩) at the position  in the -th walking step; while  ()   is the coin bias ratio of the -th walking step starting from position , and   is the measured probability at the detector located at position .The coin bias ratio  is defined as  = cos 2 .Thus, the state transformation with coin bias ratio  can be modeled as Then the measured probability   becomes where  and  are the real and imaginary components of , respectively.According to the GD algorithm, the updated value of  ()  with respect to   is where here the loss function becomes L = 1 2  (  −   ) 2 , and   is the target probability at position .Then the overall updated value of  ()   is obtained by summing Eq. ( 5), The details of the derivation are presented in the supplemental document.Therefore, during each iteration of our algorithm,  ()   updates according to the following relation The training finishes when the simulated quantum walk probability distribution reaches the target distribution.After the training is completed, the theoretical values of the coin bias ratios for generating the desired probability distribution are obtained.

Experimental setup
Quantum walks lay the natural foundation for studying plenty of novel quantum phenomena and can be realized in various systems [45][46][47][48][49][50].Among these, linear-optics-based quantum walks have advantages in convenience of implementation and compatibility.Therefore, we use this platform for our GD-based quantum RNG scheme.
In linear optical implementations of quantum walks, we use single photons as the quantum walker that moves in both directions in every position.The polarization states {|⟩, |⟩} are introduced to represent two orthogonal coin states {|⟩, |⟩}, respectively.We use single-photon spatial modes to represent the position of the walker |⟩.
The schematic of our experimental setup is shown in Fig. 2(a).Pairs of single photons are created via type-II spontaneous parametric down-conversion in a periodically poled potassium titanyl phosphate (PPKTP) crystal.This crystal is pumped by a diode laser centered at 397.5 mm and emits orthogonally polarized photon pairs (i.e., horizontal and vertical polarized, or left-and right-circularly polarized) with a wavelength of 795 nm and a FWHM bandwidth of 0.3 nm.The photon pairs are separated by a polarized beam splitter.One photon from each pair served as a trigger while the other photon is launched into the quantum walk system.
The position states of the quantum walk are represented by spatial modes of the single photons.The shift operator Ŝ acting on these modes is implemented by a 37.7 mm long, birefringent calcite beam displacer.The optical axis of each calcite prism is cut so that vertically polarized light was directly transmitted, and horizontal light underwent a 4 mm lateral displacement into a neighboring spatial mode.Here, we place the half wave plates in front of each beam displacer to adjust the coin bias ratio in the quantum walk.The aperture diameter of our half wave plate is small so that each half wave plate can change the polarization state of one beam of light without affecting adjacent beams.Therefore, we can adjust the coin bias ratio at different positions during each walking step.The details of the first two quantum walk steps are depicted in Fig. 2(b).The spatial modes after step 1 are recombined interferometrically in step 2. Repetition of these steps then forms an interferometric network as in Fig. 2(a).The lattice sites are labeled so that there are odd sites at odd walking steps, and even sites at even steps.After an -step quantum walk, the photons output in ( + 1) spatial modes are coupled into an optical fiber and subsequently detected by a single-photon photodiode, in coincidence with the trigger photon.We measure the final probability distribution of the quantum walk by manually moving the fiber coupler between individual output spatial modes.
For a four-step quantum walk with an unbiased coin ( = /4), the measured probability distribution at given sites is shown in Fig. 2(c).Here we choose four initial polarization states to verify our experimental system: horizontal polarization, vertical polarization, right-circular polarization, and left-circular polarization.The experimental data (bars with colors) are in excellent agreement with theoretical simulations (red dashes).To characterize the single-photon purity in the experiment, we also measure the second-order correlation function  2  () for our single-photon source, as depicted in Fig. 2(d).

Uniform distribution
Quantum RNGs with a uniform distribution [20,51] are of importance for applications without inherent bias, such as quantum secure communication [11,52].Therefore, we first evaluate the performance of our algorithm for generating a uniform distribution in a four-step quantum walk system.Here we use the fidelity F , defined to evaluate the similarity between the output (simulated or measured output) and the target probability distribution, where  is the system output,  is the target distribution, and  represents the position.
For generating a uniform probability distribution, the fidelity curve during the training of our GD algorithm is shown in Fig. 3(a).The "iterations" represent the accumulating time step when the training progresses.From Fig. 3(a) we can see that the fidelity increases rapidly as the training process goes on.It exceeds 0.95 after 5 iterations and finally approaches unity within 20 iterations.The learning rate of the training process is set as 0.1.The convergence rate of the training can be further improved by appropriately choosing the learning rate .
When the training is completed, we obtain the values of the coin bias ratio for generating a uniform probability distribution in the quantum walk.The values are shown in Fig. 3(b).Obviously, these values are unlikely to be found manually, while our algorithm can find proper values to obtain a high fidelity.According to these values, we adjust { } in the quantum walk experimental setup by rotating the half-wave plates in front of the BDs.The minimal adjustable angle of our half-wave plate is 0.25 degree, which leads to a slight deviation between the actual coin bias ratio in the experiment and the theoretical values.But this does not affect the performance of our experiment because our system has strong robustness (See supplemental document for details of the experimental system robustness analysis).We perform experiments with right-circular and left-circular polarized single photons, respectively.The measured probability distributions for detecting the photon at given positions are shown in Fig. 3(c).It is clear that the measured probability distributions are in good agreement with the target distribution.The fidelities of the experimental results are 96.5% for right-circular polarized photons and 95.8% for left-circular polarized photons.

Gaussian distribution
Gaussian RNGs, as another important RNG, also have diverse useful applications, including Monte Carlo simulation of Gaussian noises.Specific to quantum information, this type of RNGs provide Gaussian distributed randomness for coherent states modulation in continuous-variable quantum key distribution systems [34][35][36].In the following, we show that our GD algorithm can find the parameter set for the quantum walk based RNG to generate Gaussian distributed single-photon outputs.
We set the Gaussian distribution as the target probability distribution for the GD algorithm.The fidelity change during the training process is shown in Fig. 4(a).It can be seen that the fidelity rapidly increases to 95% at the 10th iteration.The coin bias ratios can be found in Fig. 4(b).Figure 4(c) presents the measured probability distribution of single photons in a quantum walk with GD-optimized coin bias ratios.Right-and left-circularly polarized photons are chosen as input photons to perform the quantum walk experiment.The experimentally measured probability distribution is again in good agreement with the target distribution.The fidelities of the experiment results are 94.1% and 95.8% for the right-and left-circular polarized input photons, respectively.These results show that our algorithm can be utilized to adjust a quantum walk system to generate single photons with desired distributions.This allows one to build an effective quantum RNG that conforms to arbitrary probability distributions.

Conclusion
We have reported a GD-enhanced quantum RNG based on quantum walks of single photons in a linear optical system.Our multi-bit quantum RNG can generate true random numbers with an arbitrarily defined probability distribution with nearly unitary fidelity.The promised faithful randomness of our quantum RNG can determine the random measurement basis in high-dimensional quantum communications [53][54][55][56].We note that quantum walks with a uniform distribution can be used to generate quantum random numbers [57].In comparison with this method, our GD-enhanced quantum walk can generate quantum random numbers with flexible probability distribution.

Fig. 1 .
Fig. 1.(a) Schematic of a one-dimensional discrete-time quantum walk process.The red arrows represent the walking directions.The vertical and horizontal gray dashed lines denote the position states and the walking steps, respectively.(b) Details of the quantum state transfer in a quantum walk.The symbols next to the red arrows describe the coin state transfer in each walking step.The symbol    represents the coin bias ratio of the -th walking step starting from position .

Fig. 2 .
Fig. 2. (a) Schematic of experimental setup.PPKTP: periodically poled potassium titanyl phosphate crystal, PBS: polarized beam splitter, SPCM: single photon counting module, HWP: half-wave plate, QWP: quarter-wave plate, AWP: adjustable wave plate, M: mirror, BD: beam displacer.Here AWP is designed as a HWP in the middle of two QWPs in order to compensate for the phase shift caused by the fiber twist, and can convert circular polarized light to horizontal polarized light without loss.(b) Details of the first two quantum walk steps in our experiment.(c) Measured (colorful bars) and theoretical (red dashes) probability distribution for a four-step quantum walk.Different colors represent different polarization states of the initial input single photons.(d) The second-order correlation function  2  () versus the delay  for our single-photon source.The time window length is approximately 3 ns and  2  (0) is 0.0286 ± 0.001.

Fig. 3 .
Fig. 3. Uniform probability distribution generation in a four-step quantum walk system.(a) Fidelity as the iteration increases.(b) Values of the coin bias ratio of each position and walking step, obtained with our GD algorithm.The black arrow points out the direction of the quantum walking process.The number displayed on the cell is the value of the corresponding coin bias ratio .(c) Measured probability distribution of the quantum walk for right-circular (green) and left-polarized (orange) single photons.The red dashes represent the values of the target probability distribution.

Fig. 4 .
Fig. 4. Gaussian probability distribution generation in a four-step quantum walk system.(a) Fidelity as the iteration increases.(b) Values of the coin bias ratio for each walking step and position, obtained with our GD algorithm.(c) Measured probability distribution of the quantum walk for right-circular (green) and left-polarized (orange) single photons.