% -*- root: main.tex -*-
\section{Exact Results}
\label{sec:exact}
We turn to computing the exact values of
\begin{equation}
\sum\limits_{\wVec \in \pw } \sketchJParam{\sketchHashParam{\wVec}}\sketchPolarParam{\wVec} = 
\sum\limits_{\wVec \in \pw } \kMapParam{\wVec}\sketchPolarParam{\wVec} 
\sum_{\substack{\wVecPrime \in \pw\st\\
			\sketchHashParam{\wVec} = \sketchHashParam{\wVecPrime}}} \sketchPolarParam{\wVecPrime}\label{eq:exact-results} .
\end{equation}
Starting with the latter term $\gIJ = \sum\limits_{\wVecPrime \in \pw}\sketchPolarParam{\wVecPrime}$, by the definition of the image of $\sketchPolar$ and the property of associativity in addition, we can break the sum into
\begin{equation*}
\gIJ = \sum_{\substack{\wVecPrime \in \pw \st\\
				\sketchPolarParam{\wVecPrime} = 0}} 1 + \sum_{\substack{\wVecPrime \in \pw \st\\
													\sketchPolarParam{\wVecPrime} = 1}} -1.
\end{equation*}
Setting the terms to $T_1 =  \sum\limits_{\substack{\wVecPrime \in \pw \st\\
				\sketchPolarParam{\wVecPrime} = 0}} 1$ and $T_2 =  \sum\limits_{\substack{\wVecPrime \in \pw \st\\
													\sketchPolarParam{\wVecPrime} = 1}} -1$ and fixing $\buck$ to a specific value, gives a system of linear equations for each term.  It is a known result for a consistent matrix multiplication that the number of solutions are $| \kDom |^{\numTup - rank(\matrixH')}$, where $\kDom$ is the set being considered.  This gives us an exact calculation for both terms, 
\begin{align*}
T_1 = |\{\wVec \st \matrixH' \cdot \wVec = \buck^{(0)}\}|\rightarrow T_1 \in \{0, 2^{\numTup - rank(\matrixH')}\},\\
T_2 = |\{\wVec \st \matrixH' \cdot \wVec = \buck^{(1)}\}|\rightarrow T_2 \in \{0, 2^{\numTup - rank(\matrixH')}\},
\end{align*}
where the notation $\jpbit{y}$ denotes the polarity bit $\lenB$ value of the $\buck$ bucket identifier, specifically $\buck(b)$, such that $\buck(b)\in \{0, 1\}$.  

\subsection{Algorithm for $\gIJ$}
\begin{algorithmic}
\ForAll{$\wVec \in \pw$}
\If{$\sketchHashParam{\wVec} = \buck$}
	\If{$\sketchPolarParam{\wVec} = 1$}
		\State $\gIJ += 1$
	\Else
		\State $\gIJ -= 1$
	\EndIf
\EndIf
\EndFor.
\end{algorithmic}
%Non-general algorithm
%\begin{algorithmic}
%\If {$\matrixH' \cdot \wVec = j^{(0)}$ is consistent}
%	\If {$\matrixH' \cdot \wVec = j^{(1)}$ is consistent}
%		\State $\gIJ = 0$
%	\Else
%		\State $\gIJ = 2^{\numTup - computeRank(\matrixH')}$
%	\EndIf
%\ElsIf{$\matrixH' \cdot \wVec = \buck^{(1)}$ is consistent}
%	\State $\gIJ = 2^{\numTup - computeRank(\matrixH')}$
%\Else
%	\State $\gIJ = 0$
%\EndIf.
%\end{algorithmic}
For examining the first term of equation \eqref{eq:exact-results}, we fix $\kMap{t}$ to be defined as
\begin{equation*}
\kMapParam{\wVec} = \begin{cases}
					1,&\text{if } w_t = 1\\
					0,		&\text{otherwise}.
				  \end{cases}
\end{equation*}
%Therefore, by definition we have
%\begin{equation*}
%\sum_{\wVec \in \pw}\sketchJParam{\sketchHashParam{\wVec}} = \sum_{\wVec \in \pw}\kMapParam{\wVec}\sketchPolarParam{\wVec},
%\end{equation*}
Using the same argument as in $\gIJ$ yields
\begin{equation*}
\sum_{\wVec \in \pw \st \sketchPolarParam{\wVec} = 0}\kMapParam{\wVec} - \sum_{\wVec \in \pw \st \sketchPolarParam{\wVec} = 1}\kMapParam{\wVec}.
\end{equation*}
Setting $T_3 = \sum\limits_{\wVec \in \pw \st \sketchPolarParam{\wVec} = 0}\kMapParam{\wVec}$, $T_4 = \sum\limits_{\wVec \in \pw \st \sketchPolarParam{\wVec} = 1}\kMapParam{\wVec}$ gives an exact calculation for each term given a fixed $\buck$:
\begin{equation*}
T_3 = | \{\wVec \st \matrixH \cdot \wVec = \buck^{(0)}, \kMapParam{\wVec} = 1\}\rightarrow T_3 \in [0, 2^{\numTup - rank(\matrixH')}]
\end{equation*}
\begin{equation*}
T_4 = | \{\wVec \st \matrixH \cdot \wVec = \buck^{(1)}, \kMapParam{\wVec} = 1\}\rightarrow T_4 \in [0, 2^{\numTup - rank(\matrixH') - 1}]
\end{equation*}




\subsection{Algorithm for Initialization}
\begin{algorithmic}
\ForAll{$\wVec \in \pw \st \kMapParam{\wVec} = 1$}
	\State $\sketchJParam{\sketchHashParam{\wVec}} = \sketchPolarParam{\wVec}$
\EndFor.
\end{algorithmic}
%Non-generic Algorithm
%\begin{algorithmic}
%\ForAll{$\wVec \st \kMapParam{\wVec} = 1$}
%	\State $\buck = \matrixH' \cdot \wVec$
%	\If{$\buck(\lenB) = 0$}
%		\State $\sketchIj += 1$
%	\Else
%		\State$\sketchIj -= 1$
%	\EndIf
%\EndFor.
%\end{algorithmic}