Astronomical random numbers for quantum foundations experiments

Photons from distant astronomical sources can be used as a classical source of randomness to improve fundamental tests of quantum nonlocality, wave-particle duality, and local realism through Bell's inequality and delayed-choice quantum eraser tests inspired by Wheeler's cosmic-scale Mach-Zehnder interferometer gedankenexperiment. Such sources of random numbers may also be useful for information-theoretic applications such as key distribution for quantum cryptography. Building on the design of an"astronomical random-number generator"developed for the recent"cosmic Bell"experiment [Handsteiner et al., Phys. Rev. Lett. 118, 060401 (2017)], in this paper we report on the design and characterization of a device that, with 20-nanosecond latency, outputs a bit based on whether the wavelength of an incoming photon is greater than or less than 700 nm. Using the one-meter telescope at the Jet Propulsion Laboratory (JPL) Table Mountain Observatory, we generated random bits from astronomical photons in both color channels from 50 stars of varying color and magnitude, and from 12 quasars with redshifts up to $z = 3.9$. With stars, we achieved bit rates of $\sim 1 \times 10^6$ Hz / m$^2$, limited by saturation for our single-photon detectors, and with quasars of magnitudes between 12.9 and 16, we achieved rates between $\sim 10^2$ and $2 \times 10^3$ Hz /m$^2$. For bright quasars, the resulting bitstreams exhibit sufficiently low amounts of statistical predictability as quantified by the mutual information. In addition, a sufficiently high fraction of bits generated are of true astronomical origin in order to address both the locality and freedom-of-choice loopholes when used to set the measurement settings in a test of the Bell-CHSH inequality.


I. INTRODUCTION
Quantum mechanics remains extraordinarily successful empirically, even though many of its central notions depart strongly from those of classical physics. Clever experiments have been designed and conducted over the years to try to test directly such features as quantum nonlocality and waveparticle duality. Many of these tests depend upon a presumed separation between experimenters' choices of specific measurements to perform and features of the physical systems to be measured. Tests of both Bell's inequality and wave-particle duality can therefore make stronger claims about the nature of reality when the measurement bases are determined by events that are separated by significant distances in space and time from the rest of the experiment [1][2][3][4][5][6][7].
Bell's inequality [8] sets a strict limit on how strongly correlated measurement outcomes on pairs of entangled particles can be if the particles' behavior is described by a local-realist theory. Quantum mechanics does not obey local realism and predicts that for particles in certain states, measurement outcomes can be correlated in excess of Bell's inequality. (In a local-realist theory, no physical influence can travel faster than the speed of light in vacuum, and objects possess complete sets of properties on their own, prior to measurement.) Bell's inequality was derived subject to several assumptions, the violation of any of which could enable a local-realist theory to account for correlations that exceed the limit set by Bell's inequality. (For recent discussion of such loopholes, see Refs. [9][10][11].) Beginning in 2015, several experimental tests have found clear violations of Bell's inequality while simultaneously closing two of the three most significant loopholes, namely, locality and fair sampling [12][13][14][15]. To close the locality loophole, one must ensure that no information about the measurement setting or outcome at one detector can be communicated (at or below the speed of light) to the second detector before its own measurement has been completed. To close the fair-sampling loophole, one must measure a sufficiently large fraction of the entangled pairs that were produced by the source, to ensure that any correlations that exceed Bell's inequality could not be accounted for due to measurements on some biased subensemble.
Recent work has revived interest in a third major loophole, known as the measurement-independence, settings-independence, or freedom-of-choice loophole. According to this loophole, local-realist theories that allow for a small but nonzero correlation between the selection of measurement bases and some hidden variable that affects the measurement outcomes are able to mimic the predictions from quantum mechanics, and thereby violate Bell's inequality [1,2,4,5,[16][17][18][19][20][21][22][23].
A cosmic Bell experiment was recently conducted that addressed the freedom-of-choice loophole [1]. A statistically significant violation of Bell's inequality was observed in measurements on pairs of polarization-entangled photons, while measurement bases for each detector were set by real-time astronomical observations of light from Milky Way stars. (This experiment also closed the locality loophole, but not fair-sampling.) The experiment reported in Ref. [1] is the first in a series of tests, which aim to use the most cosmologically distant sources of randomness available, thus minimizing the plausibility of correlation between the setting choices and any hidden-variable influences that can affect measurement outcomes.
Random bits from cosmologically distant phenomena can also improve tests of wave-particle duality. Wheeler [24][25][26] proposed a delayed-choice experiment in which the paths of an interferometer bent around a distant quasar due to gravitational lensing. By making the choice of whether or not to insert the final beamsplitter at the last instant, the photons end up behaving as if they had been particles or waves all along. (For a recent review, see Ref. [27].) In Sec. III, we will discuss how to feasibly implement an alternative experiment with current technology that retains the same spirit and logical conclusion as Wheeler's original gedanken experiment.
In this paper, we describe the design choices and construction of a low-latency astronomical random number generator, building on experience gained in conducting the recent cosmic Bell experiment [1]. While previous work has successfully generated randomness from astronomical images by reading out the pixels of a CCD camera [38], our unique nanosecondlatency, single-photon instrumentation and our analysis framework make this scheme well suited for conducting experiments in quantum foundations. In Sec. II we formalize and quantify what is required to close the freedom-of-choice loophole in tests of Bell's inequality. This sets a minimum signal-to-noise ratio, which in turn dictates design criteria and choices of astronomical sources. In Sec. III we describe how astronomical random number generators may be utilized in realizations of delayed-choice gedanken experiments, to dramatically isolate the selection of measurements to be performed from the rest of the physical apparatus. In Sec. IV we compare different ways to turn streams of incoming astronomical photons into an unpredictable binary sequence whose elements were determined at the time of emission at the astronomical source and have not been significantly altered since. After discussing the instrument design in Secs. V-VI, we characterize in Sec. VII the response of the instrument when observing a number of astronomical targets, including ≈50 bright Milky Way stars selected from the HIPPARCOS catalog having different magnitudes, colors, and altitudes. We also describe our observation of 12 quasars with redshifts ranging from z = 0.1-3.9. Finally, in Sec. VIII we quantify the predictability of the resulting bitstreams, and demonstrate the feasibility of using such quasars in the next round of cosmic Bell tests. Concluding remarks follow in Sec. IX.

