# Self-testing with finite statistics enabling the certification of a quantum
network link

Jean-Daniel Bancal  Quantum Optics Theory Group, Universität Basel, CH-4056
Basel, Switzerland  Kai Redeker  Fakultät für Physik, Ludwig-Maximilians-
Universität, 80799 München, Germany  Pavel Sekatski  Quantum Optics Theory
Group, Universität Basel, CH-4056 Basel, Switzerland  Wenjamin Rosenfeld
Fakultät für Physik, Ludwig-Maximilians-Universität, 80799 München, Germany
Max-Planck-Institut für Quantenoptik, Hans-Kopfermann-Strasse 1, 85748
Garching, Germany  Nicolas Sangouard  Quantum Optics Theory Group, Universität
Basel, CH-4056 Basel, Switzerland

(7 July 2020)

###### Abstract

Self-testing is a method to certify devices from the result of a Bell test.
Although examples of noise tolerant self-testing are known, it is not clear
how to deal efficiently with a finite number of experimental trials to certify
the average quality of a device without assuming that it behaves identically
at each run. As a result, existing self-testing results with finite statistics
have been limited to guarantee the proper working of a device in just one of
all experimental trials, thereby limiting their practical applicability. We
here derive a method to certify through self-testing that a device produces
states on average close to a Bell state without assumption on the actual state
at each run. Thus the method is free of the I.I.D. (independent and
identically distributed) assumption. Applying this new analysis on the data
from a recent loophole-free Bell experiment, we demonstrate the successful
distribution of Bell states over 398 meters with an average fidelity of
$\geq$55.50% at a confidence level of 99%. Being based on a Bell test free of
detection and locality loopholes, our certification is evidently device-
independent, that is, it does not rely on trust in the devices or knowledge of
how the devices work. This guarantees that our link can be integrated in a
quantum network for performing long-distance quantum communications with
security guarantees that are independent of the details of the actual
implementation.

##  1 Introduction

The distribution of entanglement over long distances is a key challenge in
extending the range of quantum communication and building quantum networks [1,
2]. The direct transmission of entangled states through optical fibers is a
viable solution for short distances but is limited by transmission loss.
Quantum repeaters have thus been proposed for entanglement distribution over
long distances111For protocols that do not rely on entanglement creation in
independent links, but are based exclusively on error correction codes, see
[3]. [4, 5]. The basic idea is to divide the global distance into short
elementary network links. Entanglement is created in each link and successive
entanglement swapping operations are used to combine links and extend
entanglement. The key to efficient quantum repeater is to use elementary links
where i) the successful creation of entanglement is heralded and ii)
entanglement is stored so that it can be created in each link independently.
Impressive progress along this line now allows one to envision multipartite
quantum networks where entanglement is distributed between arbitrary parties.
[6, 7, 8, 9, 10, 11]

At the heart of quantum networks lies the ability to distribute but also
certify an entangled state between two distant locations. Although entangled
states have been produced between remote locations forming an elementary
network link in multiple experiments [12, 13, 14, 15, 16, 17, 18, 19, 20],
their suitability for general purposes including – but not limited to –
quantum key distribution, remains unproven. Demonstrations based on the qubit
assumption for instance, stating that all elements involved are of dimension
two, are subject to side-channels which completely corrupt the security
guarantees [21].

More generally, the identification of a quantum state provides the most
complete description of a system. But the trace left by a state in the
measurement outcomes is as much influenced by the state as by the measurement
itself. Consequently, it is challenging to obtain an accurate description of a
quantum state from observed statistics without presuming a detailed
description of the measurement apparatus. Yet, characterizing univocally a
quantum resource by identifying its quantum state constitutes a crucial step
to set quantum technologies on a solid stand.

The possibility of device-independent state characterization which is not
relying on assumptions on the dimension of the Hilbert space and on the
correct calibration or modelling of the measurements [22] was first realized
in Ref. [23, 24]. There it was noted that the only quantum states able to
achieve a maximum violation of the Bell-CHSH inequality [25], are Bell states
– two-qubit maximally entangled states. Interest in self-testing however only
started growing significantly after Mayers and Yao rediscovered it and showed
that it provides security for quantum key distribution [26, 27]. Since then,
it has been understood that self-testing guarantees the security of many
quantum information tasks, including randomness generation [28, 29, 30] and
delegated quantum computing [31]; see [32] for more details. Therefore, self-
testing a state guarantees its direct applicability for a wide range of
applications. Motivated by this perspective, further theoretical self-testing
results have been obtained lately, addressing an increasing range of states,
and with improving tolerance to noise [33, 34, 35, 36, 37, 38, 30, 39, 40,
41]. Moreover, self-testing has also been extended to the characterization of
quantum measurements and channels [27, 42, 31, 43, 44, 45, 46, 47].

In the case of Bell states, it is now known that self-testing based on the
Bell-CHSH inequality is strongly resistant to noise [34, 36, 37]. Recently,
this led to the experimental estimation of self-testing fidelities from the
perspective of hypothesis testing, in which the null hypothesis to be rejected
is that the source only produces states with a fidelity below a fixed
threshold value [48]. Rejection of this hypothesis then implies that at least
one state produced by the source had a fidelity higher than the threshold
value. However, the implications of hypothesis testing to practical protocols
is not clear since no statement on the average fidelity is provided. As an
example, data from the experiment involving two individual ions separated by
$\approx 1$ m [29] were shown to lead to a significant rejection of the null
hypothesis even though the average Bell violation that could be certified with
the methods presented in [29] at 99% confidence level is lower than $2.05$,
hence precluding a conclusion on the average Bell state fidelity [49]. A
higher Bell violation was demonstrated between two ions separated by about 340
$\mu$m within a trap [48], but this short-distance setting is not directly
applicable for quantum networks. The recent advent [50, 51, 52, 53] of
loophole-free Bell tests [54] involving large separations between entangled
particles opens a new perspective for device-independent certification of
states distributed in quantum networks.

We here derive a method that provides a confidence interval on the _average_
violation of any binary Bell inequality without assuming that the trials are
independent and identically distributed. Applying this method to the CHSH-Bell
test allows us to certify that a source has the capability of producing _on
average_ states close to a Bell state without making any assumption on the
actual state at each trial. This changes the status of self-testing from a
mere theoretical tool to a practical certification technique. We show this by
considering the data used on the loophole-free Bell inequality violation
reported in Ref. [53] where entanglement is distributed in a heralded way and
stored in two single atoms trapped at two locations separated by 398m before a
Bell test is performed. We first optimize the heralding conditions using an
ab-initio model of the entanglement generation process, hence improving on the
entanglement fidelity of the data set in [53]. We then apply our new
statistical tool accounting for finite experimental statistics and
imperfections of the random number generators. From the observed Bell-CHSH
value, we certify the successful distribution over 398 m of an entangled state
with a Bell state fidelity of 55.50% at a confidence level of 99%. This
constitutes the first result where a statistically relevant bound on the
average fidelity of the distributed state is obtained directly from the Bell-
CHSH value and the first device-independent certification of an elementary
link for a quantum network.

##  2 Device-independent assumptions

The scenario we consider involves three protagonists, colloquially referred to
as Alice, Bob and Charlie, see Fig. 1. Charlie holds a preparation device
which indicates when the experiment is ready: it heralds the start of every
measurement procedure. The two other parties each hold one measurement device
and one random number generator device. Upon heralding, the random number
generators are used by Alice and Bob to choose a measurement setting which is
applied to their measurement devices. Measurement settings and outcomes are
recorded locally for later analysis. The claim of self-testing for the state
measured is based on a number of assumptions that we review now.

  1. 1.

The experiment admits a quantum description. Essentially, the state of the
system can be represented in terms of a density operator, and the measurements
as operators acting on the same Hilbert space with the appropriate tensor
structure.

  2. 2.

All devices mentioned above are well identified in space and operate
sequentially in time. In particular, the separation between the parties Alice
and Bob is clear, as well as between the random number generators and the
measurement devices of each party. Moreover, results are recorded before going
to the next round, hence we know exactly when a round is going on (two rounds
don’t happen simultaneously), when it is finished, and we can monitor how many
rounds happened in a given time.

  3. 3.

The random number generators are independent from all other devices and sample
from a well characterized probability distribution. Hence, the measurements
used are chosen freely: the measured particles cannot influence this choice,
nor vice versa. The random number devices can be correlated to each other, but
not to the rest of the setup.

  4. 4.

