\documentclass{article}
\input{../lib.sty}

\title{\texttt{fn discrete\_laplacian\_scale\_to\_accuracy}}
\author{\MichaelShoemateAuthor}

\begin{document}
\maketitle

This document contains materials associated with \rustdoc{accuracy/fn}{discrete\_laplacian\_scale\_to\_accuracy}.

\begin{definition}
    Let $z$ be the true value of the statistic and $X$ be the random variable the noisy release is drawn from.
    Define $Y = |X - z|$, the distribution of DP errors. 
    Then for any statistical significance level \texttt{alpha}, denoted $\alpha \in [0, 1]$, and \texttt{accuracy}, denoted $a \ge 0$,
    \begin{equation}
        \alpha = P[Y \ge a]
    \end{equation}
\end{definition}

\begin{theorem}
    For any $\texttt{scale} \ge 0$ denoted $s$, when $X \sim \mathcal{L}_\mathbb{Z}(z, s)$, 
    \begin{equation}
        a = s \cdot ln(2 / (\alpha (e^{1/s} + 1))) + 1
    \end{equation}
\end{theorem}

\begin{proof}

Consider that the distribution of $(X - z) \sim \mathcal{L}_\mathbb{Z}(0, s)$.
Then the PMF of $Y$ is:
\begin{equation}
    \forall y \ge 0 \qquad g(y) = (1 + 1[y \ne 0]) \frac{1 - e^{-1/s}}{1 + e^{-1/s}} e^{-y/s}
\end{equation}

The purpose of the indicator function is to avoid double-counting zero.

Now derive an expression for $\alpha$:
\begin{align*}
    \alpha &= P[Y \ge a] \\
    &= 1 - P[Y < a] \\
    &= 1 - \sum_{y=0}^{a - 1} g(y) && \text{where $g(y)$ is the distribution of Y} \\
    &= 1 - \frac{1 - e^{-1/s}}{1 + e^{-1/s}} \left(1 + 2\sum_{y=0}^{a - 1} e^{-y/s}\right) \\
    &= 2 \frac{e^{(1 - a)/s}}{e^{1/s} + 1}
\end{align*}

Invert to solve for $a$:
\begin{align*}
    2 \frac{e^{(1 - a)/s}}{e^{1/s} + 1} &= \alpha \\
    e^{(1 - a)/s} &= \alpha (e^{1/s} + 1) / 2 \\
    a &= 1 - s \cdot ln(\alpha (e^{1/s} + 1) / 2) \\
    a &= s \cdot ln(2 / (\alpha (e^{1/s} + 1))) + 1
\end{align*}

\end{proof}

\end{document}