II. CLOSING THE FREEDOM-OF-CHOICE LOOPHOLE IN BELL TESTS
To address the freedom-of-choice loophole in a cosmic Bell test, the choice of measurement basis on each side of the experiment must be determined by an event at a significant space-time distance from any local influence that could affect the measurement outcomes on the entangled particles [1,4,7]. As we demonstrate in this section, an average of at least ≈79% of detector settings on each side must be generated by information that is astronomical in origin, with a higher fraction required in the case of imperfect entanglement visibility. We will label detector settings that are determined by genuinely astronomical events as valid, and all other detector settings as invalid. We will use this framework to analyze random numbers obtained from both stars and quasars. As we will see in later sections, invalid setting choices can arise for various reasons, including triggering on local photons (sky glow, light pollution) rather than astronomical photons, detector dark counts, as well as by astronomical photons that produce the wrong setting due to imperfect optics.
Here a and A refer to the measurement setting and outcome at Alice's detector (respectively), and b and B refer to Bob's detector. We follow the notation of Ref. [1] and write the Clauser-Horne-Shimony-Holt (CHSH) parameter, S [39], in the form where E k = 2p(A = B|a k b ) − 1, and p(A = B|a k b ) is the probability that Alice and Bob measure the same outcome given the joint settings (a k ,b ). Bell's inequality places a restriction on all local-realist theories. In terms of the quantity S, the Bell-CHSH inequality takes the form S 2 [39]. The value of S that one measures experimentally may be expressed as a linear combination of S valid , due to astronomical setting choices, and S invalid , due to nonastronomical setting choices. We may write where q is the probability that both setting choices are generated by a given pair of astronomical sources for a given experimental run. We conservatively assume that a local-realist theory could exploit the freedom-of-choice loophole to maximize S exp by engineering each invalid experimental run to yield the mathematical maximum of S invalid = 4, while we assume that each valid run would be limited to S valid 2 by the usual Bell-CHSH argument. A relaxed version of the Bell-CHSH inequality is then S exp 4 − 2q. This makes the statistical significance of any experimental Bell violation highly sensitive to the fraction of valid settings generated. Since quantum mechanics predicts a maximum value S QM = 2 √ 2 [40], and since S exp 4 − 2q S QM , we conclude that for a cosmic Bell experiment to distinguish between the predictions of quantum mechanics and a local-realist alternative that exploits the freedom-of-choice loophole, we must be able to conduct a sufficiently high fraction q of our experimental runs using valid astronomical photons: In this framework, there are local-realist models in which only one detector's setting choice needs to be influenced or predicted by a hidden-variable mechanism in order to invalidate a given experimental run and produce S = 4. We conservatively assume that corrupt settings do not occur simultaneously, allowing the local-realist alternative to maximally exploit each one. If we denote by q (i) the probability that a setting at the ith detector is valid, with i = (Alice, Bob), then (1 − q (i) ) is the probability that the ith detector setting is invalid. The fraction of valid settings therefore must be at least For simplicity, if we assume that the experiment is symmetric with q Alice = q Bob = q * , we find that q * (3 − √ 2)/2 79.3%. Thus, for a symmetric setup, roughly eight out of ten photons incident on each random number generator need to be of astronomical origin. When choosing a scheme for generating random numbers, it is necessary to keep this signal-to-noise threshold in mind.
It is also important to consider that it is very difficult in practice to achieve a value of S close to the quantummechanical maximum of 2 √ 2 ≈ 2.83, due to imperfections in the experimental setup. For example, the first cosmic Bell test obtained values of S exp = 2.43 and S exp = 2.50 [1]. Under such conditions, q would need to be correspondingly higher to address the freedom-of-choice loophole. Also, the closer the measurement of S exp is to the validity-modified local-realist bound, the more experimental runs are required to achieve a statistically significant Bell violation. Hence the eight-out-often rule derived here represents the bare minimum to close the freedom-of-choice loophole for pure entangled states and robust statistics with many experimental runs. In later sections we measure different sources of invalid detections and find quasars that are on both sides of this usefulness bound with our telescope.

