WorksPhysics and Astronomy
Study of Randomness in Quantum Random Number Generator using Bayesian Neural Networks
Abstract
We propose a Bayesian neural network (BNN) framework to quantify the intrinsic (aleatoric) uncertainty in a continuous-variable quantum random number generator (CV-QRNG). This provides a direct data-driven measure of the QRNG's randomness generation. The BNN is trained on raw homodyne voltage time-series data from a fiber-coupled vacuum-fluctuation QRNG (VFQRNG). For each voltage data segment, the network predicts a Gaussian distribution (mean and variance) for the next sample, and the ensemble-averaged predicted variance is used as a diagnostic of entropy-related behavior under assumptions of our quantum source model. Thus, the predicted variance serves as a BNN model-based monitor of the randomness-generation process. We validate that the BNN metric increases with the local-oscillator (LO) power, consistent with theoretical min-entropy (extractable randomness). We also show the metric is sensitive to practical imperfections, coarse-graining (simulating limited analog-to-digital converter (ADC) sampling) or reducing ADC bit depth causes a clear drop in predicted aleatoric uncertainty, consistent with the source min-entropic model. These results establish the BNN-based metric as a complementary, physically motivated diagnostic tool for QRNG characterization. Unlike conventional tests (e.g. autocorrelation) that miss hardware issues like low ADC resolution, our method provides a direct real-time monitor of the VFRNG performance. Therefore, this metric is useful for real-time monitoring of CV-QRNG conditions, including drifts and other imperfections.
INTRODUCTION
Random numbers are essential in science, cryptography, and simulations [1]. Based on deterministic techniques, pseudo-RNGs [2] are commonly used to generate random numbers [3]. Nevertheless, given sufficient computational resources, their output can be shown to exhibit intrinsic periodicity, as it depends only on the original seed and the particular method used. For applications like cryptography, where predictability undermines security, intrinsic randomness is essential.
QRNGs exploit intrinsic quantum randomness [4, 5]. Most single-photon-detection-based QRNGs have been limited to a comparatively low random number sampling rate due to low detector count rates ( MHz) [6, 7, 8]. Significantly higher rates are achieved by homodyne measurement [9] of vacuum quadratures [10]. This uses coherent detection using balanced homodyne photodetectors, eliminating the dead-time bottleneck of single-photon detection [11, 12, 13]. In addition, Toeplitz randomness extractor implementations on FPGAs can output random bits at Gb/s [14]. Thus, these high-speed systems require robust methods to characterize randomness directly on the analog signal.
QRNG security improves under source-device-independent (SI) assumptions [15, 16]. Recently, large-scale SI-QRNGs on silicon photonic chips now reach 20–200 Gb/s [17, 18]. We have also implemented a fiber-coupled SI-QRNG [19]. This ensures security even with an untrusted source. However, measurement devices can remain vulnerable to security threats. Measurement-device-independent (MDI) QRNG schemes aim to eliminate all possible manipulation on the measurement apparatus by leveraging entanglement/Bell inequality violations [20, 21]. However, such MDI QRNGs are single-photon-based with significant technical complexity due to entanglement generation, synchronization, and low detector count rates. While SI is achieved in CV-QRNGs, MDI for homodyne systems is still unproven. For entanglement-based QRNGs, public-testing schemes have been proposed in which one of multipartite entanglement-coupled bitstreams is disclosed for verification while the remaining streams are kept secret [22, 23]. Although this enables extensive testing of long-range patterns, it relies on a dedicated multipartite entanglement architecture and is not directly transferable to a CV-QRNG. For CV-SI-QRNGs, a power spectral density (PSD)-based conditional-variance framework was recently proposed to account for detector-bandwidth-induced temporal correlations and derive a lower bound on min-entropy against quantum side information [24].
In homodyne CV-QRNGs, extractable randomness depends on the detection system parameters. Specifically, the vacuum quadrature variance (and theoretical min-entropy) increases with LO power until detectors saturate [11, 13, 25]. Consequently, scanning LO power calibrates the quantum-to-classical noise ratio: higher LO power amplifies vacuum noise over detector classical noise, usually increasing extractable entropy [19, 26, 27, 28]. From a security perspective, altering the LO or injecting signals can bias measurements and reduce true randomness, as shown experimentally [29, 30, 31].
Studies show that although entropy bounds depend on LO power, simple diagnostics (variance or autocorrelation function (ACF)) are insensitive to those changes once detector bandwidth effects are considered [26, 32, 33]. Detector nonidealities (finite bandwidth) and ADC effects (finite range, quantization) can greatly reduce min-entropy without showing up as long-range correlations in ACF tests [26, 27, 28]. For instance, modeling ADC discretization and bandwidth shows that undersampling or coarse quantization suppresses high-frequency fluctuations, causing significant underestimation of min-entropy if ignored [26, 27, 28]. Thus, despite LO sweeps being useful, a diagnostic gap remains: conventional metrics (variance, ACF) struggle to detect randomness degradation in the raw signal, motivating more sensitive data-driven analysis.
Neural networks have become powerful tools for quantum analysis [34], including QRNGs [35, 36]. Typically, machine learning techniques are employed to evaluate the randomness of bit streams after classical post-processing and randomness extraction [35, 36], and these works found predictions fail when quantum noise dominates, confirming the QRNG’s robustness. However, these methods rely on reference distributions and do not directly quantify the raw signal’s behaviour. Moreover, these methods operate on post-processed bit streams, where classical extraction and digitization effects may obscure the underlying quantum source behavior.
Unlike device-independent protocols [20, 21, 37, 38, 39], CV protocols rely on trusted physical models to estimate extractable min-entropy [11, 13, 19, 25, 26, 27, 28]. However, unmodelled correlations or drifts can compromise randomness. We propose a complementary, data-driven monitor (a min-entropy model-free diagnostic) using a BNN framework to characterize the randomness generation process in a CV homodyne QRNG from its raw analog voltage output. Unlike prior studies on post-processed bits [35, 36, 40], our approach operates directly on the homodyne output and provides a data-driven assessment of the fluctuations contributing to the randomness-generation process, while remaining sensitive to detector noise and practical imperfections. We validate this on a fiber-coupled vacuum-homodyne QRNG, showing the BNN uncertainty metric behaves as expected with changing parameters.
We train an ensemble of BNNs on segments of the homodyne output voltage, where each network is tasked with predicting the next voltage sample in a segment and outputs both a mean and a variance. The mean captures predictable structure, while the predicted variance represents the BNN model-inferred uncertainty (aleatoric uncertainty). As LO power increases (increasing vacuum variance over classical noise ) [11, 13, 25], we observe the average predicted uncertainty rises accordingly, mirroring the expected increase in min-entropy . Finally, we show the method is sensitive to ADC imperfections [26, 27, 28], such as reduced resolution (using coarse-graining ) and limited sampling rate , highlighting its use as a real-time monitor of QRNG performance. We emphasize that this is a complementary diagnostic, not a replacement for formal entropy certification with adversarial considerations, which require explicit assumptions about the source model, adversarial side information, and detector characterization. It does not guarantee unconditional security against adversarial side-information.
The remainder of the paper is organized as follows. Sec. II describes the fiber-coupled homodyne-based CV-QRNG which measures the vacuum-state quadrature fluctuations. Sec. III A and the subsequent Secs. III B, III C present the evaluation of the proposed BNN uncertainty metric under the considered operating LO power and realistic ADC conditions, respectively with the corresponding comparisons to conventional ACF analysis. The main findings, scope, limitations, and implications of the approach are discussed in Sec. IV. Supplement A provides the detailed data-preparation and BNN motivation along with methodology, including time-series voltage data segmentation, normalization, input-output construction, network architecture, discussions on variational inference and predicted aleatoric variance . Supplement B gives the mathematical definitions used for the ACF and for modeling ADC finite sampling and quantization. Supplement C reports NIST SP 800-22 statistical test of the generated random bit data from the VFQRNG.
EXPERIMENTAL SETUP
Our experimental configuration consists of a completely fiber-coupled assembly for the randomness generation. As shown in Figure 1, the interference of vacuum state () with a strong LO () (TeraXion PS-NLL-1550) at a 50:50 beam splitter (50:50 BS), yields two outputs and . Calibrated photodetectors measure each output and subtract their currents (). The AC component of is the vacuum-fluctuation signal. This signal is amplified, monitored, and digitized by a FPGA ADC. The balanced detector used is a Thorlabs PDB480C-AC (1.6 GHz)

