Approximate counting with relative error #
Stockmeyer's estimate of the size of a set S from hashing (hashEstimate) is only accurate
within a constant factor: with high probability it lies between #S / 16 and 8 #S. Applied to
the Cartesian power S ^ k, whose size is #S ^ k, the same constant factor becomes the factor
128 ^ (1 / k) after taking a k-th root, so a large enough number k of copies gives an
estimate of #S with any prescribed relative error [Sto83]. In integers: if
s ^ k ≤ e ≤ c s ^ k and c p ^ k ≤ (p + 1) ^ k, then the integer k-th root ⌊e ^ (1 / k)⌋ of
e lies between s and (1 + 1 / p) s, and k = 7 p copies suffice for the factor
c = 128 = 2 ^ 7, as (1 + 1 / p) ^ p ≥ 2.
The failure probability of the estimate is amplified by the majority votes inside it: answering
each of the n + 1 questions by the majority of 12 (n + 1 + t) trials makes the estimate fail
with probability at most 2 ^ (-t).
Main definitions #
Cslib.Probability.ApproximateCounting.relativeHashEstimate: the estimate of#Sfrom thek-th root of Stockmeyer's estimate of the size ofS ^ k.
Main results #
Cslib.Probability.ApproximateCounting.le_nthRoot_and_mul_nthRoot_le: an estimate ofs ^ kwithin a factorc ≤ (1 + 1 / p) ^ kgives an estimate ofswithin relative error1 / p.Cslib.Probability.ApproximateCounting.two_pow_mul_pow_le_add_one_pow:k = m pcopies make the factor2 ^ mat most(1 + 1 / p) ^ k.Cslib.Probability.ApproximateCounting.dens_filter_not_hashEstimate_le: Stockmeyer's estimate fails to lie between#S / 16and8 #Swith probability at most(n + 1) (8 / 9) ^ r.Cslib.Probability.ApproximateCounting.dens_filter_not_relativeHashEstimate_le,Cslib.Probability.ApproximateCounting.one_sub_inv_two_pow_le_dens_filter_relativeHashEstimate: the relative estimate lies between#Sand(1 + 1 / p) #Sexcept with probability at most(n + 1) (8 / 9) ^ r, and so with probability at least1 - 2 ^ (-t)forr = 6 (n + 1 + t).Cslib.Probability.ApproximateCounting:one_sub_inv_two_pow_le_dens_filter_affineRelativeHashEstimategives the same for a set of vectors in(ZMod 2) ^ m, with7 pcopies and affine hash families.
References #
Roots of estimates of powers #
Relative error from an estimate of a power. If e over-estimates s ^ k by at most a
factor c, that is s ^ k ≤ e ≤ c s ^ k with k ≠ 0, and c ≤ (1 + 1 / p) ^ k, then the
integer k-th root of e estimates s from above within the relative error 1 / p:
s ≤ ⌊e ^ (1 / k)⌋ ≤ (1 + 1 / p) s.
Amplifying the success probability #
The relative estimate of #S from hashing: the integer k-th root of 16 E, where E is
Stockmeyer's estimate (hashEstimate) of the size #S ^ k of the Cartesian power S ^ k from
the hash families h j on k-tuples, the targets y j and the seeds ω. The factor 16 makes
16 E an over-estimate of #S ^ k whenever E is at least #S ^ k / 16.
Instances For
The failure probability of Stockmeyer's estimate: 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 2 r independent uniform seeds per level j ≤ n, the estimate from the
majority answers fails to lie between #S / 16 and 8 #S with probability at most
(n + 1) (8 / 9) ^ r.
Approximate counting with relative error: if every h j is a pairwise independent hash
family on k-tuples into a set of 2 ^ j elements, with seeds from a nonempty type ι j,
#S ^ k ≤ 2 ^ n, and 128 ≤ (1 + 1 / p) ^ k, then for 2 r independent uniform seeds per level
j ≤ n, the relative estimate fails to lie between #S and (1 + 1 / p) #S with probability at
most (n + 1) (8 / 9) ^ r.
Approximate counting with relative error and small failure probability: under the
hypotheses of dens_filter_not_relativeHashEstimate_le, for 12 (n + 1 + t) independent uniform
seeds per level j ≤ n, the relative estimate lies between #S and (1 + 1 / p) #S with
probability at least 1 - 2 ^ (-t); at least 3 / 4 for t = 2.
Affine hash families #
Approximate counting with affine hashes and relative error: for a set S of vectors in
(ZMod 2) ^ m and a precision p ≠ 0, with 7 p copies, the affine hash families
x ↦ A x + b into (ZMod 2) ^ j applied to 7 p-tuples of vectors read as vectors in
(ZMod 2) ^ (7 p × m), for the levels j ≤ 7 p m, target 0, and 12 (7 p m + 1 + t)
independent seeds per level, the relative estimate lies between #S and (1 + 1 / p) #S with
probability at least 1 - 2 ^ (-t).