Finally, the classical and quantum communication between Alice and Bob is
limited: no communication (whether direct or indirect) is allowed between the
measurement boxes once the settings choices are received and until the
measurement outcomes are produced. Moreover, the random number generators only
provide the choice of measurement setting when required, and to their
respective measurement device. (Note that space-like separation can be used to
guarantee the condition of no communication between Alice and Bob.)

Apart from the first assumption, which has not been challenged by any
experiment so far, note that all three remaining assumptions concern the
relation between the various devices involved in the experiment rather than
their internal working. This approach is thus often called “black-box" or
“device-independent". For a physical setup permitting for self-testing these
assumptions are requirements. The settings and requirements for self testing
are sufficient to test a Bell inequality and they have been used recently in
Ref. [53] to perform a loophole-free violation of the Bell-CHSH inequality. We
briefly present this experiment in the next section.

Figure 1: Sketch of self-testing based on violation of Bell’s inequality with
entangled atoms separated by a large distance. Each "device" of Alice and Bob
is an independent apparatus for trapping and manipulating single atoms.
Entanglement between the atoms is generated by entangling the spin of each
atom with polarization of a single photon. The photons are coupled into single
mode fibers and overlapped at a fiber beamsplitter. Coincident detection of
two photons in Charlie’s device heralds the entanglement. Alice and Bob then
use their random number generators (RNGs) to select a measurement setting for
fast and efficient read-out of the atomic state based on state selective
ionization using particle detectors (CEMs) to detect the created ions (i) and
electrons (e).

##  3 Event-ready CHSH-Bell test with neutral atoms

In our experiment, Alice and Bob’s stations are made each with a single 87Rb
atom stored in an optical dipole trap, see Fig. 1. The two setups are
independently operated, that is, they are equipped with their own laser and
control systems. Two Zeeman states $|m_{F}=\pm 1\rangle$ of the ground state
manifold $5^{2}S_{1/2}$ are used as 1/2-spin states. After an initial state
preparation, the atoms are optically excited to emit a photon whose
polarization is entangled with the atomic spin states, see Fig. 3(a). The
photons are sent to Charlie’s station that is located close to Alice’s
location where a Bell state measurement is implemented with a beamsplitter
followed by a polarizing beamsplitter at each output port and four single
photon detectors, see Fig. 1. The atom excitation procedure is synchronized on
a timescale that is much shorter than the photon duration. Careful adjustment
of experimental parameters ensures a spectral, temporal and spatial mode
overlap of photons close to unity [19]. This allows us to achieve a high two-
photon interference quality limited mostly by two-photon emission effects of a
single atom. The joint measurement performed on these photons distinguishes
two out of the four Bell states and ideally projects the atoms into either of
the two states
$|\psi^{\pm}\rangle=(\left|{\uparrow}\right\rangle_{x}\left|{\downarrow}\right\rangle_{x}\pm\left|{\downarrow}\right\rangle_{x}\left|{\uparrow}\right\rangle_{x})/\sqrt{2}$
according to the outcome. Depending on the loading rate of the traps, 1 to 2
successful Bell state measurements are obtained per minute. At each success, a
signal is sent to Alice and Bob and triggers setting choices. The analysis
basis is selected by the output of a fast quantum random number generator,
which is based on counting photons emitted by an LED with a photo-multiplier
tube [55, 53]. The measurement outcome is obtained by a spin-state dependent
ionization with a fidelity of $97\%$ on a timescale $\leq 1.1\mu$s. Given that
Alice’s and Bob’s locations are separated by 398 m, this warrants space-like
separation of the measurements. Although (strict) space-like separation is not
a necessary condition for self-testing, it is a strong guarantee that Alice
and Bob’s measurement devices are indeed separated from each other and that
information about the setting of one party is not available to the other one
upon measurement, i.e. for assumptions 2 and 4 above.

##  4 CHSH Bell inequality

Let us label the measurement settings $x=0,1$ and $y=0,1$ for Alice and Bob
respectively, with outcomes $a=0,1$ and $b=0,1$ for each spin measurement. For
each pair of settings, we define the correlator
$E_{xy}=\sum_{ab}(-1)^{a+b}P(a,b|x,y)$ where $P(a,b|x,y)$ is the conditional
probability of observing outcome $a$ and $b$ when choosing the settings $x$
and $y$. This allows us to define the Bell-CHSH value, given by

$S=E_{00}+E_{01}+E_{10}-E_{11}.$ (1)

The latter is upper bounded by $2$ for any local causal theory [25]. A
significant violation of this bound can thus rule out this possibility, as
conclusively demonstrated earlier [53], see also [50, 51, 52]. Note that here
the values of 0 and 1 for the settings and outcomes were assigned arbitrarily,
therefore, any of the 8 relabellings of Eq. (1) equally qualifies as a valid
definition of the quantity $S$ [56]. With fixed measurement settings, such
equivalent rewritings of the CHSH expression may be necessary to obtain a
violation of the local bound with different Bell states.

##  5 Self-testing a Bell state

Given assumption 1 above, we can associate to each measurement of Alice and
Bob quantum observables $A_{x}$ and $B_{y}$ acting on two Hilbert spaces
$\mathcal{H}_{A}$ and $\mathcal{H}_{B}$ of unknown dimension. Also, we can
define the quantum state shared by the two parties as $\rho_{AB}\in
L(\mathcal{H}_{A}\otimes\mathcal{H}_{B}).$ We emphasize that the internal
functioning of the source and measurement boxes do not need to be known. We
simply attribute a quantum state and measurement operators to the actual
implementation. Our aim is to identify the actual state $\rho_{AB}$ from the
observed statistics only. More precisely, we wish to estimate its fidelity
with respect to a maximally entangled state of two qubits, that is

$F(\rho_{AB})=\underset{\Lambda_{A},\Lambda_{B}}{\max}\mbox{$\mathrm{Tr}\left((\Lambda_{A}\otimes\Lambda_{B})[\rho_{AB}],\left|{\psi^{-}}\right\rangle\\!\\!\left\langle{\psi^{-}}\right|\right)$},$
(2)

where the maximization is over all local trace-preserving maps
$\Lambda_{A/B}:\mathcal{H}_{A/B}\to\mathbb{C}^{2}.$ The role of these maps
$\Lambda_{A/B}$ is to identify the subsystems inside the unknown Hilbert
spaces $\mathcal{H}_{A/B}$ in which $\rho_{AB}$ can be compared to the desired
state. Given an observed Bell-CHSH value $S$, the Bell state self-testing
fidelity is defined as the minimum fidelity of the unknown quantum state
$\rho_{AB}$ which is compatible with the violation, i.e.

$\displaystyle\mathcal{F}=\underset{\rho_{AB},{A_{x}},{B_{y}}}{\min}$
$\displaystyle F(\rho_{AB})$ (3) s.t. $\displaystyle
E_{00}+E_{01}+E_{10}-E_{11}=S,$

where the correlators are now given by
$E_{xy}=\mbox{$\mathrm{Tr}\left(\rho_{AB}A_{x}B_{y}\right)$}$. This quantity
captures the relation between $\rho_{AB}$ and the singlet state
$\left|{\psi^{-}}\right\rangle$, one representative Bell state, that can be
inferred from observed statistics: if the quantum state is separable, then
$\mathcal{F}\leq\frac{1}{2}$; on the other hand, if $\mathcal{F}=1$, then we
have the guarantee that local maps exist which identify perfectly a Bell state
within the state $\rho_{AB}$, because this is the case for all admissible
quantum realizations.

It has been shown that the self-testing fidelity $\mathcal{F}$ can be directly
related to the sole knowledge of the Bell-CHSH value $S$ [34]. The tightest
known relation is given by [37]

$\mathcal{F}\geq
f(S)=\frac{\max\left(40,\,12+(4+5\sqrt{2})(5S-8)\right)}{80}.$ (4)

##  6 Statistical analysis

The previous formula holds in the limit where the CHSH value $S$ is known
exactly. In order to analyze a real experiment with finite statistics, we
consider that each run $i=1,\ldots,n$ is characterized by an (unknown) CHSH
value $S_{i}$ and fidelity $\mathcal{F}_{i}$. This fidelity could be different
at each round, and depend on past events. We are then interested in making a
claim on the average fidelity

$\overline{\mathcal{F}}=\frac{1}{n}\sum_{i=1}^{n}\mathcal{F}_{i}.$ (5)

Assuming that the measurement settings are chosen independently by both
parties and with a maximum bias $\tau$ with respect to a uniform distribution,
i.e. $1/2-\tau\leq P(x),P(y)\leq 1/2+\tau$, we show in the Appendix B that