Figure 1. Schematic diagram of the experimental setup used.
The homodyne output voltage is . The sampled raw data of this voltage consists of the vacuum signal and has a normal distribution with variance . However, classical noise from the detectors invariably taints the raw output of voltage. This classical side-information-independent randomness conditioned on this classical noise can be measured by min-entropy [13, 14]
depending on vacuum signal variance and quantization error of the 14-bit ADC implemented. This shows that random bits can be obtained by utilising of the raw voltage data. Here, the variance of the vacuum signal
can be obtained from the total variance , and the variance is from the sampled raw voltage data, which exhibits a non-zero value when the laser is turned off. This non-zero is ascribed to classical noise arising from electromagnetic disturbances, temperature fluctuations, and intrinsic imperfections within the experimental configuration. ADC quantization error is influenced by the dynamic voltage range V, and the sampling precision is of the ADC used.
The optimal performance for achieving maximum randomness, as measured by , is achieved by adjusting the laser’s power. The variance of the voltage measured at homodyne detectors increases linearly with laser power, ranging from 0 mW to 9 mW. Saturation is attained at a laser power of 9 mW, as can be seen in the corresponding in Figure 2. This implies a maximum of 8.89 random bits can be extracted from of the raw voltage data at 9 mW.
Figure 2. vs LO power. The obtained from variance of quantum signal in sampled raw voltage data.
Bayesian Neural network RESULTS
Analysis of Laser Power Variation
Raw homodyne voltage data acquired at LO powers of 1–9 mW were used to compute the BNN aleatoric variance (BNN evaluation described in Supplement A). As described in Sec. I, LO-power variation provides a controlled operating parameter for the homodyne QRNG [26, 27, 28]; here, we examine its effect on the neural-network uncertainty metric . As shown in Figure 3 (a) (the values) and in Table I (the mean and standard deviation ), the ensemble-averaged uncertainty generally increases and its standard deviation shows variability with increasing LO power, although the trend is not strictly monotonic at every power level. This qualitative trend is consistent with the increase in source-model with increasing LO power shown in Figure 2. The observed increase in BNN metric is qualitatively consistent with the expectation that increasing LO power increases the vacuum-noise contribution relative to classical detector noise, thereby increasing QCNR and the source-model (or extractable randomness) [13, 28]. However, this comparison does not imply that itself is an estimator or bound for .
| LO Power (mW) | ||
| 0 | ||
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | ||
| 9 |
Table I. Mean aleatoric uncertainty () and its standard deviation () at different LO power levels.