III. DELAYED-CHOICE EXPERIMENTS
Another application of an astronomical random number generator is to use it in an experiment to test wave-particle duality. The concept of testing wave-particle duality with a Mach-Zehnder interferometer was first proposed by Wheeler [24,25] and has been realized in several laboratory-scale experiments using single photons and single atoms [41][42][43]. In such an experiment, each photon that enters the first beamsplitter exhibits self-interference if the second beamsplitter is present,  where the second beamsplitter can be rapidly inserted or removed after a single photon from S passes the first beamsplitter. The legend here applies for Figs. 1-4. and the pattern of single-photon detections observed after aggregating many trials is in correspondence with a classical wave picture. However, if the final beamsplitter is absent, the light from each path would not recombine, and single photons would appear at one output or the other, revealing which path was taken. In Wheeler's original proposal [24], the experimenter would be able to choose whether to insert or remove the second beamsplitter after the photon had entered the interferometer. Such a scenario was dubbed a delayed-choice experiment because the photon's trajectoryone path, the other, or both-was determined after it passed the first beamsplitter. If one rejects wave-particle duality, the logical conclusion is that either the choice of removing the final beamsplitter in the final moments of the light's journey somehow retrocausally affected the light's trajectory, or that the experimenter's choice of removing the final beamsplitter was predictable by the light before it embarked on its journey. (See also Ref. [27].) See Fig. 1.
Wheeler next proposed [26] a cosmological version of this test, with the source of interfering photons being a cosmologically distant quasar and the first beamsplitter being an intervening gravitational lens that produces at least two images of the quasar on Earth. If the two images are recombined at a final laboratory beamsplitter, the quasar photons would exhibit interference between distinct paths of cosmological scale. If the final beamsplitter were removed, the photons would not exhibit interference and one could presumably identify unique trajectories for such photons from emission at the quasar to detection on Earth. If one insists on rejecting wave-particle duality in this case, it would appear as if the experimenter's choice on Earth had determined whether the photon took one path or both, billions of years ago. See Fig. 2.
The feasibility of realizing Wheeler's quasar experiment has been explored [44]. The central difficulty is maintaining the quantum coherence of the light traveling over cosmological distances. Rather than try to interfere astronomical photons with a gravitational lens, we can realize a related experiment that leads to the same logical conclusion. Instead of testing the wave-particle duality of an astronomical photon, we may use a standard tabletop Mach-Zehnder interferometer, and use astronomical setting choices to determine whether to insert or remove the beamsplitter after a laboratory-produced photon has entered the interferometer. In such a setup, the choice of which measurement to perform would be made in a causally disconnected way from the particulars of the behavior of the photon in the interferometer, billions of years before the interferometer photon had even been created. See Fig. 3.
In this experiment as well as Wheeler's original gedanken experiment, a cosmologically long time interval is realized between when a photon enters the first beamsplitter, and when the presence or absence of the second beamsplitter is determined. In Wheeler's experiment, the photon enters the gravitational lens and the second beamsplitter's presence is determined billions of years later by experimenters on Earth. In our proposed experiment, a quasar photon emitted billions of years ago determines the state of the second beamsplitter, while laboratory-generated single photons are sent into a tabletop interferometer. Separating the choice of inserting the beamsplitter from both the creation of the photon and its journey makes alternate explanations of wave-particle duality implausible.
In addition to such delayed-choice experiments, a related line of experiments probe so-called quantum erasure [27], which likewise draw inspiration from Wheeler's original One way to perform a delayed-choice experiment that keeps the spirit of Wheeler's cosmic proposal, using an astronomical random number generator to determine whether to insert or remove the second beamsplitter in the Mach-Zehnder interferometer. Like in Wheeler's original proposal, the space-time location where the choice is made is separated from the interferometer's first beamsplitter by astronomical distances. However, unlike in Wheeler's gravitational lens proposal, the astronomical photon does not go through the interferometer nor does it exhibit any wavelike properties. It is instead used to generate a classical random number that determines whether to insert or remove the beamsplitter while a locally generated single photon is in flight. It is helpful to use a photon pair source E to generate single photons and to postselect coincidence events. A two-photon entangled state is produced at E, sending one entangled partner (the environment photon) towards W and the other (the signal photon) toward a Mach-Zehnder interferometer (MZI). An astronomical random number generator (ARNG) activates an electro-optical modulator (EOM) in order to rapidly set the measurement basis for the environment photon at W , potentially revealing which-path information about the signal photon. The signal photon at the MZI acts as a particle or a wave accordingly, even though the decision point of whether to reveal which-path information is made potentially billions of years before the experiment has been run, out of the past light cone of the interferometer.
proposal (see also Refs. [45,46]). In modern delayed-choice quantum-eraser experiments [3], wave-particle duality is tested by interfering one entangled partner (the signal photon) of a two-photon entangled state in a Mach-Zehnder interferometer. Rather than removing the beamsplitter in the Mach-Zehnder interferometer, a measurement of the other entangled partner (the environment photon) is made outside the light cone of the signal photon to erase which-path information. This can be done at the same time or after the signal photon propagates through the interferometer [3,27]. Here again, we can realize Wheeler's original ambition to manifest the features of quantum mechanics on cosmic scales in a cosmic eraser experiment. In our proposed test, light from an astronomical source would determine whether which-way information is erased. See Fig. 4.
In the framework of quantum mechanics, these quantum eraser experiments begin with a polarization-entangled state of signal and environment photons. Following the discussion in Ref. [3], we may write such a state as When the signal photon enters the interferometer, the polarizing beamsplitter maps the polarization information of the signal photon onto which path it takes through the interferometer, with horizontally polarized photons taking path a and vertically polarized photons taking path b. A half-wave plate rotates path a's horizontal polarization into vertical polarization, erasing which-way information encoded in the polarization of this photon: |H → |a,V = |a and |V → |b,V = |b . If we assume the b path picks up an adjustable phase φ, the state afterward may be written as After the final 50:50 beamsplitter in the interferometer, the two signal paths will recombine. The signal's which-way information is still potentially available in the polarization of the environment photon. If the environment photon is measured in the |H e ,|V e basis, which-path information about the signal photon is nonlocally revealed, and no phase-dependent interference is observed. We can see this in the joint probability of any pair of signal and environment detectors firing simultaneously: the probability that both upper detectors register a coincidence when measuring in the |H e ,|V e basis is and no interference fringes are observed in the coincidence probability. On the other hand, if the electro-optic modulator (EOM) rotates the environment photon such that incoming |R e photons enter the upper detector and incoming |L e photons enter the lower detector, information about the signal photon's path is lost. Then the coincidence probability is given by | R| e a| s |ψ + R| e b| s |ψ | 2 = 1 4 (1 + sin φ) (9) and interference fringes are observed in the coincidence probabilities. We emphasize that for both linear and circular basis choices, the signal photon enters each detector with equal probability, so as with any entangled state, information cannot be sent simply by nonlocally choosing a measurement basis. Interference fringes or the lack thereof can only be seen when one sorts the signal photon's detections into categories based on the basis choice and measurement result of the environment photon. As in tests of Bell's inequality, any apparent nonlocality is only nonlocality of correlations.
Any local explanation of the nonlocal correlations in this experiment would rely on being able to predict whether the measurement of the environment photon erases or reveals which-path information of the signal photon, dictating the wavelike or particlelike behavior of the signal photon. Setting the environment photon's measurement basis with a single astronomical random number generator can be used to dramatically constrain the potential origins of this predictability.

IV. GENERATING ASTRONOMICAL RANDOMNESS
We consider two potential schemes for extracting bits of information from astronomical photons to use as sources of randomness for use in experiments such as those described in Secs. II-III. In general, it is important that the information extracted be set at the time of the astronomical photon's emission, rather than at the time of detection or any intervening time during the photon's propagation. We deem the setting corrupt if this condition is not met, and we evaluate two methods with particular emphasis on the mechanisms by which corruption may occur.