$\hat{S}=8\left(I^{-1}_{\alpha}\\!\left(n\overline{t}-1,n(1-\overline{t})+2\right)-\tau-\tau^{2}\right)-4$
(6)

is a lower bound on the average CHSH violation
$\overline{S}=\frac{1}{n}\sum_{i}S_{i}$ with confidence level $1-\alpha$. This
allows us to conclude that $[\hat{\mathcal{F}},1]$ with

$\hat{\mathcal{F}}=f(\hat{S})$ (7)

is a one-sided confidence interval for $\overline{\mathcal{F}}$ with
confidence level $1-\alpha$. Here, $\overline{t}=(4+\overline{S}^{u})/8$ with
$\overline{S}^{u}$ is the average CHSH value observed over the $n$ rounds
assuming a uniform sampling of the settings, i.e. following Eq. (37) from the
Appendix B, and $I^{-1}$ is the inverse regularized incomplete Beta function,
i.e. $I_{\mathsf{y}}(\mathsf{a},\mathsf{b})=\mathsf{x}$ for
$\mathsf{y}=I^{-1}_{\mathsf{x}}(\mathsf{a},\mathsf{b})$. We emphasize that
this bound on the average Bell state fidelity does not rely on the I.I.D.
assumption.

##  7 Preselection

In contrast to results presented in Ref. [53], where all registered events
were taken into account, here we use a pre-selected set of events to compute
the Bell-CHSH violation and the subsequent self-testing fidelities of heralded
atomic states. This selection is based on a physical model which takes into
account detrimental two-photon emission effects of a single atom and allows to
define pre-selection criteria, here a time-window for acceptance of photons in
the BSM, to improve the fidelity of the entangled atom-atom state. Details can
be found in the Appendix A. Importantly, these considerations are not based on
the results observed during the experiment. They are based on an ab-initio
model of the underlying excitation and emission processes. This selection can
then be seen as a pre-selection of the data, or equivalently, as a state
preparation. In particular, it does not open the detection loophole or
introduce expectation bias [57].

Figure 2: Expected self-testing fidelity $\hat{\mathcal{F}}$ resulting from
the pre-selection model (lines) for different confidence levels (CL) as a
function of the starting time of the acceptance time window for heralding
events $t_{s}$ (at a fixed $t_{e}$). The optimal start times for for different
confidence levels according to the model are shown in Tab. 1. In comparison
the self-testing fidelity for the measured data ($|\psi^{-}\rangle$, symbols)
evaluated with the acceptance time window starting with $t_{s}$. Note that the
model for the pre-selection is ab-initio and not a fit for the data. For
details of the model and a comparison to the measured data see Appendix.

##  8 Results

For the evaluation we use the data of events heralding the $|\psi^{-}\rangle$
state from the loophole-free Bell test [53] taken between 05.02.2016 and
24.06.2016 ($25211$ events). Fig. 2 shows the resulting lower bound of the
average fidelity $\hat{\mathcal{F}}$ for the ab-initio model and the data set
using the same pre-selection as a function of the acceptance window starting
time $t_{s}$ for different confidence levels. The model allows to determine
the acceptance time window start time $t_{s}$ and end time $t_{e}$ for an
optimal expected lower bound for the fidelity $\hat{\mathcal{F}}$ for each
confidence level shown in Fig. 2. The results for the pre-selected data are
shown in Tab. 1. For calculation of the lower bound of the fidelity
$\hat{\mathcal{F}}$ we consider bias of the RNGs bounded by $\tau=6.3\times
10^{-4}$ (arsing from the “paranoid” model for the predictability [53]).

The lower bound of fidelity exceeding the value of $0.5$ (at a confidence
level of up to $1-1.1\times 10^{-7}$ for $t_{s}=746$ ns) represents the first
device-independent certification of a distributed entangled state. Moreover,
an evaluation of the full data set without any pre-selection yields a Bell
state fidelity of $0.5061$ at $99\%$ confidence and a Bell state fidelity
larger than $0.5$ can be certified even at a significance level as high as
$99.6\%$.

Additionally, we applied our method to the data of the table-top Bell test
performed between two ions separated by 1 meter reported in [29]. Our
statistical analysis yields an average Bell violation of $2.2715$ or higher at
$99\%$ confidence level, clearly above the threshold $2.11$. This sets a lower
bound on the Bell state fidelity of $61.46\%$ at this confidence level, hence
guaranteeing for the first time that the states distributed in this experiment
had a significant average Bell state fidelity.

Finally, we applied our method to data from [58] obtained at a distance of
$1.3$ km. Due to the limited number of events ($545$), the method can only
guarantee a fidelity larger than $50\%$ with a confidence of $\sim 94.2\%$.
Still, this demonstrates that the method can be used in different systems
without the need of knowing their specific details.

CL | $\hat{\mathcal{F}}$ | $t_{s}$ | $n$ | $\overline{S}^{u}$
---|---|---|---|---
$99\%$ | $0.5550$ |  $748$ ns | $13141$ | $2.2589$
$99.9\%$ | $0.5407$ |  $746$ ns | $14807$ | $2.2554$
$99.99\%$ | $0.5272$ |  $745$ ns | $15671$ | $2.2505$
Table 1: Fidelity $\hat{\mathcal{F}}$ at different confidence levels. For each
the data is pre-selected with an optimal start time for the acceptance time
window [$t_{s}$, $t_{e}=895\text{\,ns}$] resulting in the corresponding $n$
events and an average CHSH value $\overline{S}^{u}$.

##  9 Discussion

We have derived a bound on the average fidelity of a measured state with
respect to a Bell state from the sole knowledge of the observed Bell-CHSH
value which is free of the I.I.D. assumption. This bound was achieved by
constructing a non-I.I.D. confidence interval for the sum of $n$ independent
binary random variables. We used it to quantify device-independently the
quality of a bipartite state distributed over $398$ m in a real-world
elementary quantum network link. These results guarantee that this link is
suitable for an integration in a quantum network, either directly or as a part
of a quantum repeater.

## Acknowledgments

J.-D.B., P.S. and N.S. acknowledge funding by the Swiss National Science
Foundation (SNSF), through the Grant PP00P2-179109 and 200021-175527, by the
Army Research Laboratory Center for Distributed Quantum Information via the
project SciNet and from the European Union’s Horizon 2020 research and
innovation programme under grant agreement No 820445 and project name Quantum
Internet Alliance. K.R. and W.R. acknowledge funding by the German Federal
Ministry of Education and Research via the project Q.com-Q.

##  Appendix A Preselection of heralding events

To allow filtering as a preselection we have developed an ab-initio physical
model independently of our measurement results to find an optimum filtering
based on the model only. This model describes the photon emission process of a
single atom excited by a short laser pulse and takes into account all
important processes within its multilevel structure. Thereby we are able to
calculate the expected fidelity for the entangled state of two atoms heralded
by a two-photon coincidence at a certain time. The full description of the
model goes far beyond the focus of the present work and shall be published
elsewhere [59, 60], here we only present a brief sketch of it.

Figure 3: Structure of the relevant levels in $\mathrm{{}^{87}Rb}$, excitation
an decay processes. (a) Generation of atom-photon entanglement in spontaneous
decay of the excited $5^{2}P_{3/2},F^{\prime}=0,m_{F}=0$ level. The excitation
laser is shown in orange. Photons polarized linearly along the quantization
axis ($\pi$-decays, gray) are not detected in our system. After the first
decay, a second excitation is possible due to polarization misalignment (b),
or off-resonant excitation (c). If the $5^{2}P_{3/2},F^{\prime}=1$ is excited,
also decay to $5^{2}S_{1/2},F=2$ level is possible (d).

For generation of a photon whose polarization is entangled with the atomic
spin state, the atom is excited by a laser pulse resonant to the transition
$5^{2}S_{1/2},F=1\rightarrow 5^{2}P_{3/2},F^{\prime}=0$. The temporal shape of
the pulse is approximately Gaussian with a FWHM of $22$ ns, see Fig. 4. After
the successful emission of a photon, ideally, the atom should not interact
with the excitation laser due to selection rules, see Fig. 3(a). In practice,
however, the atomic state remains weakly sensitive to the excitation laser due
to two reasons. First, there unavoidably are small polarization misalignments
of the excitation laser, i.e. its polarization is not perfectly aligned along
the quantization axis (imperfect $\pi$-polarization), allowing for a
reexcitation of the $5^{2}P_{3/2},F^{\prime}=0,m_{F}=0$ level, see Fig. 3(b).
Second, off-resonant scattering via the $5^{2}P_{3/2},F^{\prime}=1$ level is
possible (Fig. 3(c),(d)). Moreover, before the emission of a photon into the
desired mode takes place, there is a finite probability that the atom emitted
a first photon in a $\pi$-transition, which is not collected by the optics.
These multiple photon emissions are detrimental for the quality of the atomic
state announced by detection of the photons in the Bell state measurement in
two different ways. On the one hand, the state of the atom can be changed by
scattering additional photons. On the other hand, the interference quality of
photons is reduced since the temporal shape and coherence of the photonic
wavepackets is affected.