Figure 3. (a) Aleatoric Uncertainty vs Laser power level in mW (The black dashed line indicates the mean ). (b) Autocorrelation of voltage data from homodyne detections at different laser powers.
We compare the BNN metric with the ACF (mathematical description given in Supplement B) [32, 33] and plot the ACF of the voltage signal for different LO power levels in Figure 3 (b). As observed, the function decays rapidly to zero, though initial damped oscillations (ringing) are visible at low lags (). The low-lag ringing is consistent with the finite bandwidth of the implemented 1.6-GHz homodyne detector. At larger lags, no appreciable LO power-dependent difference is observed within the analyzed range. Thus, the ACF does not reveal a corresponding LO power-dependent change in second-order linear correlation within the analyzed lag range. In contrast, the BNN uncertainty metric shows a LO power-dependent change that is not evident in the ACF. These results indicate that the BNN provides a complementary diagnostic of LO power operating-condition-dependent changes in the measured voltage process that are not resolved by the ACF alone [26, 27, 28].
Studying imperfect sampling effects of ADC
We use coarse-graining (block-averaging) to emulate reduced effective sampling in the homodyne data, following the existing approaches used to study finite-sampling effects in CV-QRNGs [26, 27, 28]. The impact of imperfect ADC sampling has been previously investigated in the context of pulsed lasers [27], where it was observed that increasing the sampling frequency leads to a higher value of . In our work, we aim to study analogous effects in a continuous-wave laser setup. Reduced effective sampling can suppress high-frequency components of the measured voltage fluctuations. We therefore apply block averaging at retention fractions on the homodyne voltage data (mathematical procedure described in Supplement B).
The non-overlapping block average acts as a rectangular averaging filter followed by decimation. Previous CW homodyne and security analyses have used analogous decimation or filtering procedures to model finite analog bandwidth and bound correlations when estimating [26, 28]. This transformation effectively simulates the loss of high-frequency voltage fluctuations due to the ADC’s finite sampling bandwidth. A larger coarse-graining percentage retains more data, corresponding to a higher effective sampling frequency of the ADC.
| Coarse-graining () | ||
| 10 | ||
| 30 | ||
| 50 | ||
| 70 | ||
| 80 |
Table 2. Mean Aleatoric uncertainty () and its standard deviation () at different coarse-graining percentage.
After training the neural network on the coarse-grained data subsets, we observe that increasing the coarse-graining percentage leads to a corresponding increase in the ensemble-averaged uncertainty and its standard deviation characterizes the variability, as shown in Table II and Figure 4 (a) (the values). The BNN uncertainty is sensitive to changes introduced by the effective sampling procedure and is in qualitative agreement with previous CV-QRNG analyses showing that source-model entropy estimates are sensitive to finite sampling [27]. This highlights the importance of accounting for finite-sampling effects in entropy estimation and randomness-extractor design [26, 27, 28].
Figure 4. (a) Aleatoric Uncertainty vs Coarse Graining Percentages (The black dashed line indicates the mean ). (b) Autocorrelation of coarse-grained data.
We also computed the ACF for the coarse-grained datasets. As shown in Figure 4 (b), the autocorrelation rapidly decays toward zero across all coarse-graining percentages. The ACF shows only short-lag differences and no clear change in second-order linear correlation over the analyzed lag range; however, this result does not exclude higher-order or longer-range dependencies. In contrast, the BNN metric changes systematically with the effective sampling rate, providing a complementary diagnostic. Here, we investigate analogous effects in a continuous-wave laser setup.
Studying imperfect precision effects of ADC
Uniform quantization of the observed voltage into an -bit dynamic range is used in CV-QRNG entropy analyses to quantify the effect of finite ADC range and precision on extractable min-entropy [13, 26, 28]. The impact of finite ADC precision has also been investigated for pulsed-laser CV-QRNG, where increasing the bit depth increases , with diminishing gains at higher precision [27]. Here, we investigate analogous effects in a continuous-wave laser setup.
The quantized voltage data (mathematical procedure described in Supplement B) is then processed by the BNN ensemble to obtain the aleatoric uncertainty . As shown in Figure 5 (a) and Table III, we observe an increase in the ensemble averaged () and consecutively variability in as the precision increases from 8 to 12 bits and changes only marginally between 12 and 16 bits. This behavior is qualitatively consistent with diminishing influence of ADC precision at [27]. Previous studies likewise show diminishing gains in at higher ADC precision [13, 27, 28]. Thus, the BNN metric is sensitive to changes in the effective resolution of the measurement apparatus, while this result should not be interpreted as a direct measurement of extractable randomness.
Figure 5. (a) Aleatoric Uncertainty vs ADC sampling precision (The black dashed line indicates the mean ). (b) Autocorrelation of voltage data reconstructed at different ADC bit depths.
| ADC Precision (bits) | ||
| 8 | ||
| 12 | ||
| 14 | ||
| 16 |
Table III. Mean Aleatoric uncertainty () and its standard deviation () at different ADC sampling precisions.
To examine whether ACF could detect these quantization effects, we again computed the ACFs of signals reconstructed at varying bit depths. As illustrated in Figure 5 (b), the ACF rapidly decays toward zero for all precision levels, showing no discernible difference between the 8-bit and 16-bit reconstructions. This indicates that the simulated quantization changes are not reflected in the second-order temporal correlation measured by the ACF. In contrast, the change in () between 8 and 12 bits (Table III) shows that the BNN is sensitive to changes in the quantized signal that are not apparent in the ACF.
Summary and Discussion
We introduced a finite ensemble-BNN framework for monitoring changes in predictive uncertainty from raw analog voltage data for a homodyne-based CV-QRNG. Under the experimental conditions considered, the BNN predicted uncertainty metric changes systematically with LO power, effective sampling, and ADC precision. The LO-power behavior is qualitatively consistent with the expected increase of vacuum-noise contribution relative to classical detector noise and with the corresponding source-model extractable randomness trend. The ADC sampling and precision studies further show that the BNN metric is sensitive to measurement conditions that are not clearly reflected in the autocorrelation function ACF [26, 32, 33].
The BNN uncertainty metric is a BNN model-relative diagnostic and must not be interpreted as an information-theoretic measure of conditional min-entropy or as a proof of quantum unpredictability. In particular, the predictive performance of a finite ensemble BNN does not establish that a more powerful predictor or an adversary with additional classical or quantum side information could not obtain more information about the output. The source-model is conditional on the assumed source, detector-noise, and ADC models [11, 13, 26, 27, 28] and should therefore be distinguished from an adversarial conditional min-entropy bound [41]. The BNN metric is consequently intended to complement, rather than replace such physics-based entropy estimation and security-certification methods [42].
Standard NIST SP 800-22 testing provides an additional statistical assessment of the bit stream generated by the VFQRG (Supplement C). The 1 GB bit stream passed all 15 statistical tests, with the corresponding -values exceeding the significance threshold . However, passing such tests is not a proof of quantum randomness or information-theoretic security. More exhaustive non-IID, and quantum side-information analyses [43, 44] would be required for a complete security assessment of higher-order, cross-segment, or longer-range dependencies [22, 23].
Looking ahead, this neural-network uncertainty analysis could serve as a real-time monitoring layer in practical QRNGs. For instance, the BNN could be implemented on an FPGA for low-latency online monitoring [45]. A key advantage of the proposed approach is that it operates directly on the measured analog voltage and can provide an operatingcondition-sensitive diagnostic without relying solely on conventional second-order correlation measures.
Code availability
The code used for training and evaluating the neural networks is publicly available on GitHub [46].
References
Supplement A: Bayesian Neural network to study randomness in raw voltage data
Data Preparation for Timeseries Analysis
The raw voltage time series recorded from the homodyne detector contains approximately samples. To ensure computational tractability while maintaining statistical representativeness, the data are analyzed in disjoint subsets. Specifically, each experimental run processes a contiguous segment of voltage samples, and multiple such segments are analyzed independently to assess reproducibility. The measured homodyne-voltage distribution is approximately Gaussian over the operating conditions considered and contains contributions from vacuum fluctuations and classical detector/electronic noise.
Let be the number of data points in the dataset and be the size of the lookback window. Each data segment is standardized prior to training by subtracting its empirical mean and dividing by its empirical standard deviation (zero-mean, unit-variance normalization). We adopt this z-score normalization because it stabilizes training and makes the network’s predicted variance independent of the chunk-specific scale during optimization. Normalization is essential for machine learning models because it ensures that all features contribute equally to the training process; without it, features with larger ranges could dominate the model, leading to biased results.
Given the time-series nature of the data, the raw dataset is then segmented into overlapping input-output pairs suitable for neural network training. This is achieved using a sliding window approach: each input consists of a sequence of consecutive, normalized data points , and the corresponding output is the next data point that immediately follows this window in the sequence, for . This method allows the neural network to learn temporal dependencies by mapping recent history to the subsequent value, which is a standard approach in time series forecasting using neural networks:
where is the total number of normalized data points and for a given look-back window size , the input-output pairs are created as follows:
This process is repeated for the entire dataset for training and the dataset would be like the following:
The resulting dataset is split into training and test sets using an 80:20 ratio. The look-back window determines the amount of temporal context provided to the BNN for predicting the next voltage sample. To select an appropriate window size, we considered five values, , and evaluated the corresponding BNN output aleatoric uncertainty ( defined in next Sec.) for voltage data of LO power 9 mW (based on discussion in Sec. II). The rationale for selecting is presented at the end of this supplement.
Bayesian Approach to Uncertainty Quantification in CV-QRNGs
Initially, we employed a deep neural network (DNN) approach to predict from (Eq. (2)) and utilized the standard deviation of the Mean Squared Error (MSE) across the ensemble of DNNs as our measure of randomness. Typically, MSE evaluates the neural network’s performance for regression tasks, which measures the average of the squared differences between predicted and actual values given by
where is the actual value and is the predicted value for predictions. We observed that this ensemble-based metric lacked reproducibility; due to the stochastic nature of weight initialization and optimization in standard deep learning, the MSE variance fluctuated significantly across different training runs on identical datasets. Furthermore, deterministic networks like DNN conflate epistemic uncertainty (uncertainty in model parameters) with aleatoric uncertainty (noise inherent in input dataset) [47]. For a QRNG, only the latter might represent the entropic model-inferred uncertainty of the vacuum fluctuations. Consequently, we transition to a BNN framework here. By placing probability distributions over the network weights, the BNN allows us to mathematically decompose the total predictive variance and isolate the aleatoric uncertainty. This provides a stable, reproducible, and physically interpretable metric for the CV-QRNG, independent of the stochastic variations inherent in the neural network model training process.
Bayesian Neural Network Architecture
The BNN employed is a multi-layer perceptron (MLP) designed to operate on the voltage time-series data. Unlike traditional MLPs that learn fixed weight values, this architecture treats weights and biases as random variables and learns their probability distributions. The network receives a univariate input sequence of length in each instance, a segment of the time-series data (as discussed in Eq. (2)). This input feeds into a series of fully connected (dense) layers that progressively reduce in width. We have used a network with 2 hidden layers, 128 units to 64 units, and finally to an output layer with 2 units, as seen in Fig. ??. Rectified Linear Unit (ReLU) activation functions are applied after the hidden layers to introduce non-linearity. The output layer is configured to produce two values: the predicted mean and the log-variance of a Gaussian distribution. The log-variance is constrained within a stable range to ensure numerical robustness. The standard deviation is then derived from this log-variance.
Further, variational inference (VI) is used [48, 49], which is an optimization technique that approximates the intractable true posterior distribution of the network’s weights by iteratively updating the parameters of a simpler, tractable variational distribution (the ”guide”). An automated method is used to construct the variational posterior. This typically involves assuming a simple form for the posterior, such as a diagonal Gaussian distribution for each weight and bias. This means that for each parameter in the network, the guide learns a mean and a standard deviation, effectively approximating each parameter’s posterior distribution as a Gaussian. An optimizer, such as Adam, is employed to update the variational parameters of the guide. The training process involves repeatedly sampling weights from the current guide, computing the Evidence Lower Bound (ELBO) loss, and then adjusting the variational parameters to maximize this ELBO. This iterative process refines the guide to better approximate the true posterior.
Once the BNN is trained, the learned guide provides an approximation of the posterior distribution over the weights. To make predictions and quantify uncertainties, it is necessary to sample from this learned posterior. Multiple sets of network weights are sampled from the trained guide. For each sampled set of weights, the network’s forward pass is executed using the input data. This yields a set of predictions, including the predicted mean and, crucially, the predicted standard deviation for each input. The predicted standard deviations obtained from these multiple samples are then rescaled back to the original data units. The aleatoric uncertainty for each input is estimated by calculating the mean of the squared predicted standard deviations across all Monte Carlo samples. This average variance captures the inherent noise in the data that the model accounts for. Finally, an overall measure of aleatoric uncertainty is obtained by averaging these individual estimates across all test data points.
This comprehensive approach allows the BNN to generate predictions while providing an estimate of the predictive uncertainty associated with them. The predicted variance representing the BNN model-inferred aleatoric component. Because the homodyne voltage data contain contributions from quantum vacuum fluctuations as well as classical electronic noise, our objective is not to improve point-prediction performance but to characterize the uncertainty associated with predicting the measured signal. Therefore, we focus on the model’s predicted variance and use it in this work as the diagnostic metric.
Bayesian Neural Networks and Aleatoric Uncertainty Estimation
Given a dataset such as in Eq. (2), the BNN aims to learn the posterior distribution over its network weights . According to Bayes’ rule, this posterior is given by [48, 49]:
where
is the likelihood of the data given the weights. For regression task like ours, this is often modeled as a Gaussian likelihood, (normal distribution of ), where and (their parameters) are predicted by the neural network from the input .
is the prior distribution over the weights , reflecting our initial beliefs about the weights before observing any data.
is the evidence, a normalizing constant defined as .
In BNNs, the true posterior distribution over the network’s weights is often analytically intractable to compute. As mentioned, VI is employed to overcome this. VI seeks to approximate the true posterior with a simpler, more tractable distribution , known as the variational posterior or guide. Here, represents the variational parameters that define this approximating distribution [50]. The objective of VI is to minimize the Kullback-Leibler (KL) divergence between the variational posterior and the true posterior . However, directly minimizing this KL divergence is also intractable because it requires computing the evidence . Instead, VI focuses on maximizing a lower bound on the marginal likelihood , which is known as the ELBO.
Further, in our setting, the BNN is designed to output both the mean () and the variance () of a Gaussian distribution for each prediction. The aleatoric uncertainty is then directly captured by this predicted variance. To estimate the total aleatoric uncertainty , we find the expectation of the predicted variance over the posterior distribution of the weights [49]:
where
is the number of Monte Carlo samples, which was found to be sufficient to stabilise the estimate of , while maintaining computational efficiency.
is the predicted variance for the sampled set of weights of test sample.
Post-training, the variational parameters defining the approximate posterior are fixed. To compute for a specific input sequence , we perform stochastic forward passes (Monte Carlo sampling). In each pass , a distinct set of weights is sampled from the learned distribution . The network processes the same input using these sampled weights to output a predicted variance . This procedure effectively integrates over the uncertainty in the model weights.
Model Evaluation process
As described in the previous section, aleatoric uncertainty () from Eq. (4) evaluates the neural network’s performance. The voltage stream acquired from the balanced homodyne detector is partitioned into 50 mutually exclusive subsets. Each subset is delivered to a dedicated BNN member of an ensemble , and every network is trained independently. After convergence, the aleatoric uncertainty recorded for the model is collected as . We then compute the mean as
standard deviation as
and treat these as an empirical indicator and diagnostic metric. Since the aleatoric uncertainty serves as a quantitative measure of how well each model within the ensemble learns the data, examining the standard deviation of values across all models provides valuable insight into the consistency of the ensemble’s predictions, similar to MSE from Eq. (3) (For DNN). A high mean and variability of standard deviation of indicates that there is substantial variability in the from one model to another. This variability suggests that the models
are not consistently able to learn or generalize patterns from the data, and may, in effect, be resorting to random guessing in their predictions. If the standard deviation is low, it implies that the models are performing similarly, potentially indicating that the data contains learnable, deterministic structure. Conversely, a high standard deviation points to the presence of randomness that the models are unable to capture, reflecting the stochastic nature of the dataset.
Sensitivity to look-back window size L
To investigate the influence of temporal context on the proposed aleatoric uncertainty metric , we evaluated five look-back window sizes, . The resulting ensemble mean and standard deviation of the predicted aleatoric uncertainty are summarized in Table IV and their values are shown in Figure 7.