A. Time of arrival
The first method is to use the time of arrival of the astronomical photons to generate bits [4,5]. We can choose to map time tags to bits based on whether some prespecified decimal place of the time stamp is even or odd. For example, a 0 could correspond to the case of a photon arriving on an even nanosecond, and a 1 for arrival on an odd nanosecond.
The main advantage of this scheme is its simplicity: since time stamps need to be recorded to close the locality loophole, there is no need for additional hardware to generate random settings. In addition, it will always be possible to ensure a near-50:50 split between the two possible setting choices at each side of the experiment regardless of the source of astronomical randomness. Indeed, our time tags, when mapped to random bits by their time stamp, pass every test of randomness in the NIST Statistical Test Suite for which we had sufficient bits to run them [47].
The primary disadvantage of this scheme is that it is very difficult to quantify galactic and terrestrial influences on the recorded time stamp of the photon's arrival. It is necessary that we be able to quantify the fraction of photons that are corrupt, as discussed in Sec. II. In the remainder of this section, we consider the constraints on which decimal place in the detection time stamp should be used to generate random bits.
It is tempting to condition setting choices on the evenness or oddness of a subnanosecond decimal place, making use of deterministic chaos and apparent randomness. However, the time stamp of a given photon's arrival at this level of precision is sensitive to corruption from myriad local influences, which are difficult (perhaps impossible) to quantify, such as effects in the interstellar medium, time-dependent atmospheric turbulence, and timing jitter in the detectors or time-tagging unit, which may affect the even-odd classification of nanosecond time stamps. The atmosphere has an index of refraction n ≈ 1 + 2.9 × 10 −4 , which in a 10 km-thick atmosphere corresponds to the photons arriving ∼ 10 ns later than they would if traveling in a vacuum [48]. Thus, relying upon any decimal place less significant than the tens-of-nanoseconds place to generate a bit admits the possibility of the atmosphere introducing some subtle delay and corrupting the generated bits.
Choosing a setting by looking at the evenness or oddness of microsecond time stamps, on the other hand, makes it difficult to close the locality loophole in tests of Bell's inequality. To close the locality loophole, a random bit must be generated on each side of the experiment within a single timing window, whose duration is set by the distance between the source of entangled particles and the closer of the two measurement stations (≈3 μs in the first cosmic Bell experiment [1]). The coincidence rate between the two RNGs is proportional to the bit generation rate on each side, increasing the number of Bell runs achievable within a certain experiment runtime. However, if the bit generation rate increased, the bits lose their apparent randomness: generating bits at any rate faster than 1 μs −1 would simply yield strings of consecutive 0's and 1's. This creates a difficult scenario where the experimenter can only increase the rate of successful runs by sacrificing the statistical unpredictability of the random bits, in a scenario where it is already desirable to maximize the rate of successful runs due to practical constraints on observatory telescope time.
In addition, for rates that are slow compared to the causal validity time, the remote setting choice on each side of the experiment is a deterministic function of time. Using even or odd time stamps to determine the setting choice admits the possibility that a local hidden variable theory, acting at the entanglement source, emits photon pairs to coincide with a particular setting choice. For these reasons, using the time stamp of astronomical photons' arrivals does not appear to be an optimal method for generating unpredictable numbers of astronomical origin.

B. Colors
An alternate approach, developed for use in the recent cosmic Bell test [1], is to classify astronomical photons by designating a central wavelength λ and mapping all detections with λ < λ to 0 and detections with λ > λ to 1 using dichroic beamsplitters with appropriately chosen spectral responses. The advantage of the wavelength scheme is that possible terrestrial influences on photons as a function of wavelength are well studied and characterized by empirical studies of astronomical spectra, as well as studies of absorption and scattering in the atmosphere. In contrast to effects that alter arrival times, the effects of the atmosphere on the distribution of photon wavelengths varies over the course of minutes or hours, as astronomical sources get exposed to a slowly varying air mass over the course of a night-long Bell test. The air mass, and therefore the atmosphere's corrupting influence on incoming astronomical photons, can be readily quantified as a function of time.
One important advantage of using astronomical photons' color stems from the fact that in an optically linear medium, there does not exist any known physical process that could absorb and reradiate a given photon at a different wavelength along our line of sight, without violating the local conservation of energy and momentum [1]. While photons could scatter off particles in the intergalactic media (IGM), interstellar media (ISM), or Earth's atmosphere, a straightforward calculation of the column densities for each medium indicates that among these, the number of scatterers per square meter is highest in the Earth's atmosphere by more than two orders of magnitude compared to the ISM in the Milky Way, and several orders of magnitude greater than in the IGM [49]. Hence, treating the IGM and ISM as transparent media for photons of optical frequencies from distant quasars is a reasonable approximation.
For photons of genuinely cosmic origin, certain wellunderstood physical processes do alter the wavelength of a given photon between emission and detection, such as cosmological redshift due to Hubble expansion. Such effects, however, should not be an impediment to using astronomical photons' color to test local-realist alternatives to quantum mechanics.
The effects of cosmological redshift are independent of a photon's wavelength at emission, and hence treat all photons from a given astronomical source in a comparable way [50,51]. Gravitational lensing effects are also independent of a photon's wavelength at emission [52], though lensing accompanied by strong plasma effects can yield wavelength-dependent shifts [53]. Even in the latter case, however, any hidden-variable mechanism that might aim to exploit gravitational lensing to adjust the detected wavelengths of astronomical photons on a photon-by-photon basis would presumably need to be able to manipulate enormous objects (such as neutron stars) or their associated magnetic fields (with field strengths B > 10 8 Gauss) with nanosecond accuracy, which would require the injection or removal of genuinely astronomical amounts of energy. Thus, whereas some of the original hidden-variable models were designed to account for (and hence be able to affect) particles' trajectories [54,55]-including, thereby, their arrival times at a detector-any hidden-variable mechanism that might aim to change the color of astronomical photons on a photon-by-photon basis would require significant changes to the local energy and momentum of the system.
The chief disadvantage of using photons' color in an astronomical random number generator is that the fluxes of red (λ > λ ) and blue (λ < λ ) photons will almost never be in equal proportion, and hence will yield an overall red-blue statistical imbalance. Such an imbalance in itself need not be a problem: one may conduct Bell tests with an imbalance in the frequency with which various detector-setting combinations are selected [1,11]. However, a large red-blue imbalance does affect the duration of an experiment-whose duration is intrinsically limited by the length of the night-because collecting robust statistics for each of the four joint setting choices (a k ,b ) would prolong the experiment.
A second disadvantage comes from imperfect alignment. If the detectors for different colors are sensitive to different locations on the sky, atmospheric turbulence can affect the paths of photons and the relative detection rates. We see evidence of this effect at the subpercent level in the measurements described in Sec. VII: the probability of the next photon being the same color as the previous few photons slightly exceeds what is expected from an overall red-blue imbalance. We quantify this effect in terms of mutual information in Sec. VIII. This effect could have been mitigated through better alignment since our aperture was smaller than the active areas of our detectors, but the sensitivity profiles of our detectors' active areas would have to be identical to eliminate it entirely.
We devote the remainder of this paper to the photon-color scheme, given its advantages over the time-stamp scheme. We point out that any time-tagging hardware that outputs bits based on color can also output bits based on timing.

