Revised S.4 example and corresponding Fig. 3.

master
Aaron Huber 2022-06-07 09:32:14 -04:00
parent f8fd864a28
commit 07ea722712
3 changed files with 11 additions and 11 deletions

View File

@ -94,14 +94,14 @@ Given the above, the algorithm is a sampling based algorithm for the above sum:
to $\abs{\coef}$ and compute $\vari{Y}=\indicator{\isInd{\encMon}}
\cdot \prod_{X_i\in \monom} p_i$.
Repeating the sampling an appropriate number of times
and computing the average of $\vari{Y}$ gives us our final estimate. To illustrate the sampling procedure using~\Cref{fig:circuit}, \onepass recursively computes $\abs{\circuit}\inparen{1,\ldots, 1}$, where the gray values are the intermediate values.
and computing the average of $\vari{Y}$ gives us our final estimate. To illustrate the sampling procedure using~\Cref{fig:circuit}, \onepass recursively computes $\abs{\circuit}\inparen{1,\ldots, 1}$ for any subcircuit whose sink is gate \circuit. The gray values in~\Cref{fig:circuit} illustrate these computations, as seen, for example in the leftmost $\circplus$ gate, where $\abs{\circuit}\inparen{1,\ldots, 1} = \abs{\circuit_\linput}\inparen{1,\ldots, 1} + \abs{\circuit_\rinput}\inparen{1,\ldots, 1}$, the sum of its children's values.
% visits each gate \circuit exactly once, computing $\abs{\circuit}\inparen{1,\ldots, 1}$. %for each gate \circuit.
%If we consider the leftmost source gates, \onepass computes $\abs{\circuit}\inparen{1,\ldots,1} = 1$ for $\circuit.\val = X$ and $\abs{\circuit}\inparen{1,\ldots, 1} = 2$ for $\circuit.\val = 2$. For the leftmost $\circmult$ gate, \onepass computes $\abs{\circuit}\inparen{1,\ldots, 1} = 2\circmult 1$, i.e. $\abs{\circuit_\linput}\inparen{1,\ldots, 1} \times \abs{\circuit_\rinput}\inparen{1,\ldots, 1}$ for children $\circuit_\linput$ and $\circuit_\rinput$. A level higher, the leftmost $\circplus$ gate recursively adds the values of its two children deriving $\abs{\circuit}\inparen{1,\ldots, 1} = 2 \circplus 1$, while using the expression $\frac{\abs{\circuit_i}\inparen{1,\ldots, 1}}{\abs{\circuit}\inparen{1,\ldots, 1}}$ for $i\in\inset{\linput, \rinput}$ to simultaneously compute the weights $\frac{1}{3}$ and $\frac{2}{3}$ for its children. The final sum value is then computed in similar fashion. % yielding $\abs{\circuit}\inparen{1,\ldots, 1} = 3 \circmult 3 = 9$.
Given the computed values of \onepass, \sampmon picks a sampling path by traversing both children of a $\circmult$ gate and randomly choosing a child from a $\circplus$ gate according to the weight $\frac{\abs{\circuit_i}\inparen{1,\ldots, 1}}{\abs{\circuit}\inparen{1,\ldots, 1}}$ for $i\in\inset{\linput, \rinput}$.
%Given the computed values of \onepass, \sampmon picks a sampling path by traversing both children of a $\circmult$ gate and randomly choosing a child from a $\circplus$ gate according to the weight $\frac{\abs{\circuit_i}\inparen{1,\ldots, 1}}{\abs{\circuit}\inparen{1,\ldots, 1}}$ for $i\in\inset{\linput, \rinput}$.
%then uses the weights provided by \onepass to randomly select a monomial from $\expansion{\circuit}$.
To sample the monomial $X$ in~\Cref{fig:circuit}, \sampmon recursively traverses both children of the sink gate. Since both children are $\circplus$ gates, \sampmon then randomly selects the left child of each $\circplus$ gate with probability $\frac{1}{3}$ and $\frac{2}{3}$ respectively. Note that the probabilty for choosing both said children is $\frac{2}{9}$, which is indeed the ratio of the number of $X$ terms to the total number of terms in $\expansion{\circuit}$, thus a correct sampling probability. For the fomer $\circplus$ gate, the leaf gate with variable $X$ and sign value $1$ is returned, while the latter visits both children of the selected child $\circmult$ gate, recursively returning $X$ with a sign value of $1$. Finally, \sampmon performs the operation $X\cup X = X$, effectively reducing the monomial to its $\rpoly$ valuation. Suppose \sampmon also randomly samples $XY$ and $-Y$. To estimate $\rpoly\inparen{\vct{\prob}}$, \approxq computes $\prob_X + \prob_X\prob_Y - \prob_Y$ and scales the accumulation accordingly.
To sample the monomial $-XY$ in~\Cref{fig:circuit}, \sampmon recursively traverses both children of the sink $\circmult$ gate. Since both $\circuit_\linput$ and $\circuit_\rinput$ are $\circplus$ gates, \sampmon then randomly selects the left child of $\circuit_\linput$ with probability $\frac{1}{3}$ and the right child of $\circuit_\rinput$ with probability $\frac{1}{3}$. Note that the probabilty for choosing both $\circuit_\linput$ and $\circuit_\rinput$ is $\frac{1}{9}$, which is indeed the ratio of the number of $-XY$ terms to the total number of terms in $\expansion{\circuit}$, thus a correct sampling probability. For the recursive call on $\circuit_\linput$, the leaf gate with variable $X$ and sign value $1$ is returned, while $\circuit_\rinput$ recursively visits both children of the sampled $\circmult$ gate, returning $Y$ with a sign value of $-1$. Multiplying $-1 \circmult XY$, concludes the random sampling of monomial $-XY$. Suppose \sampmon also randomly samples $X$ and $-Y$ from $\rpoly$ in a call to \approxq. To estimate $\rpoly\inparen{\vct{\prob}}$, \approxq computes $\prob_X - \prob_X\prob_Y - \prob_Y$ and scales the accumulation accordingly.
%such that a source gate \circuit has $\abs{\circuit}\inparen{1,\ldots, 1} = \circuit.\val$ when \circuit.\type $=$ \num and $\abs{\circuit}\inparen{1,\ldots,1} = 1$ otherwise. For every gate \circuit, \onepass computes $\abs{\circuit}\inparen{1,\ldots, 1}$ as seen in the lighter font of~\Cref{fig:circuit}. \onepass further weights each child $\circuit_i$ for $i\in\inset{\linput, \rinput}$, by the expression $\frac{\abs{\circuit_i}\inparen{1,\ldots, 1}}{\abs{\circuit}\inparen{1,\ldots, 1}}$. These weight are the basis for the sampling performed by \sampmon.
All the algorithm details are in \Cref{sec:proofs-approx-alg}.
All algorithm details are in \Cref{sec:proofs-approx-alg}.
%%%%%%%%%%%%%%%%%%%%%%%

