\documentclass[aps,prl,twocolumn,superscriptaddress, letterpaper]{revtex4}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{amsmath}

\newcommand{\ket}[1]{|{#1}\rangle}
\newcommand{\bra}[1]{\langle{#1}|}


\begin{document}
\title{Error analysis in the measurement of the CHSH inequality}

\maketitle
\section{Counting statistics}
The SPDC process produces photon pairs at random times.
We can then assume that the poissonian statistics well represents the probability distribution of the count within a finite time interval, with a mean value equal to the number of detected coincidences $N$.
\begin{equation}\label{eq:count_poiss}
	\Delta N_p = \sqrt{N}
\end{equation}

\section{Time uncertainties}
% The time uncertainties affect the count rate. Defining the count rate $R$ as the ratio between the total count in a finite time interval $N$, and the duration of the time interval $T$, $R=\frac{N}{T}$, we can derive the effect of the uncertainty $\Delta T$ has on the rate.
% \begin{equation}
% 	\Delta R^2 =\frac{\Delta N^2}{T^2}+\frac{N^2\cdot\Delta T^2}{T^4}.
% \end{equation}
% We can now use Eq.~(\ref{eq:count_poiss}) and the relation $N = R\cdot T$:
% \begin{equation}
% 	\Delta N = \sqrt{N + N^2 \frac{\Delta T^2}{T^2}}
% 	\approx
% 	\Delta N_p + N\frac{\Delta T}{2T}.
% \end{equation}
% The effect of a temporal uncertainty $\Delta T$ is then described by:
% \begin{equation}\label{eq:count_time}
% 	\Delta N_T =\frac{1}{2} N\frac{\Delta T}{T}.
% \end{equation}

Time uncertaineties affect the total acquisition time $T$.
The uncertainty on the number of counts in a finite time interval $N$ is proportional to the time uncertainty times the count rate $R$, defined as $R = N/T$.
\begin{equation}\label{eq:count_time}
	\Delta N_T =R\cdot\Delta T =  N\frac{\Delta T}{T}.
\end{equation}


\section{Detector dead time}
The effect of the dead time of the detector $T_D$ is to reduce the effective measurement time $T$ by a quantity $S_{1,2}\cdot T_D$, with $S_{A,B}$ representing the total number of single counts for the detectors $A$, $B$. The uncertainty in the total measurement time  is then proportional to the uncertainty in the single counts:
$\Delta T = T_D \cdot \Delta S_{A,B} = T_D\sqrt{S_{A,B}}$.
Applying Eq.~(\ref{eq:count_time})), we obtain:
\begin{equation}\label{eq:count_dead}
	\Delta N_D = N\sqrt{(S_A+S_B)}\frac{T_D}{T}.
\end{equation}

\section{Polarizers}
In order to assess how the uncertainty in the angular position of the polarizers propagates into an uncertainty in $N$, we assume that the relation between $N$, $\theta_A$, and $\theta_B$ is well described by standard quantum mechanics.
If this is the case, for the singlet state we expect $N$ to be a function of the difference $\theta = \theta_A - \theta_B$: $N = \frac{1}{2} (sin\theta)^2 $.
We can easily then propagate the uncertainty $\Delta \theta_A = \Delta \theta_B = \Delta \theta$ to obtain:
\begin{equation}\label{eq:count_polarizer}
	\Delta N_R = \sqrt{2}N\cot{\theta}\;\Delta \theta.
\end{equation}


\section{Total error on $N$}
We can combine the errors expressed by Eqs.~(\ref{eq:count_poiss},\ref{eq:count_time},\ref{eq:count_dead},\ref{eq:count_polarizer})) to calculate the uncertainty associated with each measurement N:
\begin{equation}
	\Delta N = \sqrt{(\Delta N_P)^2+(\Delta N_T)^2+(\Delta N_D)^2+(\Delta N_R)^2},
\end{equation}
where each term is calculated for the corresponding angular setting $\theta$ and also include the single counts $S_A$ and $S_B$.

\section{Propagation of the error to $E$}

In order to propagate the error to $E$, we use the standard propagation for the statistical error:
\begin{equation}
	\Delta E^2 = \sum\limits_{i=1}^4 \left(\frac{\partial E}{\partial N_i}\right)^2\Delta N_i^2
\end{equation}
from the definition of $E$, we derive:
\begin{equation}
	\frac{\partial E}{\partial N_i} =
	\begin{cases}
    2\frac{N_3+N_4}{\left(\sum\limits_{i=1}^4 N_i\right)^2} & \mathrm{ for }\; i=1,2\\
    &\\
    2\frac{N_1+N_2}{\left(\sum\limits_{i=1}^4 N_i\right)^2} & \mathrm{ for }\; i=3,4\,,\\
  \end{cases}
\end{equation}
from which it follows:
\begin{equation}
	\Delta E = \frac{2
	\left[
	(N_3+N_4)^2(\Delta N_1^2+\Delta N_2^2) + (N_1+N_2)^2(\Delta N_3^2+\Delta N_4^2)
	\right]}{\left(\sum\limits_{i=1}^4 N_i\right)^2}
\end{equation}

We use the Matlab script
\verb|err_estimation.m|
% (I apologize for the terrible name, it is not mine)
to numerically propagate the error from the the 16 $N$s to the final $S$.
It is possible to derive a single analytical expression but it would contain $16*3$ variables: the 16 coincidences and the 16 singles counts from $A$ and $B$

On the other hand, with some basic assumption it is possible to figure out the dependencies.

Assuming that $N_i = N\cdot c_i$, with $N = \sum\limits_i N_i$, and $|E| = \frac{1}{\sqrt{2}}$
% and that $N$ and $\Delta N$ are the same for all measurements,
we obtain:
\begin{equation}
	\Delta E = \frac{\Delta N}{4N}.
\end{equation}


Under the same assumptions, we obtain the uncertainty for $S$:
\begin{equation}
	\Delta S = \frac{\Delta N}{N}.
\end{equation}


Replacing $\Delta N$  with the uncertainty associated only with $\Delta T$, we obtain the scaling:

\begin{equation}
	\Delta S_T = \frac{\Delta T}{T}.
\end{equation}

\end{document}