V. DESIGN CONSIDERATIONS
As became clear during the preparation and conduct of the recent cosmic Bell experiment [1], in designing an instrument that uses photon colors to generate randomness, it is necessary to begin with a model of how settings become corrupted by local influences and make design choices to minimize this. In this section we build on the discussion in Ref. [1] to characterize valid and invalid settings choices.
One obvious source of potential terrestrial corruption is from background noise, due to thermal fluctuations in the detector (or dark counts), as well as background light from the atmosphere (or sky glow). We designate the sum of these two rates as n (i) j , where j labels the two detector arms (red and blue) and i labels the two random number generators (Alice and Bob) in a test of Bell's inequalities. If we measure a count rate of r (i) j when pointing at an astronomical source, then the probability of obtaining a noise count is simply n (i) j /r (i) j . In selecting optics, it is important to select single-photon detectors, which have low dark count rates and a small field of view on the sky, in order to minimize this probability.
A second source of terrestrial corruption is misclassification of photon colors. A typical way to sort photons by color is to use a dichroic beamsplitter. However, due to imperfections in the dichroic beamsplitter's spectrum, there is a nonzero probability that a photon in the red wavelength range is transmitted towards the arm designated for blue photons and vice versa. We need to select dichroic beamsplitters with high extinction ratios and steep transitions such that crosstalk is minimized.
To quantify the contribution from imperfect dichroic mirrors, we define j to be the color opposite to j , that is, red if j refers to blue and vice versa. Depending on the source spectrum, some fraction f (i) j →j of photons end up in the j th arm, despite being of the j th color. If s (i) j astronomical photons per second of color j are intended for the ith detector, photons leak into the j th arm at a rate of f j →j s (i) j . Knowing r (i) j , n (i) j , as well as the mixture rates f j →j ,f j →j allows us to unmix the observed count rates r j to back out the true fluxes s (i) j . We will discuss the computation of f (i) j →j for our instrument in a later section.
In summary, the rate that the j th detector arm in the ith detector yields a corrupt setting is at most the sum of the noise rate, n (i) j , and the rate of misclassifications from the j th arm, f j →j s (i) j . Since the total observed count rate is r (i) j , the probability of obtaining an incorrect setting is The overall probability of corruption for a bit is conservatively estimated by maximizing over its red and blue detector arms.
Since the overall probability of corruption is not necessarily the same for Alice and Bob, we denote this invalid-bit probability p (i) , where where the average of the two valid-bit probabilities q (i) needs to be at least 79.3%, as discussed in Sec. II. Note that the j index labels individual detector arms, whereas the i index labels different observers' detectors after maximizing over each detector's arms.
To minimize an individual detector arm's corruption probability p j , it suffices to minimize the quantities n j by minimizing the dark count and sky-glow rates, and to choose high-quality dichroic beamsplitters to minimize f j →j . The total count rate, r j , is maximized when the atmosphere is most transparent: thus, we will designate our red and blue observing bands to roughly coincide with the near-infrared (700 nm-1150 nm) and optical (350 nm-700 nm), respectively [1,4].
Several other design considerations are equally important. The instrument must be able to point to dim and distant target objects, which are typically high-redshift quasars. The dimness of even the brightest high-redshift quasars in optical and near-infrared (NIR) wavelengths not only makes it difficult to establish the high signal-to-noise ratio required, but also makes tracking objects nontrivial over the duration of a Bell test, which can last for hours. At the same time, the instrument must generate settings at a sufficiently high rate to perform the experiment. Each run of a Bell inequality test only closes the locality and freedom-of-choice loopholes if valid settings from quasars arrive on both sides within a time window whose duration is set by the light-travel time between Alice and Bob. Thus having a high collection efficiency of the quasar light is doubly important.

VI. INSTRUMENT
Our astronomical random number generator incorporates several design features that were developed in the course of preparing for and conducting the recent cosmic Bell experiment [1]. A schematic of our new instrument, constructed at the Harvey Mudd College Department of Physics, is shown in Fig. 5 and a photo in Fig. 6. It is housed in a box made of black Delrin plastic of dimensions 30 × 30 × 10 centimeters and weighs 5.5 kg, most of which is the weight of two single-photon detectors and the astronomical pointing camera. The instrument was mounted at the focus of a 1-meter aperture, 15-meter focal-length telescope at the NASA Jet Propulsion Laboratory's Table Mountain Observatory. The light from the telescope is coupled directly into our instrument's aperture without using optical fibers to reduce coupling losses. Astronomical light from multiple objects in the field of view of the telescope enters at the top right of the schematic. This light is brought to a focus by the telescope onto the plane of the pinhole mirror. Most of the light is reflected by the mirror (yellow) and refocused onto a CCD. However, light from an object of interest (purple) passes through the pinhole, and is then collimated and sorted by color via a system of one short-pass and one long-pass dichroic beamsplitter. These beams (red and blue) are refocused onto the active area of our two avalanche photodiodes for detection and timestamping. The placement of the dichroics is similar to the fiber-coupled scheme used in Ref. [1].
FIG. 6. Photo of our astronomical random number generator in the laboratory with the lid off and dichroic beamsplitters exposed.