Figure 4: Time histogram of single photon detection (red) for excitation of a
single atom by a short resonant laser pulse (blue). $t_{s}$ and $t_{e}$ define
the acceptance time window for coincidences.

Importantly, the unwanted multiphoton processes happen predominantly during
the excitation. Thus, to filter them, we only accept the detection events for
which the first detector click is obtained after a time $t_{s}$ when the
excitation laser pulse is essentially off, see Fig. 4. Additionally, to reduce
the dark counts contribution to the heralding event we define a maximal time
$t_{e}$ for the detection of the second photon. A later start time $t_{s}$
increases the entanglement swapping fidelity and by this the expected S-value
for the CHSH inequality but at the expense of the obtained events number, see
Fig. 5. Since the measured S-values will depend not only on the entanglement
swapping fidelity but also on other properties, e.g., the atomic state
measurement fidelity and the coherence time of the entangled states, we use
the experimental parameters as specified in [53] to predict the experiment’s
S-value.

The optimal selection of the time window of
$\left[t_{s}=748\text{\,ns},t_{e}=895\text{\,ns}\right]$, considering Eq. (7)
for a $99\%$ confidence interval, reduces the number of heralding events by
approximately a factor of $2$ but the atoms are expected to be in an entangled
state of a higher quality.

Figure 5: S-value for CHSH inequality (orange line) resulting from the ab-
initio model as a function of the start time $t_{s}$ of the acceptance time
window. The orange circles show the values obtained from experimental data by
applying the same filtering criteria. The black dashed line and squares
respectively show the predicted and measured fraction of remaining events
after filtering. The optimal calculated start time for the acceptance time
window is $t_{s}=748\text{\,ns}$ according to Eq. (7) for $99\%$ confidence.
The contribution of $t_{e}$ to the fidelity was found to be negligible, it was
fixed at $t_{e}=890\text{\,ns}$.

##  Appendix B Finite statistics analysis

In this section, we detail the construction of the confidence interval on the
average singlet fidelity reported in the main text.

###  B.1 Model

In the experimental situation described in the main text, the settings used
after the $i^{\text{th}}$ heralding event can be described by two random
variables $X_{i}$ and $Y_{i}$. These variables follow a global probability
distribution

$P(\vec{X}=\vec{x},\vec{Y}=\vec{y}),$ (8)

where $\vec{X}=(X_{1},X_{2},\ldots)$, $\vec{Y}=(Y_{1},Y_{2},\ldots)$ and
$\vec{x},\vec{y}\in\\{0,1\\}^{n}$ for a binary choice of settings.

Similarly, two random variables $A_{i}$ and $B_{i}$ can be used to describe
the outcomes observed upon measuring the state in the $i^{\text{th}}$ round.
By assumptions 2-4 of the main text, the settings and outcomes follow a joint
probability distribution of the form

$\begin{split}P(\vec{A}&=\vec{a},\vec{B}=\vec{b},\vec{X}=\vec{x},\vec{Y}=\vec{x})=\\\
&P(\vec{X}=\vec{x},\vec{Y}=\vec{y})\prod_{i=1}^{n}P_{i}(a_{i},b_{i}|x_{i},y_{i},\text{past}_{i}).\\\
\end{split}$ (9)

Here, $\vec{a},\vec{b}\in\\{0,1\\}^{n}$ are the possible outcome strings in
the binary case,

$\begin{split}&P_{i}(a,b|x,y,\text{past}_{i})=\\\ &\ \ \ \ \ \ \
P(A_{i}=a,B_{i}=b|X_{i}=x,Y_{i}=y,\text{past}_{i})\end{split}$ (10)

describes the behavior sampled in the $i^{\text{th}}$ round and
$\text{past}_{i}\ni\\{a_{j},b_{j},x_{j},y_{j}\\}_{j<i}$ stands for any
information available from the past of round $i$ such as the previous settings
and outcomes.

We associate to each measurement round $i$ the CHSH value

$S_{i|\text{past}_{i}}=\sum_{a,b,x,y}(-1)^{a+b+xy}P_{i}(a,b|x,y,\text{past}_{i}).$
(11)

This quantity $S_{i|\text{past}_{i}}$ is the expectation value for the S
parameter given in Eq. (1) for the given round $i$. We also define the singlet
fidelity $\mathcal{F}_{i|\text{past}_{i}}$, which is bounded according to Eq.
(4) as

$\mathcal{F}_{i|\text{past}_{i}}\geq f(S_{i|\text{past}_{i}}).$ (12)

Note that these statistical parameters may be different for all rounds $i$ and
may depend on past events.

###  B.2 Estimation

Before focusing on the fidelity, our figure of merit, let us recall how to
estimate the Bell contribution corresponding to a given round $i$. We
introduce the statistic

$T_{i|\text{past}_{i}}=\frac{1}{4}\cdot\frac{\chi(A_{i}\oplus
B_{i}=X_{i}Y_{i})}{P(X_{i},Y_{i}|\text{past}_{i})},$ (13)

where $\chi$ is the indicator function, i.e. $\chi(\text{condition})=1$ if the
condition is true and $\chi(\text{condition})=0$ for a false condition, and
$\oplus$ is the addition modulo 2. The expectation value of this estimator is
directly related to the CHSH violation on round $i$ given the past:

$\begin{split}&\mathbb{E}(T_{i|\text{past}_{i}})\\\ &\ \
=\sum_{\vec{a},\vec{b},\vec{x},\vec{y}}T_{i|\text{past}_{i}}P(\vec{A}=\vec{a},\vec{B}=\vec{b},\vec{X}=\vec{x},\vec{Y}=\vec{y})\\\
&\ \ =\frac{1}{4}\sum_{a,b,x,y}\frac{\chi(a\oplus
b=xy)}{P(X_{i}=x,Y_{i}=y|\text{past}_{i})}\\\ &\ \ \ \ \ \ \ \ \ \ \times
P(A_{i}=a,B_{i}=b,X_{i}=x,Y_{i}=y|\text{past}_{i})\\\ &\ \
=\frac{1}{4}\sum_{a,b,x,y}\chi(a\oplus b=xy)\
P_{i}(a,b|x,y,\text{past}_{i})\\\ &\ \
=\frac{4+S_{i|\text{past}_{i}}}{8}\end{split}$ (14)

This expression thus provides a good estimation of the Bell violation
contribution of round $i$. Note that the relation (14) is valid for all
distribution of the settings which is independent from $A$ and $B$’s behavior
according to Eq. (9).

In the case where the settings are chosen uniformly, i.e.
$P(X_{i}=x_{i},Y_{i}=y_{i}|\text{past}_{i})=\frac{1}{4}$, the random variable
$T_{i|\text{past}_{i}}$ is a Bernoulli variable whose only possible values are
$0$ and $1$. It can then be interpreted as a binary game which is either won
(if $T_{i|\text{past}_{i}}=1$) or lost (if $T_{i|\text{past}_{i}}=0$). The
CHSH contribution of round $i$ can then be re-interpreted in terms of the
winning probability $q_{i|\text{past}_{i}}=P(T_{i|\text{past}_{i}}=1)$ of this
game, such that

$8q_{i|\text{past}_{i}}=4+S_{i|\text{past}_{i}}.$ (15)

###  B.3 Settings choice bias

In practice, it may be difficult to guarantee that the choice of settings is
exactly uniform. One can then resort to a partial characterization of the
settings’ distribution. For instance, consider the case where the settings of
Alice and Bob are chosen independently as

$\begin{split}P(&\vec{X}=\vec{x},\vec{Y}=\vec{y})=\\\ &\ \ \
\prod_{i}P(X_{i}=x_{i},Y_{i}=y_{i}|\\{x_{j},y_{j}\\}_{j<i})\end{split}$ (16)

with

