Package: qrand
qrandA multiprotocol and multiplatform quantum random number generation frameworkRandom numbers are everywhere.Computer algorithms, data encryption, physical simulations, and even the arts use them all the time. There is one problem though: it turns out that they are actually very difficult to produce in large amounts. Classical computers can only implement mathematical tricks to emulate randomness, while measuring it out of physical processes turns out to be too slow. Luckily, the probabilistic nature of quantum computers makes these devices particularly useful for the task.QRAND is a free and open-source framework for quantum random number generation. Thanks to its loosely coupled design, it offers seamlessly compatibility between differentquantum computing platformsandQRNG protocols. Not only that, but it also enables the creation of custom cross-compatible protocols, and a wide range of output formats (e.g. bitstring, int, float, complex, hex, base64).To boost its efficiency, QRAND makes use of a concurrent cache to reduce the number of internet connections needed for random number generation; and for quality checks, it incorporates a suite of classical entropy validation tests which can be easily plugged into any base protocol.Additionally, QRAND introduces an interface layer forNumPythat enables the efficient production of quantum random numbers (QRN) adhering to a wide variety of probability distributions. This is ultimately accomplished by transforming uniform probability distributions produced in cloud-based real quantum hardware, through NumPy's random module.fromqrandimportQuantumBitGeneratorfromqrand.platformsimportQiskitPlatformfromqrand.protocolsimportHadamardProtocolfromnumpy.randomimportGeneratorfromqiskitimportIBMQprovider=IBMQ.load_account()platform=QiskitPlatform(provider)protocol=HadamardProtocol()bitgen=QuantumBitGenerator(platform,protocol)gen=Generator(bitgen)print(f"Random Raw:{bitgen.random_raw()}")print(f"Random Bitstring:{bitgen.random_bitstring()}")print(f"Random Unsigned Int:{bitgen.random_uint()}")print(f"Random Double:{bitgen.random_double()}")print(f"Random Binomial:{gen.binomial(4,1/4)}")print(f"Random Exponential:{gen.exponential()}")print(f"Random Logistic:{gen.logistic()}")print(f"Random Poisson:{gen.poisson()}")print(f"Random Std. Normal:{gen.standard_normal()}")print(f"Random Triangular:{gen.triangular(-1,0,1)}")# ...Supported quantum platformsAs of May 2021, onlyQiskitis supported. However, support forCirqandQ#is under active development.Implemented QRNG protocolsAs of May 2021, only the basicHadamardProtocolis available. We are also working on implementing thisEntaglementProtocol, as well as a version ofGoogle's Sycamore routine(patent permitting).Authors and citationQRAND is the work of many people who contribute to the project at
different levels. If you use QRAND, please cite as per the includedBibTeX file.Contribution guidelinesIf you'd like to contribute to QRAND, please take a look at thecontribution guidelines. This project adheres to the followingcode of conduct. By participating, you are expected to uphold this code.We useGitHub issuesfor tracking requests and bugs. Please use Unitary Fund'sDiscordfor discussion and simple questions.AcknowledgementsParts of this software's source code have been borrowed from theqRNGproject, which is licensed under theGNU GPLv3license. Copyright notice and specific changes can be found as a docstring wherever this applies.LicenseApache License 2.0(c) Copyright 2021 Pedro Rivero