A. Optics
The telescope light is focused onto a 200 μm pinhole on a Lenox Laser 45 • pinhole mirror. The size of this pinhole was chosen to minimize sky-glow background (and therefore the predictability due to sky glow) by matching the 2-3 arcsecond astronomical seeing at the Table Mountain site. The pinhole diameter corresponds to 2.75 arcseconds on our 15 m focal-length telescope. The incoming light that does not pass through the pinhole is reflected by the mirror and reimaged through a Canon EF-S 60 mm F2.8 macro lens onto a ZWO ASI 1600 MM cooled 4/3 CMOS camera, which aids in finding and positioning the source into the pinhole. Real-time monitoring of this camera was used to guide the telescope in some observations and to capture long exposures as in Fig. 7 and Fig. 8.
The light from the object of interest that passes through the pinhole gets collimated by a 25 mm diameter, 50 mm focal-length achromatic lens (Edmund 49-356-INK). This collimated light gets split by a system of two dichroic beamsplitters, with shorter-wavelength light (denoted blue) being transmitted and longer-wavelength light being reflected. The beams are focused onto one IDQ ID120 Silicon Avalanche Photodiode detector through a 25 mm diameter, 35 mm focallength achromatic lens (Edmund 49-353-INK) mounted on a two-axis translation stage attached to the detector. The image of the pinhole is reduced to 140 μm in diameter, which is well within the ID120's 500 μm active area, making for stable alignment and minimal concern about aberrations and diffraction. The efficiency of the whole system -from the top of the atmosphere to an electronic pulse -is on the order of 30%, dominated by loss from the detectors and Rayleigh scattering in the atmosphere.  Table Mountain Observatory, it is possible to compute the angular diameter of Saturn. This enables us to estimate the size of the pinhole as an ellipse with semimajor axes of 2.01 and 3.15 arcseconds. The horizontal and vertical lines running through the pinhole are cross hairs to guide the eye. The field of view calculated via Saturn is consistent with the field of view computed using telescope and camera parameters.

B. Detectors and time tagging
The ID120 Silicon Avalanche Photodiode Detectors (APDs) have up to 80% quantum efficiency between 350 and 1000 nm and a low (<100 Hz) specified dark count rate. These have an artificially extended dead time of 420 ns to prevent after-pulsing. They have a photon-to-electrical-pulse latency of up to 20 ns. The detectors' active area was cooled to −40 • C and achieved a measured dark count rate of ≈40 Hz. Signals from the APDs are recorded by an IDQ ID801 Time to Digital Converter (TDC). The relative precision of time tags is limited by the 80.955 ps clock rate of the TDC, and by the 300 ps timing jitter on the APD. As a timing reference, we also record a stabilized one-pulse-per-second signal from a Spectrum Instruments TM-4 GPS unit. (Absolute time can FIG. 8. Dim objects such as the quasar PG 1718 + 481 (shown here) were identified by comparing the local field to astronomical catalogs. Dark counts were typically recorded by keeping the object a few spot sizes away from the pinhole, for example, as the telescope is positioned here.
FIG. 9. The total count rate over time for various sources fluctuates dramatically due to 2-3 arcseconds of seeing and telescope pointing, which are on the order of our pinhole size. The legend entries appear in the same vertical ordering as on the plot. The small spike in the Darks + Sky-glow trace is likely from an object such as a plane or satellite that briefly passed through our field of view, or headlights from a car. also be recorded using this GPS unit's IRIG-B output.) The GPS timing solution from the satellites is compensated for the length of its transponder cable, which corresponds to a delay of 77 ns.

C. Dichroic beamsplitters
Building on the analysis in Ref. [1], we formulate a model of the instrument's spectral response in each arm to characterize its ability to distinguish red from blue photons. The aim of this section is to compute the f j →j parameters for our instrument, defined as the probability that photons of type j are detected as photons of type j . As described in Sec. V, such misclassified photons contribute to invalid detector-setting choices in the same way that noise does.
The parameter f j →j depends on the choice of what cutoff wavelength λ we choose to distinguish the photons we call red (λ > λ ) from blue (λ < λ ). It also depends on the emission spectra of the astronomical source. Note that since this color cutoff is completely arbitrary, we may choose λ differently for each astronomical source such that the crosstalk probability is minimized. These probabilities can be computed from the atmospheric scattering and absorption, detector quantum efficiencies, and transmission and reflection probabilities of the optics in each detector arm (see Fig. 10). We define the following quantities, which all are dependent on wavelength: N source (λ): Number distribution of astronomical photons per wavelength that impinge on the top of Earth's atmosphere towards the telescope. We treat the interstellar-intergalactic medium as transparent because the column density of the ISM/IGM is lower than that of the Earth's atmosphere by at least a factor of 400, even over cosmological path lengths.
N in (λ): Number of photons per wavelength that are transmitted through the atmosphere and impinge on the pinhole mirror. In terms of these quantities, we can compute the overall spectral response of the red and/or blue arms of the instrument: as well as the parameters f j →j : For bright stars such as the ones we observe, the quantity N source (λ) is well approximated by a blackbody [56]. For dim, 042120-9 TABLE I. A list of quasars observed, their corresponding redshifts z, and light travel times τ . We report their B and V magnitudes from the SIMBAD Astronomical Database and our observed 75th percentile count rates. The table is sorted by the fraction of valid settings q (i) for each quasar observation, based on both off-target counts measured at each observation's airmass and rates for quasar photons to go the wrong way through our imperfect dichroics calculated from each quasar's emission spectrum. Predictability, as measured by I = max m I N (m; m + 1), is the small mutual information we measured in each quasar's bitstream and corresponds to a negligible reduction in q (i) . Even using a small (1 m) telescope at a light-polluted Los Angeles observing site, we find that the first quasar (3C 273) paired with either of the next two would yield q Alice + q Bob in excess of the limit set by Eq. (4) for addressing the freedom-of-choice loophole.