$P(X_{i}=x_{i},Y_{i}=y_{i}|\\{x_{j},y_{j}\\}_{j<i})=P(x_{i}|\tau^{x}_{i})P(y_{i}|\tau^{y}_{i})$
(17)

and

$\displaystyle P(x_{i}|\tau^{x}_{i})$
$\displaystyle=\frac{1}{2}+(-1)^{x_{i}}\tau^{x}_{i}$ (18) $\displaystyle
P(y_{i}|\tau^{y}_{i})$ $\displaystyle=\frac{1}{2}+(-1)^{y_{i}}\tau^{y}_{i},$
(19)

and we only have the guarantee that the local biases are bounded
$|\tau_{i}^{x}|,|\tau_{i}^{y}|\leq\tau$ by some maximal value
$\tau\leq\frac{1}{2}$. In this case the statistic (13) as well as the CHSH
value Eq. (11) cannot be evaluated directly. We can nevertheless bound its
behavior.

For this, let us then consider the statistic that would correspond to a
uniform choice of settings

$\begin{split}T^{u}_{i|\text{past}_{i}}=\chi(A_{i}\oplus
B_{i}=X_{i}Y_{i}).\end{split}$ (20)

As mentioned before, this statistic is a Bernoulli random variable taking
value either 0 or 1. Its winning probability is
$q_{i|\text{past}_{i}}^{u}=\mathbb{E}(T^{u}_{i|\text{past}_{i}})$, and can be
evaluated without having the knowledge of distribution of settings. It’s
expectation value is given by

$\displaystyle\mathbb{E}(T^{u}_{i|\text{past}_{i}})$
$\displaystyle=\sum_{a,b,x,y}\\!\\!\\!\\!\\!\chi(a\oplus
b=xy)P_{i}(a,b|x,y,\text{past}_{i})$ (21) $\displaystyle\ \ \ \ \ \ \ \ \
\times P(x|\tau^{x})P(y|\tau^{y})$
$\displaystyle=\sum_{a,b,x,y}\\!\\!\chi(a\oplus
b=xy)P_{i}(a,b|x,y,\text{past}_{i})$ $\displaystyle\ \ \ \ \
\times\left(\frac{1}{4}+\frac{(-1)^{x}}{2}\tau^{x}+\frac{(-1)^{y}}{2}\tau^{y}+(-1)^{x+y}\tau^{x}\tau^{y}\right)$
$\displaystyle=\underbrace{\frac{1}{4}\sum_{a,b,x,y}\\!\\!\chi(a\oplus
b=xy)P_{i}(a,b|x,y,\text{past}_{i})}_{=\mathbb{E}(T_{i|\text{past}_{i}})}$
(22) $\displaystyle\ \ \ +\sum_{a,b,x,y}\\!\\!\chi(a\oplus
b=xy)P(a,b|x,y,\text{past}_{i})$ $\displaystyle\ \ \
\times\left(\frac{(-1)^{x}}{2}\tau^{x}+\frac{(-1)^{y}}{2}\tau^{y}+(-1)^{x+y}\tau^{x}\tau^{y}\right)$

Defining $f_{xy}=\sum_{a,b}\chi(a\oplus
b=xy)P(a,b|x,y,\text{past}_{i})\in[0,1]$ we write

$\displaystyle\mathbb{E}(T^{u}_{i|\text{past}_{i}})-\mathbb{E}(T_{i|\text{past}_{i}})$
(23)
$\displaystyle=\sum_{x,y}f_{xy}\left(\frac{(-1)^{x}}{2}\tau^{x}+\frac{(-1)^{y}}{2}\tau^{y}+(-1)^{x+y}\tau^{x}\tau^{y}\right).$

Let us now consider this sum. Without loss of generality we set
$0\leq\tau_{y}\leq\tau_{x}\leq\tau$, all the other cases directly follow by a
permutation of the outcomes or the exchange of $x$ and $y$. One has

$\displaystyle
2\sum_{x,y}f_{xy}\left(\frac{(-1)^{x}}{2}\tau^{x}+\frac{(-1)^{y}}{2}\tau^{y}+(-1)^{x+y}\tau^{x}\tau^{y}\right)$
$\displaystyle=f_{00}\left(\tau^{x}+\tau^{y}+2\tau^{x}\tau^{y}\right)+f_{10}\left(-\tau^{x}+\tau^{y}-2\tau^{x}\tau^{y}\right)$
$\displaystyle\ \ \
+f_{01}\left(\tau^{x}-\tau^{y}-2\tau^{x}\tau^{y}\right)+f_{11}\left(-\tau^{x}-\tau^{y}+2\tau^{x}\tau^{y}\right)$
$\displaystyle\leq\tau^{x}+\tau^{y}+2\tau^{x}\tau^{y}+f_{01}\left(\tau^{x}-\tau^{y}-2\tau^{x}\tau^{y}\right),$
(24)

where we used $f_{xy}\in[0,1]$, $\tau^{x}+\tau^{y}+2\tau^{x}\tau^{y}\geq 0$,
$-\tau^{x}+\tau^{y}-2\tau^{x}\tau^{y}\leq 0$ and
$-\tau^{x}-\tau^{y}+2\tau^{x}\tau^{y}\leq 0$. For the last term one finds

$\begin{split}f_{01}&\left(\tau^{x}-\tau^{y}-2\tau^{x}\tau^{y}\right)\\\ &\ \
\
\leq\begin{cases}\tau^{x}-\tau^{y}-2\tau^{x}\tau^{y}&\tau_{y}<\frac{\tau_{x}}{1+2\tau_{x}}\\\
0&\tau_{y}\geq\frac{\tau_{x}}{1+2\tau_{x}},\end{cases}\end{split}$ (25)

leading to

$\displaystyle\sum_{x,y}f_{xy}\left(\frac{(-1)^{x}}{2}\tau^{x}+\frac{(-1)^{y}}{2}\tau^{y}+(-1)^{x+y}\tau^{x}\tau^{y}\right)$
$\displaystyle\leq\begin{cases}\tau^{x}&\tau_{y}<\frac{\tau_{x}}{1+2\tau_{x}}\\\
\frac{1}{2}(\tau^{x}+\tau^{y})+\tau^{x}\tau^{y}&\tau_{y}\geq\frac{\tau_{x}}{1+2\tau_{x}}\end{cases}$
(26) $\displaystyle\leq\tau+\tau^{2},$ (27)

which holds for all allowed values of $\tau^{x}$ and $\tau^{y}$. Plugging this
inequality in Eq. (23) then gives

$\mathbb{E}(T^{u}_{i|\text{past}_{i}})-\mathbb{E}(T_{i|\text{past}_{i}})\leq\tau+\tau^{2}.$
(28)

Therefore, we obtain

$q_{i|\text{past}_{i}}\geq q_{i|\text{past}_{i}}^{u}-\tau-\tau^{2},$ (29)

meaning that a lower bound on the winning probability
$q_{i|\text{past}_{i}}^{u}$ of the uniform statistic
$T^{u}_{i|\text{past}_{i}}$ gives rise to a lower bound on
$q_{i|\text{past}_{i}}$. In order to estimate $q_{i|\text{past}_{i}}$ with a
distribution of settings which is not fully known, we can thus safely estimate
the CHSH value with the statistic (20), effectively assuming that the settings
are chosen uniformly, and then correct the winning probability
$q_{i|\text{past}_{i}}^{u}$ according to the value of $\tau$, as expressed in
(29). This provides a lower bound on the actual winning probability
$q_{i|\text{past}_{i}}$ of (13).

To simplify the notation, we now drop the explicit conditioning on the past,
and thus simply write e.g. $S_{i}$, $q_{i}$, $T_{i}$ and $\mathcal{F}_{i}$ for
the quantities introduced above.

###  B.4 Bounding the fidelity

We construct a statistical parameter for the whole experiment corresponding to
the average Bell state fidelity:

$\overline{\mathcal{F}}=\frac{1}{n}\sum_{i}\mathcal{F}_{i}.$ (30)

Thanks to the convex relation between the CHSH violation and the singlet
fidelity Eq. (4), this quantity can be bounded from the average CHSH violation
$\overline{S}$ as

$\displaystyle\overline{\mathcal{F}}$ $\displaystyle=$
$\displaystyle\frac{1}{n}\sum_{i}\mathcal{F}_{i}$ (31) $\displaystyle\geq$
$\displaystyle\frac{1}{n}\sum_{i}f(S_{i})$ (32) $\displaystyle\geq$
$\displaystyle f\left(\frac{1}{n}\sum_{i}S_{i}\right)=f(\overline{S}),$ (33)

