RNG Using Boson Sampling
Used boson sampling simulation to create a random number generator and Monte Carlo integral solver. This project was completed with fellow optics student Atkin Hyatt as a part of the 2022 Womanium Quantum Computing workshop and hackathon.
Project Overview
Integration is a natural part of many processes in nature, be it classical or quantum mechanical. And unlike their counterpart derivatives, integration is notoriously more difficult. Thus, most integrals must be solved numerically. In this hackathon project, a boson sampler is used to generate random numbers to solve definite integrals using Monte Carlo sampling. For time and simplicity, this method is demonstrated on one dimensional functions. Although the algorithm presented only works for one dimensional functions, higher order integrals can be evaluated by similar methods.
Overview of RNG Solution
To simulate a boson sampling QRNG, this team used the Perceval package and consulted their webpage on boson sampling. Using the sample code as a guide, we defined 14 photons at the input and 60 modes, simulated a boson sampling circuit, and took 2 output samples. We then performed Von-Neuman post processing using the 2 samples to get a final string, which we saved into a .txt file. Iterating this process allowed us to generate a sizable amount of random bits.
NIST SP 800-22 (Statistical Test Suite for Random and Pseudorandom Number Generators)
The team generated a stream of 1000000 bits, saved them into a .txt file, and tested the data with the NIST test package. The random bits generated by our RNG passed most of the tests. The errors we encountered in testing could be due to incompatibilities between the input file format and the test package.
In the screenshot of the test results below, the proportion refers to the fraction of bitstreams that passed a particular test. Stars indicate unsuccessful tests that did not produce reliable or interpretable results.
Bit Rate in bps (bits per second)
The bit rate for our boson sampling RNG was found by timing the execution of the code block responsible for taking 2 samples and performing Von-Neuman post processing.
The table below shows the bit rates we found by repeatedly generating 10000 bits with our RNG. The average, maximum, and minimum bit rates found are displayed below.
Application of Boson Sampling: Monte Carlo Algorithms
Monte Carlo algorthims are a class of techniques which involve random sampling to numerically obtain results. Monte Carlo methods are typically employed when systems are too complex for deterministic algorithms to handle. Although computationally simple, Monte Carlo algorithms rely on vast quantities of randomly generated numbers. Classical random number generators lack the ability to generate truly random numbers, revealing certain correlations and non-randomness given a large enough set. This is where a quantum random number generator (QRNG) with quantum advantage can come to the rescue. Not only does a QRNG produce truly random numbers, it also has the ability to produce them faster than their classical counterparts.
Monte Carlo Integration: Area from Sampling
In this challenge, Monte Carlo sampling is used to numerically evaluate integrals over finite bounds. The integral of a function is equivalent to the area between the curve and the x-axis. The area of a shape is essentially how much hypothetical stuff can be contained within the walls of that shape. Hence we can relate the area of some shape to the amount of points that lie within its walls. The area, and therefore an integral, can then be found by sampling the points inside that shape, the points between the curve and the x-axis. But how can we ensure that the points we decide to sample are fair and unbiased? This is where Monte Carlo sampling comes in. After picking a set of random points, we count how many land between the x-axis and the curve and divide that by the total number of points we chose to sample (see below). Since integrals take into account whether the area is above or below the x-axis, we simply count up when a point lies above the axis and under the curve and count down when the point is below the axis and above the curve. Finally, we scale this ratio by the bounds of our random numbers to obtain the result of our integration.
In the example above, we randomly sample 1000 points and count about 339 landed underneath the curve. Our random numbers go from x = -1 to x = 1 and y = 0 to y = 1, meaning the integral of this function over the given interval is approximately 0.678, only 1.7% off from the actual value of 2/3.
Scope
Of course this technique wouldn't be very useful if we limit ourselves to measly one dimentional integrals for which we have much more powerful tools to tackle. The algorithm can easily be extended into a higher dimentions by sampling additional random number vectors, with one vector for each variable in the expression y = f(x1,x2,x3,...). The Monte Carlo integration method is inefficient for lower order integrals but is far less complex than other deterministic methods for computing higher order integrations. The Riemann sum method, for example, requires one summation for each independent variable in a multivariable function, a task which takes polynomial time. Monte Carlo integration, on the other hand, only requires the generation of additional random number vectors, a proceedure which increases linearly in time.
Sources Consulted
- https://github.com/terrillmoore/NIST-Statistical-Test-Suite
- https://perceval.quandela.net/docs/notebooks/Boson%20Sampling.html
- https://en.wikipedia.org/wiki/Monte_Carlo_method