Name
Redshift ( redshifted quasars, we apply the appropriate Doppler shift to the composite rest-frame spectrum computed in Ref. [57]. Once N source is obtained, we compute N in (λ) via the equation where ρ atm (λ) is taken from the atmospheric radiative transfer code MODTRAN [58] and takes into account the Rayleigh scattering and atmospheric absorption at zenith. In order to correct for off-zenith observations, we insert a factor of exp[−Xτ (λ)] where X is the observation air mass and τ (λ) is the optical depth due to Rayleigh scattering. In doing so, we make the approximation that the contribution to f j →j due to the optical density of absorption is negligible compared to Rayleigh scattering. In preparing for the recent cosmic Bell experiment [1], it was determined that two dichroics were necessary because a single dichroic's optical density was low enough such that a non-negligible fraction of the light could go either way and would not be determined by the astronomical object. With this model, we selected our two dichroic beamsplitters to minimize the total amount of crosstalk while splitting the detector's sensitivity band in roughly equal halves. We determined that putting the short-pass dichroic beamsplitter first yielded lower crosstalk than the other way around. We used a 697 nm shortpass dichroic beamsplitter (Semrock F697-SDi01-25x36) and an additional 705 nm long-pass dichroic beamsplitter (Semrock FF705-Di01-25x36) to reduce the number of wrong-way photons in the reflected (red) arm.
For the quasars listed in Table I, we compute f j →j values in the ranges 0.16% < f b→r < 0.20% and 0.17% < f r→b < 0.23%, an order of magnitude better than the values of f j →j achieved with the instrumentation used for the original cosmic Bell experiment in Ref. [1]. We plot in Fig. 10(d) the products ρ blue N in and ρ red N in , where N in is computed for the quasar PG 1718+481 at an observation altitude of 67 degrees.

VII. OBSERVATIONS
We observed roughly 50 stars of varying B-V color roughly at zenith, generating astronomical random bits at rates from ∼1 × 10 4 Hz −1 × 10 6 Hz. Count rates for these, along with 12 different quasars, are plotted in Fig. 11 as a function of astronomical V-band magnitude, denoted m V . The V band is defined by a broad filter centered at 551 nm with a FWHM of 88 nm.
Count rates as a function of time for dark counts and several stars and quasars are shown in Fig. 9. To characterize the dark-count rates of the instrument, we close the telescope dome FIG. 11. For 50 bright stars in the HIPPARCOS catalog observed at zenith and twelve high-redshift quasars (z < 3.911), we plot the total (red + blue) background-subtracted count rate against the V-band magnitude (551 ± 88 nm). Though the V magnitude is well into our blue band, it is the only data available for all observed objects and turns out to be a good predictor of the observed photon flux, as seen by the best-fit line that relates the two. We see subtle evidence of detector nonlinearity at high count rates, as discussed in the text. and obstruct its aperture with a tarp, and measure the count rate for about 500 s. We find that the variability in count rates, when integrated over 1 s, is consistent with a Poisson process with variance √ N : in the blue arm we see 41 cps, and in the red arm we see 93 cps. At zenith, the background rates due to sky glow were roughly 20 Hz and 60 Hz in the blue and red arms, respectively. (For comparison, the quasars we observed had rates of 100 to 1000 Hz in each channel.) The reason for this asymmetry results from a combination of different optical coupling efficiencies in each arm and the spectrum of the background sky glow, which tends to be brighter in the near-infrared than in the visible band.
A comprehensive list of our star observations is available upon request. We find that the astronomical bit rate per telescope area is given approximately by log 10 (countrate[Hz/m 2 ]) after subtracting sky glow and dark counts. The deviation from the expected slope of −0.4 is likely due to detectors becoming significantly saturated at count rates higher than ∼1 × 10 5 Hz.
In addition, we generated random bits from a number of quasars, with V-band magnitudes ranging from 12.9 to 16, and redshifts up to z = 3.911, with bit rates ranging from ∼1 × 10 2 Hz −2 × 10 3 Hz. Light travel times τ are calculated from the maximally constrained cosmological parameters from the Planck satellite [60]. The two most distant quasars we observed emitted their light over 12 × 10 9 years ago, a significant fraction of the 13.8 × 10 9 -year age of the universe. A summary of our quasar observations, and two measures quantifying the physical and information-theoretic predictability of bits (p (i) and I ), are presented in Table I. Time-stamped random bits generated from these quasars are available [59].

VIII. QUALITY OF RANDOMNESS
In addition to quantifying the fraction of valid runs as was done in Ref. [1], we may assess the quality of randomness statistically to yield a measure of predictability. The NIST Statistical Test Suite [47] provides a device-independent statistical approach to evaluate the quality of the output of any random number generator given a sufficiently large number of bits. When using time stamps to generate random bits based on whether photons arrive on an even or odd nanosecond, we find that our random numbers pass the NIST test suite, consistent with the findings in Ref. [5]. When using photon colors to generate random bits, our data fail the NIST tests, largely due to the existence of an overall imbalance in red-blue count rates.
To quantify imperfect statistical randomness in a bitstream, we may consider the mutual information between a moving window of m bits and the (m + 1)th bit, which we denote as I (m; m + 1). If each bit were truly independent, this mutual information would be zero, even if the probability to get a 0 or 1 was not 50%. To define I (m; m + 1), let X m denote the set of all length-m binary strings, and let p(x) be the probability that an m-bit string within our bitstream is x ∈ X m . Similarly, let p(y) be the probability that the next bit is y ∈ {0,1}. If we define p(x,y) to be the probability that a string of m + 1 bits are x followed by y, then the mutual information in our data is defined to be Note that if the next bit is independent of the m bits preceding it, then p(x,y) = p(x)p(y) and the mutual information vanishes.
Estimating the true mutual information in a sample of length N , denoted I N (m; m + 1), is in general a highly nontrivial problem. Precise knowledge of the true probabilities p(x,y),p(x), and p(y) is required. While statistical fluctuations in counting the numbers of zeros and ones in a particular data set has an equal chance of overestimating or underestimating the finite-sample estimatesp(x,y),p(x), and p(y), any statistical fluctuations in these probability estimates cause an upward bias in the estimated mutual information in the data set [61] if we simply plug in the experimental probability estimatesp into Eq. (15), which takes as input the true probabilities p. An intuitive explanation for this bias in the mutual information is that our mutual information estimator cannot distinguish between a true pattern in the collected data and a random statistical fluctuation. We emphasize that it is statistical fluctuations in the count rates that cause overestimation of the mutual information. For example, a random realization of a 50:50 bitstream composed of 0's and 1's is unlikely to have exactly the same number of 0's and 1's (or the exact same number of occurrences of 01's and 00's), but regardless of whether there are more 01's or 00's, the mutual information will increase.
We denote this upward-biased estimator byÎ N (m; m + 1). However, in the limit that the data set is large (N 1), and if m is fixed, the amount of positive bias in the estimated mutual informationÎ N (m; m + 1) is dependent only on N and can be represented as a perturbation away from the true mutual information I (m; m + 1). To construct an unbiased estimator that removes these finite-size effects, we adopt the ansatz [61] where I (m; m + 1), a, and b are fixed, unknown constants, with finite-size effects being captured in values of a and b. To determine these constants, we first computeÎ N (m; m + 1) for the entire data set. By splitting the data set into two chunks of size N/2, we may estimateÎ N/2 (m; m + 1) by averaging the naive estimate from both chunks. Repeating this procedure for four chunks of size N/4 gives us a system of three equations linear in the unknowns I (m; m + 1), a, and b. From this procedure, we compute an unbiased estimate of the mutual information in the bits we generate when taking on-quasar data as well as data taken when pointing at the sky slightly off-target. We compute I (m; m + 1) for m = 1,2, . . . 6 look-back bits on our data sets of sufficient length N > 2 16 to run. To determine whether our estimates are consistent with zero mutual information, we compare our estimates of I N (m; m + 1) against fifty simulated data sets, each with the same length and the same red-blue imbalance but with no mutual information. Examples of a quasar bitstream with almost no mutual information (PG 1718+481) and a quasar FIG. 12. We plot for two different quasars our estimate of the mutual information between a bit and the m bits preceding it, for m = 1, . . . ,6, for bitstreams generated when the quasar light is both present (circles) and absent (crosses). To test the hypothesis that the mutual information in our on-target data is consistent with zero, we analyze the mutual information of 50 pseudorandom bitstreams with the same length and red-blue bias as our astronomical bitstreams. The statistical distributions of the mutual information in the simulated bitstreams are shown for simulated on-target data (shaded, purple fill) and simulated off-target noise (dotted lines). For the quasar PG1718+481, we find that the experimentally observed mutual information in the on-target as well as the off-target data is consistent with zero, while the mutual-information deviates significantly from zero when observing the exceptionally bright quasar 3C 273 (≈2500 cps). In both cases, data taken off target never exceeds 200 cps. This illustrates how increased bit rates lead to slightly increased statistical predictability, as discussed in the text. bitstream with nonzero mutual information (3C 273) are shown in Fig. 12.
For the quasars in Table I, we observe that the random bits generated from colors in 8 out of 12 data sets exhibit mutual information that is statistically significantly different from zero, though still very small. This hints at the possibility of some nontrivial structure in the data, which may be induced by physical effects or systematic error. For the exceptionally bright quasar 3C 273 (V = 12.9), we measure I ≈ 0.009, while in the remaining 11 data sets, the maximum mutual information I = max m I (m; m + 1) never exceeds 0.001. One way to realize a mutual information of 0.001 is to have one in every 1000 bits be a deterministic function of the previous few bits instead of being random. Even in the worst case of 0.009, the amount of predictability is only increased negligibly compared to the effect from sky glow, and is well below the threshold needed to address the freedom-of-choice loophole in a Bell test. For example, in the recent cosmic Bell experiment [1], violations of the Bell-CHSH inequality were found with high statistical significance (>7 standard deviations) for an experiment involving ∼10 5 detected pairs of entangled photons, even with excess predictability in each arm of each detector of order p (i) ∼ 0.1.
Upon examining the experimental probability estimateŝ p(x,y) that went into the mutual information calculation, we identified two systematic sources of nonrandomness, both of which are exacerbated at high bit rates. The first mechanism for nonrandomness is detector saturation. After a detection, the detector has a hard-coded 420 ns dead-time window during which a detection is improbable. Hence for sufficiently high count rates (such as those experienced when observing stars), it is much more likely to observe a blue photon following a red one and vice versa than multiple photons of the same color in a row. While we see this effect in our calibration data with HIPPARCOS stars, the count rates necessary for this effect to be important (10 5 -10 6 counts per second) far exceed what is observed with quasars. These are eliminated by imposing the same dead-time window in the other channel and removing (in real time or in postprocessing) any detection that is within the dead time of any previous detection from either channel.
The second mechanism is a consequence of imperfect alignment combined with random atmospheric seeing. The exact extent of a slight geometric misalignment is extremely difficult to measure and changes slightly day to day. We checked the optical alignment before each night of observation, and the device's alignment remained quite stable from night to night for over a week -a practical boon for a cosmic Bell test. However, due to our device's imperfectly manufactured pinhole, we know there exists a sweet spot for optimal coupling to the blue detector, and a slightly different sweet spot for optimal alignment with the red detector. As the image of the quasar twinkles within the pinhole on timescales of milliseconds, its instantaneous scintillation pattern overlaps differently with these sweet spots. The result is that when photon fluxes increase to rates approaching one per millisecond (∼1000 cps), the conditional probability p(x → y) of receiving detection y given previous detections x begins to exceed the average probability of obtaining y if the last few bits in x are the same as y. For example, for quasar 3C273 we see p(10111 → 1) = p(101111)/p(10111) = 0.751 > p(1) = 0.726. We suspect that this effect is responsible for the nonzero statistical predictability in our data and leads to an increased predictability of a few parts in 10 4 for high count rates.
Since atmospheric seeing is a consequence of random atmospheric turbulence, it is a potential source of local influences on astronomical randomness. It can be mitigated by careful characterization of the optical alignment of the system, making sure that the sweet spots of both detector arms overlap to the greatest extent possible, using detectors with a large, identical active detector area, and observing under calm atmospheric conditions. For a larger telescope in a darker location where the signal-to-background ratio is higher, this would be a relatively larger effect on the fraction of valid runs.

IX. CONCLUSION
Building on the design and implementation of astronomical random number generators in the recent cosmic Bell experiment [1], we have demonstrated the capabilities of a telescope instrument that can output a time-tagged bitstream of random bits based on the detection of single photons from astronomical sources with tens of nanoseconds of latency. We have further demonstrated its feasibility as a source of random settings for such applications as testing foundational questions in quantum mechanics, including asymptotically closing the freedom-of-choice loophole in tests of Bell's inequality, and conducting a cosmic-scale delayed-choice quantum-eraser experiment. Beyond such foundational tests, astronomical sources of random numbers could also be of significant use in quantum-cryptographic applications akin to those described in Refs. [5,[28][29][30][31][32][33].
Other interesting applications of this device may be found in high-time-resolution astrophysics. For example, it might be possible to indirectly detect gravitational waves and thereby perform tests of general relativity with the careful observation of several optical pulsars using future versions of our instrument and larger telescopes, complementing approaches described in Refs. [62][63][64][65][66].