or equivalently, using relation (15), from the average winning probability
$\overline{q}=\frac{1}{n}\sum_{i}q_{i}$ as

$\overline{\mathcal{F}}\geq f(8\overline{q}-4).$ (34)

In particular, a left-sided confidence interval for $\overline{q}$ gives rise
to a one-sided confidence interval for the singlet fidelity. By relation (29),
a left-sided confidence interval for $\overline{q}^{u}=\sum_{i}q_{i}^{u}$
gives rise to a left-sided confidence interval for $\overline{q}$, and thus
also for the singlet fidelity:

$\overline{\mathcal{F}}\geq
f\left(8(\overline{q}^{u}-\tau-\tau^{2})-4\right).$ (35)

Let us thus focus now on the average winning probability $\overline{q}^{u}$.

###  B.5 A confidence interval for the average winning probability

The random variables $T_{i}^{u}$ in Eq. (20) being estimators for the
parameters $q_{i}^{u}$, we use their average

$\overline{T}^{u}=\frac{1}{n}\sum_{i=1}^{n}T_{i}^{u}$ (36)

to estimate $\overline{q}^{u}$. This gives rise to the following effective
CHSH value

$\overline{S}^{u}=8\overline{T}^{u}-4$ (37)

which can be evaluated in practice directly from the observed data, without
assumption on the distribution of measurement settings. Note that each random
variable $T_{i}^{u}$ is a Bernoulli variable with parameter $q_{i}^{u}$.
Therefore, $\overline{T}^{u}$ is a so-called (renormalized) Poisson binomial
random variable. The distribution probability of such a random variable in
terms of the average parameter $\overline{q}^{u}$ has been characterized by
Hoeffding [61]. We recall this result here.

######  Theorem B.1 (Hoeffding, 1956).

Let $\overline{T}=\frac{1}{n}\sum_{i=1}^{n}T_{i}$ be the average of $n$
independent Bernoulli variables $T_{i}$ with parameters $q_{i}$. If $c$ and
$d$ are two integers such that

$0\leq c\leq n\overline{q}\leq d\leq n$ (38)

for $\overline{q}=\frac{1}{n}\sum_{i=1}^{n}q_{i}$, then

$P(c\leq n\overline{T}\leq
d)\geq\sum_{k=c}^{d}\binom{n}{k}{\overline{q}}^{k}(1-\overline{q})^{n-k}.$
(39)

This theorem says that within all sets of $n$ choices of Bernoulli variables
$\\{T_{i}\\}_{i=1}^{n}$ with a fixed average parameter
$\overline{q}=\frac{1}{n}\sum_{i}q_{i}$, the one producing the largest tail
distribution for the average variable $\overline{T}$ is the set of $n$
identically-distributed Bernoulli variables with $q_{i}=\overline{q}$ $\forall
i$. The tail probability then follows a binomial distribution. Since
$q_{i}=\overline{q}$ $\forall i$ is an admissible parameter value, this bound
is tight.

We recall that the Binomial cumulative distribution can be expressed in terms
of the regularized incomplete Beta function
$I_{\mathsf{x}}(\mathsf{a},\mathsf{b})$ as

$\sum_{k=0}^{d}\binom{n}{k}q^{k}(1-q)^{n-k}=1-I_{q}(d+1,n-d),$ (40)

or equivalently

$\sum_{k=c}^{n}\binom{n}{k}q^{k}(1-q)^{n-k}=I_{q}(c,n-c+1).$ (41)

We then denote the inverse regularized incomplete Beta function by $I^{-1}$,
i.e. $I_{\mathsf{y}}(\mathsf{a},\mathsf{b})=\mathsf{x}$ for
$\mathsf{y}=I^{-1}_{\mathsf{x}}(\mathsf{a},\mathsf{b})$.

Note that even if Thm. B.1 applies to independent (though not necessarily
identically distributed) random variables, it is still useful for our purpose
in which we do not wish to assume rounds to be either independent or
identically distributed. The reason is because we are interested in the
average winning probability $\overline{q}$, defined as the average of
individual winning probabilities $q_{i}=q_{i|\text{past}_{i}}$ which are
conditioned on past events. The corresponding conditional random variables
$T_{i}=T_{i|\text{past}_{i}}$ are indeed independent from each other. We now
construct a confidence interval for the average CHSH winning probability
$\overline{q}$.

######  Theorem B.2.

Given Bernoulli random variables $T_{i}$ with parameter $q_{i}$ for
$i=1,\ldots,n$ and $0\leq\alpha\leq 1/2$, the interval $[\hat{q},1]$ with the
random variable

$\hat{q}=\begin{cases}I^{-1}_{\alpha}(n\overline{T}-1,n(1-\overline{T})+2)&\textrm{if
}n\overline{T}\geq 1\\\ 0&\textrm{if }n\overline{T}=0\end{cases}$ (42)

is a confidence interval for $\overline{q}=\frac{1}{n}\sum_{i}q_{i}$ with
confidence level $1-\alpha$.

###### Proof.

We need to show that

$P(\hat{q}\leq\overline{q})\geq 1-\alpha$ (43)

for all possible sets of Bernoulli variables characterized by parameters
$0\leq q_{i}\leq 1$ with $\frac{1}{n}\sum_{i}q_{i}=\overline{q}$. Condition
(43) states that whatever the unknown distribution of the Bernoulli variables
$T_{i}$ happens to be, the value of $\hat{q}$ computed from them (the random
variable $\hat{q}$ depends on the observed $\overline{T}$) can be higher than
the actual parameter $\overline{q}$ only with probability at most $\alpha$.
$\hat{q}$ then constitutes a reasonable lower bound for the parameter
$\overline{q}$.

The case for which $n\overline{T}=0$ is clear. We can thus assume that
$n\overline{T}\geq 1$. But before starting, let us introduce the function

$\begin{split}g:&\mathbb{R}\to\mathbb{R}\\\ &z\mapsto
I^{-1}_{\alpha}(z,n-z+1).\end{split}$ (44)

This function describes the trade-off between the parameters $q$ and $z$ in
$I_{q}(z,n-z+1)$. Let us remember that the incomplete beta function
$I_{q}(\alpha,\beta)$ is the cumulative distribution function for the beta
distribution with parameter $\alpha$ and $\beta$. Therefore, $I_{q}(z,n-z+1)$
is strictly increasing on $q\in[0,1]$ even for non-integer values of $n$ and
$z$. At the same time, $1-I_{q}(z,n-z+1)$ seen as a function of
$z\in\mathbb{R}$ is a cumulative distribution for the continuous binomial
distribution with parameter $q$, so it strictly increases with $z\in[0,n+1]$
[62]. In other words, $I_{q}(z,n-z+1)$ strictly decreases with $z$. Since
$g(z)$ is defined as the value of $q$ which leaves $I_{q}(z,n-z+1)$ invariant
(and equal to $\alpha$) when $z$ changes, it is a strictly increasing function
of $z\in[0,n+1]$: increasing $z$ increases $I_{q}(z,n-z+1)$ unless $q$
increases as well.

Let us now write

$\begin{split}P(\hat{q}\leq\overline{q})&=P(n\overline{T}=0)\\\ &\ \ \
+\sum_{k=1}^{n}P(n\overline{T}=k)\chi(g(k-1)\leq\overline{q})\\\
&=\sum_{k=0}^{d}P(n\overline{T}=k)\\\ \end{split}$ (45)

where $P(n\overline{T}=k)$ is the probability distribution of the sum
$n\overline{T}$ of arbitrary Bernoulli random variables and $d$ is the largest
integer such that $g(d-1)\leq\overline{q}$, hence $g(d)>\overline{q}$. The sum
contains all terms between 0 and $d$ because $g(z)$ is an increasing function.

Another implication of the monotonicity of $I_{\overline{q}}(z,n-z+1)$ with
respect to q, is that its inverse function $I^{-1}_{\alpha}(z,n-z+1)$
increases with $\alpha$. Therefore

$I^{-1}_{\alpha}(z,n-z+1)\leq I^{-1}_{1/2}(z,n-z+1)$ (46)

for $\alpha\leq 1/2$. $I^{-1}_{1/2}(z,n-z+1)$ is the median of a beta
distribution, which can always be bounded by its mean [63]:

$\begin{split}I^{-1}_{1/2}(z,n-z+1)&\leq\begin{cases}\frac{z}{n+1}&\text{if
}z\leq n-z+1\\\ 1-\frac{n-z+1}{n+1}&\text{else}\end{cases}\\\
&=\frac{z}{n+1}.\end{split}$ (47)