Figure 7. Aleatoric Uncertainty vs Look-back window (The black dashed line indicates the mean ).
The mean aleatoric uncertainty and its standard deviation both increase as the look-back window increases from to , reaching their highest observed values at . For , both quantities decrease. Thus, yields the highest observed mean aleatoric uncertainty and the largest standard deviation . These results indicate that increasing the look-back window does not necessarily lead to a higher value of the proposed uncertainty metric . We therefore selected for the subsequent analyses because it yields the highest observed mean aleatoric uncertainty among the tested, while avoiding the additional computational burden associated with the larger windows. The comparatively large standard deviation at also indicates substantial variability.
| Look-back () | ||
| 10 | ||
| 50 | ||
| 100 | ||
| 200 | ||
| 500 |
Table IV. Mean aleatoric uncertainty () and its standard deviation () at different Look-back values ().
Supplement B: Modeling of autocorrelation function (ACF), imperfect sampling effects of ADC and imperfect precision effects of ADC
ACF Modeling
The ACF quantifies the linear dependence between the signal and a time-shifted version of itself; we compute it as following:
The global arithmetic mean of the original voltage sequence is computed to center the data:
For a specific time lag , the normalized ACF is obtained by dividing the autocovariance at lag by the variance (autocovariance at lag 0). This normalizes the result to the range :
Given that the voltage data was recorded using an oscilloscope with a sampling rate of 40 GHz, the temporal resolution (time step) between data points is s ps. Consequently, in our analysis we calculate the autocorrelation up to a lag of , this corresponds to a total physical time delay of ps s.
Mathematical modeling of imperfect sampling effects of ADC
Mathematically, we model imperfect sampling effects of ADC as a discrete block-averaging operation defined by the following steps:
Let the original digitized voltage time-series be denoted by
where is the total number of raw data points.
For a defined retention percentage , the target number of samples () is calculated as the nearest integer:
This imposes an effective sampling window () determined by integer division:
The coarse-grained voltage sequence is constructed by averaging the original signal over non-overlapping, contiguous windows of size . The -th downsampled value is given by:
Mathematical modeling of imperfect precision effects of ADC
To simulate imperfect precision effects of ADC, we apply uniform quantization to the raw voltage time series. This process maps a continuous-valued voltage signal to a discrete set of approximation levels defined by the simulated ADC’s precision, similar to the previous section.
Let and denote the global minimum and maximum values of the acquired voltage signal . For a simulated -bit ADC, the dynamic range is partitioned into discrete quantization intervals.
The uniform quantization step size, or bin width , is defined as:
Each instantaneous voltage sample is mapped to a discrete bin index . Since the signal is bounded by , the index is determined by the floor function, constrained by the upper limit :
To maintain a continuous domain representation suitable for the BNN, the signal is reconstructed into by mapping each index to the geometric midpoint of its corresponding interval:
SUPPLEMENT C: National Institute of Standards and Technology statistical tests

