Approximate counting by hashing #
Stockmeyer's approximate counting [Sto83] estimates the size of a set S with
#S ≤ 2 ^ n from the answers, for each level j ≤ n, to the question whether S meets a random
one of 2 ^ j cells, the fibers of a pairwise independent hash family into a set of size 2 ^ j.
The cells at level j have mean size #S / 2 ^ j: if it is at least 8, then S meets a random
cell with probability at least 7 / 8, and if it is at most 1 / 8, with probability at most
1 / 8.
The estimate (Cslib.Probability.ApproximateCounting.estimate) is 2 ^ k for the largest level
k ≤ n answered yes, or 0 if the level 0, whose single cell is S, is answered no. If the
answers are correct wherever the mean cell size is at least 8 or at most 1 / 8
(Cslib.Probability.ApproximateCounting.AnswersCorrect), the estimate is at most 8 #S and at
least #S / 16. Answering each question by the majority of 2 r independent trials
(Cslib.Probability.ApproximateCounting.hashAnswer), the answers are correct except with
probability at most (n + 1) (8 / 9) ^ r, so with r = 12 (n + 1) the estimate is within these
bounds with probability at least 3 / 4. Each question is an NP question when membership in S
is decidable in polynomial time, which is how Stockmeyer approximates #P functions with an NP
oracle; this file contains the finite, probabilistic part of the argument.
Main definitions #
Cslib.Probability.ApproximateCounting.estimate: the estimate from the answers.Cslib.Probability.ApproximateCounting.AnswersCorrect: correct answers for a set of a given size.Cslib.Probability.ApproximateCounting.hashAnswer,Cslib.Probability.ApproximateCounting.hashEstimate: the answers and the estimate from majority votes over independent seeds of pairwise independent hash families.
Main results #
Cslib.Probability.ApproximateCounting.AnswersCorrect.estimate_le,Cslib.Probability.ApproximateCounting.AnswersCorrect.le_estimate: correct answers give an estimate between#S / 16and8 #S.Cslib.Probability.ApproximateCounting.dens_filter_not_answersCorrect_le: the majority answers are correct except with probability at most(n + 1) (8 / 9) ^ r.Cslib.Probability.ApproximateCounting.three_quarters_le_dens_filter_hashEstimate: withr = 12 (n + 1)the estimate is between#S / 16and8 #Swith probability at least3 / 4, andCslib.Probability.ApproximateCounting.three_quarters_le_dens_filter_affineHashEstimatefor the affine hash families overZMod 2.
References #
The estimate from the answers #
Stockmeyer's estimate of the size of a set from answers a j, for the levels j ≤ n, to the
question whether the set meets a random one of 2 ^ j cells: 0 if level 0 is answered no, and
otherwise 2 ^ k for the largest level k ≤ n answered yes.
Instances For
Answers a j, for the levels j ≤ n, to the question whether a set of c elements meets a
random one of 2 ^ j cells are correct if level 0 answers whether c ≠ 0, and every level
j ≤ n answers yes when the mean cell size c / 2 ^ j is at least 8 and no when it is at most
1 / 8.
Level
0answers whetherc ≠ 0.A level with mean cell size at least
8answers yes.A level with mean cell size at most
1 / 8answers no.
Instances For
Correctness of decidable answers is decidable.
The estimate from correct answers is at most 8 times the size of the set.
The estimate from correct answers is at least a sixteenth of the size c ≤ 2 ^ n of the
set.
Majority votes and the union bound #
Answers from hashing #
The answers from hashing, with seeds ω j k for the levels j ≤ n and the trials
k < 2 r: level j answers yes if more than r of the hash functions h j (ω j k) send an
element of S to the target y j.
Instances For
The answers from hashing are decidable.
Stockmeyer's estimate of #S from the answers from hashing with seeds ω.
Instances For
The answers from hashing are correct with high probability: if every h j is a pairwise
independent hash family into a set of 2 ^ j elements, with seeds from a nonempty type ι j, then
for 2 r independent uniform seeds per level j ≤ n, the majority answers are correct for S
except with probability at most (n + 1) (8 / 9) ^ r.
Stockmeyer's approximate counting: if every h j is a pairwise independent hash family
into a set of 2 ^ j elements, with seeds from a nonempty type ι j, and #S ≤ 2 ^ n, then for
24 (n + 1) independent uniform seeds per level j ≤ n, the estimate from the majority answers is
between #S / 16 and 8 #S with probability at least 3 / 4.
Affine hash families #
Approximate counting with affine hashes: for a set S of vectors in (ZMod 2) ^ n, with
the affine hash families x ↦ A x + b into (ZMod 2) ^ j for the levels j ≤ n, target 0, and
24 (n + 1) independent seeds per level, the estimate is between #S / 16 and 8 #S with
probability at least 3 / 4.