Therefore, we have

$I^{-1}_{\alpha}(n\overline{q},n(1-\overline{q})+1)\leq\frac{n\overline{q}}{n+1}\leq\overline{q}.$
(48)

Since $g(d)\geq\overline{q}$ by the definition of $d$, we obtain

$\displaystyle g(d)$ $\displaystyle\geq
I^{-1}_{\alpha}(n\overline{q},n(1-\overline{q})+1)=g(n\overline{q}).$ (49)

By the strict monotonicity of $g$, this implies that the condition $d\geq
n\overline{q}$ is satisfied. So we can use Thm. (B.1) to lower bound the
probability Eq. (45) by the binomial case:

$\begin{split}P(\hat{q}\leq\overline{q})&=\sum_{k=0}^{d}P(n\overline{T}=k)\\\
&=P(n\overline{T}\leq d)\\\
&\geq\sum_{k=0}^{d}\binom{n}{k}{\overline{q}}^{k}(1-\overline{q})^{n-k}\end{split}$
(50)

Using Eq. (40) we obtain

$P(\hat{q}\leq\overline{q})\geq 1-I_{\overline{q}}(d+1,n-d).$ (51)

Since $g(d)\geq\overline{q}$, or

$I_{\alpha}^{-1}(d,n-d+1)\geq\overline{q}$ (52)

and $I_{\overline{q}}(d,n-d+1)$ is an increasing function of $\overline{q}$ we
can write:

$\begin{split}I_{I_{\alpha}^{-1}(d,n-d+1)}(d,n-d+1)=\alpha&\geq
I_{\overline{q}}(d,n-d+1)\\\ &\geq I_{\overline{q}}(d+1,n-d),\end{split}$ (53)

where we applied the incomplete beta function to both sides of Eq. (52) and
used the monotonicity of the beta function again in the last line. Combining
with Eq. (51) completes the proof

$\begin{split}P(\hat{q}\leq\overline{q})&\geq 1-I_{\overline{q}}(d+1,n-d)\\\
&\geq 1-\alpha.\end{split}$ (54)

∎