Figure 8. P-values obtained from the statistical tests of the NIST (National Institute of Standards and Technology) test suite are presented. According to the NIST SP 800-22 criteria, a test is considered to pass when the corresponding P-value exceeds the significance threshold of 0.01.
randomness. P-values close to unity indicate strong consistency with random behavior, whereas values approaching zero provide evidence against the null hypothesis. Accordingly, the null hypothesis is accepted when P-value , while a P-value below leads to its rejection. As illustrated in Figure 6, the P-values obtained from all 15 NIST statistical tests remain above the chosen threshold of , demonstrating that the recorded sequence passes the complete set of randomness tests.

Figure 6. Architecture of one Bayesian neural network (BNN) member used for next-sample prediction of the homodyne voltage. The input consists of consecutive voltage samples. Two fully connected hidden layers contain 128 and 64 ReLU units, respectively. The output layer predicts the mean and log-variance of a Gaussian likelihood. Network weights and biases are treated probabilistically using variational inference, which approximates their posterior distribution . The drawing shows representative neurons; the red edges and Gaussian glyphs mark example weights whose values are drawn from learned distributions, and the labels give the full layer dimensions. Every weight and bias is a random variable.
References
- [1]M. Herrero-Collantes and J. C. Garcia-Escartin, Quantum random number generators, Rev. Mod. Phys. 89, 015004 (2017).
- [2]D. E. Knuth, The art of computer programming, volume 2 (3rd ed.): seminumerical algorithms (Addison-Wesley Longman Publishing Co., Inc., USA, 1997).
- [3]W. Hörmann, J. Leydold, and G. Derflinger, Automatic Nonuniform Random Variate Generation, Statistics and Computing (Springer, 2004).DOI
- [4]M. Stipčević, Quantum random number generators and their use in cryptography, in 2011 Proceedings of the 34th International Convention MIPRO (IEEE, 2011) pp. 1474–1479.
- [5]X. Ma, X. Yuan, Z. Cao, B. Qi, and Z. Zhang, Quantum random number generation, npj Quantum Information 2, 16021 (2016).DOI
- [6]T. Uchida, U. Achleitner, G. Weihs, H. Weinfurther, and A. Zeilinger, A fast and compact quantum random number generator, Review of Scientific Instruments 71, 1675 (2000).
- [7]J. F. Dynes, Z. L. Yuan, A. W. Sharpe, and A. J. Shields, A high speed, postprocessing free, quantum random number generator, Applied Physics Letters 93, 031109 (2008).DOI
- [8]M. Wahl, M. Leifgen, M. Berlin, T. Rö hlicke, H.-J. Rahn, and O. Benson, An ultrafast quantum random number generator with provably bounded output bias based on photon arrival time measurements, Applied Physics Letters 98, 171105 (2011).DOI
- [9]M. Collett, R. Loudon, and C. Gardiner, Quantum theory of optical homodyne and heterodyne detection, Journal of Modern Optics 34, 881 (1987), https://doi.org/10.1080/09500348714508511.
- [10]H. P. Yuen and V. W. S. Chan, Noise in homodyne and heterodyne detection, Opt. Lett. 8, 177 (1983).
- [11]C. Gabriel, C. Wittmann, D. Sych, R. Dong, W. Maurer, U. L. Andersen, C. Marquardt, and G. Leuchs, A generator for unique quantum random numbers based on vacuum states, Nature Photonics 4, 711 (2010).
- [12]T. Symul, S. M. Assad, and P. K. Lam, Real time demonstration of high bitrate quantum random number generation with coherent laser light, Applied Physics Letters 98, 231103 (2011).DOI
- [13]J. Y. Haw, S. M. Assad, A. M. Lance, N. H. Y. Ng, V. Sharma, P. K. Lam, and T. Symul, Maximization of extractable randomness in a quantum random-number generator, Phys. Rev. Appl. 3, 054004 (2015).DOI
- [14]Z. Zheng, Y. Zhang, W. Huang, S. Yu, and H. Guo, 6 Gbps real-time optical quantum random number generator based on vacuum fluctuation, Review of Scientific Instruments 90, 043105 (2019).DOI
- [15]D. G. Marangon, G. Vallone, and P. Villoresi, Source-device-independent ultrafast quantum random number generation, Phys. Rev. Lett. 118, 060503 (2017).DOI
- [16]T. Michel, J. Y. Haw, D. G. Marangon, O. Thearle, G. Vallone, P. Villoresi, P. K. Lam, and S. M. Assad, Real-time source-independent quantum random-number generator with squeezed states, Phys. Rev. Appl. 12, 034017 (2019).DOI
- [17]L. Huang and H. Zhou, Integrated gbps quantum random number generator with real-time extraction based on homodyne detection, J. Opt. Soc. Am. B 36, B130 (2019).DOI
- [18]M. Cizauskas, H. Tebyanian, M. Fox, M. Bayer, M. Ab̆mann, and A. Greilich, 33 gbit/s source-device-independent quantum random number generator based on heterodyne detection with real-time fpga-integrated extraction, Quantum Science and Technology (2026).arxiv.org/abs/2512.07319
- [19]M. Shrivastava, M. Mittal, I. Kumari, and V. Abhig-nan, Randomness in quantum random number generator from vacuum fluctuations with source-device-independence, Applied Physics B 131, 111 (2025).DOI
- [20]S. Pironio, A. Acín, S. Massar, A. B. de la Giro-day, D. N. Matsukevich, P. Maunz, S. Olmschenk, D. Hayes, L. Luo, T. A. Manning, and C. Monroe, Random numbers certified by bell’s theorem, Nature 464, 1021 (2010).DOI
- [21]Y.-Q. Nie, J.-Y. Guan, H. Zhou, Q. Zhang, X. Ma, J. Zhang, and J.-W. Pan, Experimental measurement-device-independent quantum random-number generation, Phys. Rev. A 94, 060301 (2016).DOI
- [22]J. E. Jacak, W. A. Jacak, W. A. Donderowicz, and L. Jacak, Quantum random number generators with entanglement for public randomness testing, Scientific Reports 10, 164 (2020).
- [23]P. Jóźwiak, J. E. Jacak, and W. A. Jacak, New concepts and construction of quantum random number generators, Quantum Information Processing 23, 132 (2024).DOI
- [24]H. Zhou, X. Wang, Z. Chen, and S. Yu, Addressing temporal overlap against quantum side information in continuous variable source independent quantum random number generators, Chinese Optics Letters 24, 102703 (2026).
- [25]V. Abhignian, M. Mittal, M. Shrivastava, and A. Mitra, Neural network analysis in detection imperfections of continuous-variable quantum key distribution, in 2024 IEEE International Conference on Advanced Networks and Telecommunications Systems (ANTS) (2024) pp. 411–416.
- [26]J. Zhang, Y. Zhang, Z. Zheng, Z. Chen, B. Xu, and S. Yu, Finite-size analysis of continuous variable source-independent quantum random number generation, Quantum Information Processing 20, 15 (2021).arxiv.org/abs/2002.12767
- [27]Y. Li, Y. Fei, W. Wang, X. Meng, H. Wang, Q. Duan, Y. Han, and Z. Ma, Impact of an imperfect sampling device on the security of a continuous-variable source-independent quantum random-number generator with a phase-randomized local oscillator, Phys. Rev. A 109, 052401 (2024).DOI
- [28]W. Huang, Y. Zhang, Z. Zheng, Y. Li, B. Xu, and S. Yu, Practical security analysis of a continuous-variable quantum random-number generator with a noisy local oscillator, Phys. Rev. A 102, 012422 (2020).DOI
- [29]J. Thewes, C. Lüders, and M. Aßmann, Eavesdropping attack on a trusted continuous-variable quantum random-number generator, Phys. Rev. A 100, 052318 (2019).
- [30]H. Zhou, Z. Zheng, L. Huang, X. Wang, Z. Chen, and S. Yu, Eavesdropping attack on a continuous-variable source-independent quantum random-number generator with fluctuating local oscillator, Journal of Physics B: Atomic, Molecular and Optical Physics 55, 065502 (2022).DOI
- [31]P. Smith, D. Marangon, M. Lucamarini, Z. Yuan, and A. Shields, Out-of-band electromagnetic injection attack on a quantum random number generator, Phys. Rev. Appl. 15, 044044 (2021).DOI
- [32]X. Ma, F. Xu, H. Xu, X. Tan, B. Qi, and H.-K. Lo, Postprocessing for quantum random-number generators: Entropy evaluation and randomness extraction, Phys. Rev. A 87, 062327 (2013).DOI
- [33]M.-S. Kim, I.-W. Tcho, and Y.-K. Choi, Analyses of unpredictable properties of a wind-driven triboelectric random number generator, Scientific Reports 13, 16610 (2023).DOI
- [34]G. Carleo, I. Cirac, K. Cranmer, L. Daudet, M. Schuld, N. Tishby, L. Vogt-Maranto, and L. Zdeborová, Machine learning and the physical sciences, Rev. Mod. Phys. 91, 045002 (2019).DOI
- [35]Y. Feng and L. Hao, Testing randomness using artificial neural network, IEEE Access 8, 163685 (2020).DOI
- [36]J. L. Crespo, J. González-Villa, J. Gutiérrez, and A. Valle, Assessing the quality of random number generators through neural networks, Machine Learning: Science and Technology 5, 025072 (2024).
- [37]G. Vallone, D. G. Marangon, M. Tomasin, and P. Villoresi, Quantum randomness certified by the uncertainty principle, Phys. Rev. A 90, 052327 (2014).DOI
- [38]Y. Liu, X. Yuan, M.-H. Li, W. Zhang, Q. Zhao, J. Zhong, Y. Cao, Y.-H. Li, L.-K. Chen, H. Li, T. Peng, Y.-A. Chen, C.-Z. Peng, S.-C. Shi, Z. Wang, L. You, X. Ma, J. Fan, Q. Zhang, and J.-W. Pan, High-speed device-independent quantum random number generation without a detection loophole, Phys. Rev. Lett. 120, 010503 (2018).
- [39]S. Zhou, Q.-M. Xie, and N.-R. Zhou, Measurement-free mediated semi-quantum key distribution protocol based on single-particle states, Laser Physics Letters 21, 065207 (2024).DOI
- [40]R. Heese, M. Wolter, S. Mücke, L. Franken, and N. Piatkowski, On the effects of biased quantum random numbers on the initialization of artificial neural networks, Machine Learning 113, 1189 (2024).
- [41]R. Wang and H. F. Chau, One-shot min-entropy calculation of classical-quantum states and its application to quantum cryptography, Phys. Rev. Lett. 135, 020801 (2025).DOI
- [42]J. Kelsey, K. A. McKay, and M. Sönmez Turan, Predictive models for min-entropy estimation, in Cryptographic Hardware and Embedded Systems – CHES 2015, edited by T. Güneysu and H. Handschuh (Springer Berlin Heidelberg, Berlin, Heidelberg, 2015) pp. 373–392.DOI
- [43]M. S. Turan, E. Barker, J. Kelsey, K. McKay, M. Baish, and M. Boyle, Recommendation for the Entropy Sources Used for Random Bit Generation, Tech. Rep. NIST SP 800-90B (National Institute of Standards and Technology), 2018).DOI
- [44]J. D. Hart, Y. Terashima, A. Uchida, G. B. Baumgartner, T. E. Murphy, and R. Roy, Recommendations and illustrations for the evaluation of photonic random number generators, APL Photonics 2, 090901 (2017).DOI
- [45]H. Fan, M. Ferianc, M. Rodrigues, H. Zhou, X. Niu, and W. Luk, High-performance fpga-based accelerator for bayesian neural networks, in 2021 58th ACM/IEEE Design Automation Conference (DAC) (2021) pp. 1063–1068.arxiv.org/abs/2105.09163
- [46]Bayesian neural network, (2025).
- [47]S. Depeweg, J. M. Hernández-Lobato, F. Doshi-Velez, and S. Udluft, Uncertainty decomposition in bayesian neural networks with latent variables (2017), arXiv:1706.08495 [stat.ML].arxiv.org/abs/1706.08495
- [48]E. Goan and C. Fookes, Bayesian neural networks: An introduction and survey, in Case Studies in Applied Bayesian Data Science (Springer International Publishing, 2020) pp. 45–87.
- [49]L. R. Chai, Uncertainty estimation in bayesian neural networks and links to interpretability (2018).
- [50]A. Graves, Practical variational inference for neural networks, in Advances in Neural Information Processing Systems, Vol. 24, edited by J. Shawe-Taylor, R. Zemel, P. Bartlett, F. Pereira, and K. Weinberger (Curran Associates, Inc., 2011).