View File

View File

@ -23,19 +23,19 @@ Each gate has the following members: \type, \vari{input}, %\val,
%see https://tex.stackexchange.com/questions/26846/how-to-scale-a-tikzpicture-including-texts#26852
%for a nice explanation of scaling a tikzpicture
\begin{tikzpicture}[thick, scale=0.67, every node/.style={transform shape}]
\node[tree_node] (a1) at (0, 0) {$\boldsymbol{X}$};
\node[tree_node, purple] (a1) at (0, 0) {$\boldsymbol{X}$};
\node[tree_node] (b1) at (1.5, 0) {$\boldsymbol{2}$};
\node[tree_node] (c1) at (3, 0) {$\boldsymbol{Y}$};
\node[tree_node] (d1) at (4.5, 0) {$\boldsymbol{-1}$};
\node[tree_node, purple] (c1) at (3, 0) {$\boldsymbol{Y}$};
\node[tree_node, purple] (d1) at (4.5, 0) {$\boldsymbol{-1}$};
\node[tree_node] (a2) at (0.75, 0.75) {$\boldsymbol{\circmult}$};
\node[tree_node] (b2) at (2.25, 0.75) {$\boldsymbol{\circmult}$};
\node[tree_node] (c2) at (3.75, 0.75) {$\boldsymbol{\circmult}$};
\node[tree_node, purple] (c2) at (3.75, 0.75) {$\boldsymbol{\circmult}$};
\node[tree_node] (a3) at (0.55, 1.5) {$\boldsymbol{\circplus}$};
\node[tree_node] (b3) at (3.75, 1.5) {$\boldsymbol{\circplus}$};
\node[tree_node, purple] (a3) at (0.55, 1.5) {$\boldsymbol{\circplus}$};
\node[tree_node, purple] (b3) at (3.75, 1.5) {$\boldsymbol{\circplus}$};
\node[tree_node] (a4) at (2.25, 2.25) {$\boldsymbol{\circmult}$};
\node[tree_node, purple] (a4) at (2.25, 2.25) {$\boldsymbol{\circmult}$};
%%%%%%%%%%%%%%
%|C| label nodes
\node[draw=none, figray%, left=of a1