## References

  * Kimble [2008] H. J. Kimble, The quantum internet, Nature (London) 453, 1023 (2008).
  * Gisin and Thew [2007] N. Gisin and R. Thew, Quantum communication, Nature Photonics 1, 165 (2007).
  * Knill and Laflamme [1996] E. Knill and R. Laflamme, Concatenated quantum codes, (1996), arXiv:quant-ph/9608012.
  * Briegel  _et al._ [1998] H.-J. Briegel, W. Dur, J. I. Cirac, and P. Zoller, Quantum repeaters: the role of imperfect local operations in quantum communication, Phys. Rev. Lett. 81, 5932 (1998).
  * Sangouard  _et al._ [2011] N. Sangouard, C. Simon, H. De Riedmatten, and N. Gisin, Quantum repeaters based on atomic ensembles and linear optics, Rev. Mod. Phys. 83, 33 (2011).
  * Pirandola [2016] S. Pirandola, Capacities of repeater-assisted quantum communications, (2016), arXiv:1601.00966.
  * [7] E. Schoute, L. Mancinska, T. Islam, I. Kerenidis, and W. S., Shortcuts to quantum network routing, arXiv:1610.05238.
  * [8] M. Pant, H. Krovi, D. Towsley, L. Tassiulas, L. Jiang, P. Basu, D. Englund, and S. Guha, Routing entanglement in the quantum internet, arXiv:1708.07142.
  * Wallnofer  _et al._ [2016] J. Wallnofer, M. Zwerger, C. Muschik, N. Sangouard, and W. Dur, Two-dimensional quantum repeaters, Phys. Rev. A 94, 052307 (2016).
  * Epping  _et al._ [2016] M. Epping, H. Kampermann, and D. Bruss, Large-scale quantum networks based on graphs, New J. Phys. 18, 053036 (2016).
  * Das  _et al._ [2018] S. Das, S. Khatri, and J. P. Dowling, Robust quantum network architectures and topologies for entanglement distribution, Physical Review A 97, 012335 (2018).
  * Matsukevich  _et al._ [2006] D. N. Matsukevich, T. Chanelière, S. D. Jenkins, S.-Y. Lan, T. A. B. Kennedy, and A. Kuzmich, Entanglement of remote atomic qubits, Phys. Rev. Lett. 96, 030405 (2006).
  * Chou  _et al._ [2007] C.-W. Chou, J. Laurat, H. Deng, K. S. Choi, H. de Riedmatten, D. Felinto, and H. J. Kimble, Functional quantum nodes for entanglement distribution over scalable quantum networks, Science 316, 1316 (2007).
  * Yuan  _et al._ [2008] Z.-S. Yuan, Y.-A. Chen, B. Zhao, S. Chen, J. Schmiedmayer, and J.-W. Pan, Experimental demonstration of a bdcz quantum repeater node, Nature (London) 454, 1098 (2008).
  * Moehring  _et al._ [2007] D. L. Moehring, P. Maunz, S. Olmschenk, K. C. Younge, D. N. Matsukevich, L.-M. Duan, and C. Monroe, Entanglement of single-atom quantum bits at a distance, Nature (London) 449, 68 (2007).
  * Matsukevich  _et al._ [2008] D. N. Matsukevich, P. Maunz, D. L. Moehring, S. Olmschenck, and C. Monroe, Bell inequality violation with two remote atomic qubits, Phys. Rev. Lett. 100, 150404 (2008).
  * Lee  _et al._ [2011] K. C. Lee, M. R. Sprague, B. J. Sussman, J. Nunn, N. K. Langford, X.-M. Jin, T. Champion, P. Michelberger, K. F. Reim, D. England, D. Jaksch, and I. A. Walmsley, Entangling macroscopic diamonds at room temperature, Science 334, 1253 (2011).
  * Ritter  _et al._ [2012] S. Ritter, C. Nölleke, C. Hahn, A. Reiserer, A. Neuzner, M. Uphoff, M. Mücke, E. Figueroa, J. Bochmann, and G. Rempe, An elementary quantum network of single atoms in optical cavities, Nature (London) 484, 195 (2012).
  * Hofmann  _et al._ [2012] J. Hofmann, M. Krug, N. Ortegel, L. Gérard, M. Weber, W. Rosenfeld, and H. Weinfurter, Heralded entanglement between widely separated atoms, Science 337, 72 (2012).
  * Bernien  _et al._ [2013] H. Bernien, B. Hensen, W. Pfaff, G. Koolstra, M. S. Blok, L. Robledo, T. H. Taminiau, M. Markham, D. J. Twitchen, L. Childress, and R. Hanson, Heralded entanglement between solid-state qubits separated by three metres, Nature 497, 86 (2013).
  * Acin  _et al._ [2006] A. Acin, N. Gisin, and L. Masanes, From bell’s theorem to secure quantum key distribution, Phys. Rev. Lett. 97, 120405 (2006).
  * Scarani [2012] V. Scarani, The device-independent outlook on quantum physics, Acta Physica Slovaca 62, 347 (2012).
  * Popescu and Rohrlich [1992] S. Popescu and D. Rohrlich, Which states violate bell’s inequality maximally? Phys. Lett. A 169, 411 (1992).
  * Braunstein  _et al._ [1992] S. L. Braunstein, A. Mann, and M. Revzen, Maximal violation of bell inequalities for mixed states, Phys. Rev. Lett. 68, 3259 (1992).
  * Clauser  _et al._ [1969] J. F. Clauser, M. A. Horne, A. Shimony, and R. A. Holt, Proposed experiment to test local hidden-variable theories, Phys. Rev. Lett. 23, 880 (1969).
  * Mayers and Yao [1998] D. Mayers and A. Yao, Quantum cryptography with imperfect apparatus, Proceeding FOCS ’98 Proceedings of the 39th Annual Symposium on Foundations of Computer Science , 503 (1998).
  * Mayers and Yao [2004] D. Mayers and A. Yao, Self testing quantum apparatus, QIC 4, 273–286 (2004).
  * Colbeck [2009] R. Colbeck, Quantum and relativistic protocols for secure multi-party computation, (2009), arXiv:0911.3814.
  * Pironio  _et al._ [2010] S. Pironio, A. Acin, S. Massar, A. Boyer de la Giroday, 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).
  * Bamps and Pironio [2015] C. Bamps and S. Pironio, Sum-of-squares decompositions for a family of clauser-horne-shimony-holt-like inequalities and their application to self-testing, Phys. Rev. A 91, 052111 (2015).
  * Reichard  _et al._ [2013] B. W. Reichard, F. Unger, and U. Vazirani, Classical command of quantum systems, Nature (London) 496, 456 (2013).
  * Ivan Šupić [2019] J. B. Ivan Šupić, Self-testing of quantum systems: a review, (2019), arXiv:1904.10042.
  * Tomamichel and Hänggi [2013] M. Tomamichel and E. Hänggi, The link between entropic uncertainty and nonlocality, J. Phys. A: Math. Theor. 46, 055301 (2013).
  * Bardyn  _et al._ [2009] C.-E. Bardyn, T. C. H. Liew, S. Massar, M. McKague, and V. Scarani, Device-independent state estimation based on bell’s inequalities, Phys. Rev. A 80, 062327 (2009).
  * Miller and Shi [2013] C. Miller and Y. Shi, Optimal robust self-testing by binary nonlocal xor games, 8th Conference on the Theory of Quantum Computation, Communication and Cryptography, TQC 2013 22, 254 (2013).
  * Yang  _et al._ [2014] T. H. Yang, T. Vértesi, J.-D. Bancal, V. Scarani, and M. Navascués, Robust and versatile black-box certification of quantum devices, Phys. Rev. Lett. 113, 040401 (2014).
  * Kaniewski [2016] J. Kaniewski, Analytic and nearly optimal self-testing bounds for the clauser-horne-shimony-holt and mermin inequalities, Phys. Rev. Lett. 117, 070402 (2016).
  * McKague [2016] M. McKague, Interactive proofs for bqp via self-tested graph states, Theory of Computing 12, 1 (2016).
  * Natarajan and Vidick [2017] A. Natarajan and T. Vidick, A qantum linearity test for robustly verifying entanglement, Proc. of STOC ’17 , 1003–1015 (2017).
  * Coladangelo  _et al._ [2017] A. Coladangelo, K. T. Goh, and V. Scarani, All pure bipartite entangled states can be self-tested, Nature Communications 8, 15485 (2017).
  * Šupić  _et al._ [2018] I. Šupić, A. Coladangelo, R. Augusiak, and A. Acín, Self-testing multipartite entangled states through projections onto two systems, New Journal of Physics 20, 083041 (2018).
  * Magniez  _et al._ [2006] F. Magniez, D. Mayers, M. Mosca, and H. Ollivier, Self-testing of quantum circuits, Proceedings of the 33rd International Colloquium on Automata, Lang Lecture Notes in Computer Science No. 4052, edited by Bugliesi , 72 (2006).
  * Bancal  _et al._ [2015] J.-D. Bancal, M. Navascues, V. Scarani, T. Vertesi, and T. H. Yang, Physical characterization of quantum devices from nonlocal correlations, Phys. Rev. A 91, 022115 (2015).
  * Dall’Arno  _et al._ [2017] M. Dall’Arno, S. Brandsen, and F. Buscemi, Device-independent tests of quantum channels, Proc. R. Soc. A 473, 20160721 (2017).
  * Kaniewski [2017] J. Kaniewski, Self-testing of binary observables based on commutation, Phys. Rev. A 95, 062323 (2017).
  * Sekatski  _et al._ [2018] P. Sekatski, J.-D. Bancal, S. Wagner, and N. Sangouard, Certifying the building blocks of quantum computers from bell’s theorem, Phys. Rev. Lett. 121, 180505 (2018).
  * Wagner  _et al._ [2018] S. Wagner, J.-D. Bancal, N. Sangouard, and P. Sekatski, Device-independent characterization of generalized measurements, (2018), arXiv:1812.02628.
  * Tan  _et al._ [2017] T. R. Tan, Y. Wan, S. Erickson, P. Bierhorst, D. Kienzler, S. Glancy, E. Knill, D. Leibfried, and D. J. Wineland, Chained bell inequality experiment with high-efficiency measurements, Phys. Rev. Lett. 118, 130403 (2017).
  * Valcarce  _et al._ [2019] X. Valcarce, P. Sekatski, D. Orsucci, E. Oudot, J.-D. Bancal, and N. Sangouard, What is the minimum chsh score certifying that a state contains the singlet? (2019), arXiv:1910.04606.
  * Hensen  _et al._ [2015] B. Hensen, H. Bernien, A. E. Dréau, A. Reiserer, N. Kalb, M. S. Blok, J. Ruitenberg, R. F. L. Vermeulen, R. N. Schouten, C. Abellán, W. Amaya, V. Pruneri, M. W. Mitchell, M. Markham, D. J. Twitchen, D. Elkouss, S. Wehner, T. H. Taminiau, and R. Hanson, Loophole-free bell inequality violation using electron spins separated by 1.3 kilometres, Nature (London) 526, 682 (2015).
  * Shalm  _et al._ [2015] L. K. Shalm, E. Meyer-Scott, B. G. Christensen, P. Bierhorst, M. A. Wayne, M. J. Stevens, T. Gerrits, S. Glancy, D. R. Hamel, M. S. Allman, K. J. Coakley, S. D. Dyer, C. Hodge, A. E. Lita, V. B. Verma, C. Lambrocco, E. Tortorici, A. L. Migdall, Y. Zhang, D. R. Kumor, W. H. Farr, F. Marsili, M. D. Shaw, J. A. Stern, C. Abellán, W. Amaya, V. Pruneri, T. Jennewein, M. W. Mitchell, P. G. Kwiat, J. C. Bienfang, R. P. Mirin, E. Knill, and S. W. Nam, Strong loophole-free test of local realism, Phys. Rev. Lett. 115, 250402 (2015).
  * Giustina  _et al._ [2015] M. Giustina, M. A. M. Versteegh, S. Wengerowsky, J. Handsteiner, A. Hochrainer, K. Phelan, F. Steinlechner, J. Kofler, J.-c. A. Larsson, C. Abellán, W. Amaya, V. Pruneri, M. W. Mitchell, J. Beyer, T. Gerrits, A. E. Lita, L. K. Shalm, S. W. Nam, T. Scheidl, R. Ursin, B. Wittmann, and A. Zeilinger, Significant-loophole-free test of bell’s theorem with entangled photons, Phys. Rev. Lett. 115, 250401 (2015).
  * Rosenfeld  _et al._ [2017] W. Rosenfeld, D. Burchardt, R. Garthoff, K. Redeker, N. Ortegel, M. Rau, and H. Weinfurter, Event-ready bell test using entangled atoms simultaneously closing detection and locality loopholes, Phys. Rev. Lett. 119, 010402 (2017).
  * Bell [1964] J. S. Bell, On the einstein podolsky rosen paradox, Physics 1, 195 (1964).
  * Fürst  _et al._ [2010] M. Fürst, H. Weier, S. Nauerth, D. G. Marangon, C. Kurtsiefer, and H. Weinfurter, High speed optical quantum random number generation, Opt. Express 18, 13029–13037 (2010).
  * Rosset  _et al._ [2014] D. Rosset, J.-D. Bancal, and N. Gisin, Classifying 50 years of bell inequalities, J. Phys. A: Math Theor. 47, 424022 (2014).
  * Jenga [2006] M. Jenga, A selected history of expectation bias in physics, American Journal of Physics 74, 578 (2006).
  * Hensen  _et al._ [2016] B. Hensen, N. Kalb, M. S. Blok, A. E. Dréau, A. Reiserer, R. F. L. Vermeulen, R. N. Schouten, M. Markham, D. J. Twitchen, K. Goodenough, D. Elkouss, S. Wehner, T. H. Taminiau, and R. Hanson, Loophole-free bell test using electron spins in diamond: second experiment and additional analysis, Scientific Reports 6, 30289 (2016).
  * [59] J. Hofmann, M. Krug, N. Ortegel, C. Kurz, M. Weber, W. Rosenfeld, and H. Weinfurter, in preparation .
  * [60] K. Redeker, R. Garthoff, W. Rosenfeld, and H. Weinfurter, in preparation .
  * Hoeffding [1956] W. Hoeffding, On the distribution of the number of successes in independent trials, Annals of Math. Stat. 27, 713 (1956).
  * Ilienko [2013] A. Ilienko, Continuous conterparts of poisson and binomial distributions and their properties, Annales Univ. Sci. Budapest., Sect. Comp. 39, 137 (2013), arXiv:1303.5990.
  * R. van de Ven [1993] N. C. W. R. van de Ven, Bounds for the median of the negative binomial distribution, Metrika 40, 185 (1993).