We design an almost instance optimal algorithm for the sum estimation problem using weighted sampling. We show that the sample complexity for sum estimation is closely related to the ℓ2 norm of the weighted sampling distribution. We show an almost instance optimal lower bound for this problem as well. We also study the moment estimation problem and design an algorithm that has better instance-wise sample complexity bounds.
1 Introduction
Let A={a1,a2,…,an} be a set of n elements, where element ai has a non-negative weight w(ai). Let W=∑a∈Aw(a) be the total weight of elements in A. In our computational model, one does not get direct access to the weights of the elements in A. Instead, one gets sample access to the elements of A using an oracle. We assume access to an oracle that returns an element a∈A with probability proportional to its weight w(a). That is, the oracle samples element ai∈A with probability pi=Ww(ai). Throughout, we refer to these samples as weighted samples or proportional samples. Our objective is to design an algorithm that computes a good estimate of W using a sublinear number of queries to the oracle. Next, we formally define the sum estimation problem.
Definition 1.1. ((ϵ,δ)-sum estimation) Given sample access to a set A with n weighted elements, and parameters ϵ,δ∈(0,1), the objective is to obtain an estimate W^ of W=∑a∈Aw(a) such that Pr[∣W^−W∣>ϵW]≤δ.
Our objective in this work is to design an algorithm that compues an (ϵ,δ)-estimate of W using a small number of queries to the oracle. Beretta and Tětek [BT24] showed that, in the worst case, obtaining an (ϵ,1/3)-estimate of W requires Θ(ϵn) proportional samples. Their estimator crucially relies on observing a collision in the sample. Since, in the worst case, Ω(n) samples are needed to observe a collision for the uniform distribution, their algorithm has worst-case sample complexity of O(n/ϵ). They also showed a matching lower bound of Ω(n/ϵ) samples for any
∗National Institute of Science Education and Research, Bhubaneswar, 752050, India
†Homi Bhabha National Institute, Training School Complex, Anushakti Nagar, Mumbai, 400094, India
(ϵ,1/3)-estimate of the sum of the weights. While this sample complexity bound is optimal in the worst case, it might not capture the complexity of the problem on all input instances. In this work, we set out to design algorithms which have better sample complexity bounds on an instance to instance basis. Consider, for example, instances which have a small number of very large weights and the remaining weights are small. With high probability, one would observe a collision in the sampled set with much less number of samples for this instance. Hence, if detecting a collision is the key for an algorithm of this problem to work, then it might require considerably less number of samples compared to the worst-case bound of Ω(n/ϵ). This leads to our quest for designing an instance optimal algorithm for the sum estimation problem using weighted sampling. Let p denote the proportional (weighted) sampling distribution for A. It is known that the probability of observing a collision in the sample is related to the ℓ2 norm ∥p∥2 of the sampling distribution p [BC17, SGW22, DGPP19]. We ask the following question in this work.
Sample complexity for Sum Estimation
Can the sample complexity of the sum estimation problem using proportional sampling be expressed using the ℓ2 norm of the proportional sampling distribution p?
We answer this question in the affirmative by designing an algorithm for the sum estimation problem, where the sample complexity depends on the ℓ2 norm of p. We design an algorithm that produces an (ϵ,δ)-estimate of W using O((ϵ2∥p∥21+∥p∥2ln1/∥p∥2)log1/δ) samples on an input instance with weighted distribution p. More specifically, we prove the following result.
Theorem 1.1. (Upper bound for Sum Estimation) Given proportional sampling access to a set A with n weighted elements and parameters 0<ϵ,δ<1, there exists an algorithm that gives an (ϵ,δ)-estimate of the sum of the weights using O((ϵ2∥p∥21+∥p∥2ln1/∥p∥2)log1/δ) proportional samples.
Next, we show an almost instance optimal lower bound for the sum estimation problem. More specifically, we prove a Ω(ϵ∥p∥21) lower bound for any (ϵ,1/3)-estimate of W, when the input instance A and ϵ are restricted in the following sense.
Theorem 1.2. Let A=A1⊎A2⊎…⊎At, where all elements in Ai have weight wi, and let t be a constant. Let 0<ϵ≤1 be such that ϵ≥1/∣Ai∣ for all i. Then, any (ϵ,1/3)-estimate of W requires Ω(ϵ∥p∥21) proportional samples.
We also construct families of instances for which ∥p∥2 is a constant, and show that for ϵ>1/n, one requires Ω(1/ϵ2) samples for any (ϵ,1/3)-estimate of the sum. More formally, we prove the following result.
Theorem 1.3. For ϵ>1/n, there exist instances with ∥p∥2 being a constant such that any (ϵ,1/3) estimate of the sum requires Ω(ϵ2∥p∥21) samples.
Next, we discuss our results for the moment estimation problem. We first formally define the (ϵ,δ)-moment estimation problem below.
Definition 1.2. ((ϵ,δ)-moment estimation) Given sample access to a set A with n weighted elements, and parameters ϵ,δ∈(0,1), an integer h>1, the objective of the (ϵ,δ)-moment estimation problem is to obtain an (ϵ,δ)-estimate of Wh(A)=∑a∈Aw(a)h.
Motivated by our result for the sum estimation problem for which the sample complexity can be expressed as a function of the ℓ2 norm of sampling distribution p, we ask whether a similar result can be obtained for the moment estimation problem. We state the following question that we explore in our work.
Sample complexity for Moment Estimation
Can the sample complexity for the moment estimation problem using proportional sampling be expressed using the ℓh norm of the proportional sampling distribution p?
We give a positive answer to this question and state the algorithmic result we obtain for this problem below.
Theorem 1.4. (Upper bound for moment estimation) There exists an algorithm that given proportional sampling access to a set A with n weighted elements and parameters ϵ,δ∈(0,1) and h>1, returns an (ϵ,δ)-estimate of Wh(A) using O((∥p∥hh+ϵ2∥p∥h1+ϵ2∥p∥21+∥p∥2ln1/∥p∥2)log1/δ) samples.
2 Technical overview
The main idea behind our sum estimation algorithm is to find a subset S⊂A for which w(S)/W is sufficiently large such that the ratio w(S)/W can be subsequently estimated using a small number of independent samples to obtain an estimate W^ for W. We show that this idea almost works out when ∣S∣=O(1/∥p∥2). We first obtain an estimate T for the ℓ2 norm ∥p∥2 of the weighted sampling distribution p, and then independently sample S of O(1/T) elements. We still need to take care of two issues. First, if the variance of the weights wi is large, then a sample S of size O(1/T) might not result in a large w(S)/W. To overcome this, we proceed as follows. First, we check whether there exists a heavy hitter element ai∈A for which the sampling probability pi is larger than some threshold. If such an element ai exists, we set S={ai}. Else, the variance of the weights cannot be too large and we show that a sampled set S of size O(1/T) would have large w(S)/W with high probability. Second, we estimate the ratio w(S)/W by obtaining independent samples and computing the fraction of sampled elements that belong to S. One subtle issue here is that the estimate will be wrong if the sample S contains duplicates. We resolve this by choosing the sample size O(1/T) such that with high probability S does not contain any repeated elements.
For the moment estimation problem, Bhattacharya and Pradhan [BP25] have given an (ϵ,δ)-estimate for the h-th moment Wh(A) of A using O((n/ϵ+ϵ2n1−1/h)ln1/δ) proportional samples, for any h>1. We note that the first term in the above sample complexity bound appears due to the sum estimation algorithm of [BT24] that the authors use as a subroutine. We also observe that the second term can be expressed using the ℓh norm ∥p∥h of the sampling distribution p. In our algorithm for the moment estimation problem, we first estimate the ℓh norm ∥p∥h of p. We do this by sampling elements until we observe the first h-wise collision. We show that this gives a good estimate of ∥p∥h, and we run the algorithm of Bhattacharya and Pradhan with this estimate. We use our sum estimation algorithm as a subroutine in this algorithm in place of the sum estimation algorithm of [BT24].
We prove a lower bound on the number of samples required to obtain an (ϵ,1/3)-estimate the sum of the weights of A using proportional sampling. We adapt the techniques of Beretta and Tětek [BT24] to obtain an almost instance optimal lower bound for the sum estimation problem. However, we have to face significant difficulties in extending the worst-case lower bound of [BT24] to an almost instance optimal lower bound. First, the construction of the hard instances differs substantially from that of [BT24]. Beretta and Tětek [BT24] showed that an instance with uniform weights is a worst-case instance for the sum estimation problem. Since, we aim for an instance optimal lower bound, for every input instance I, we need to construct an almost similar instance I′ with W(I′)≥(1+ϵ)W(I) such that it is difficult to distinguish the two instances while using a small number of samples. Beretta and Tětek computed the ratio of the conditional probabilities of observing a sample from I and I′, and show that the ratio is a function of the number of distinct elements in the sample. Using concentration bounds on the number of distinct elements in the sample, they argue that this ratio remains close to one when the number of samples is o(n/ϵ), and show that even the Bayes optimal classifier cannot distinguish the instances when this ratio is close to one. We group elements of A into t blocks A1,…,At, where all elements in a block have the same weight. We compute the ratio of the conditional probabilities of observing a sample from I and I′, and show that this ratio depends on the number of distinct elements observed from each block. We show that the number of distinct elements from each block is concentrated around its expected value and argue that the ratio remains close to one when the number of samples is o(ϵ∥p∥21). Since the ratio remains close to one, even the Bayes optimal classifier cannot distinguish whether the samples are from I or I′ with probability at least 2/3. We require the number t of blocks to be a constant and ϵ≥1/∣Ai∣ for all i for this analysis to work.
3 Related works
Motwani et al. [MPX07] initiated the study of the sum estimation problem using weighted sampling and designed an algorithm that uses O~(n/ϵ7/2) proportional samples. Recently, Beretta and Tětek [BT24] designed an worst-case optimal algorithm for the (ϵ,1/3)-sum estimation problem that uses Θ(n/ϵ) samples. For the moment estimation problem, Bhattacharya and Pradhan [BP25] designed an algorithm for (ϵ,δ)-moment estimation using O(ϵ2n1−1/hln1/δ) samples for any h>1. There have been a lot of work on graph parameter estimation problems in the query model. We cite only a few relevant works here [ERS18, ERS19, BCS26].
4 Preliminaries
Fact 4.1. For any vector x∈Cn, and for any 0<r<p, we have ∣∣x∣∣p≤∣∣x∣∣r≤n(1/r−1/p)∣∣x∣∣p.
Lemma 4.1. (Chernoff bound [MU17]) Let Z1,Z2,…,Zv be independent and identically distributed Bernoulli random variables and 0<γ<1 and η>0. Let Z=∑i=1vZi. Then, Pr[Z≤(1−γ)E[Z]]≤e−1/2⋅γ2⋅E[Z] and Pr[Z≥(1+η)E[Z]]≤((1+η)(1+η)eη)E[Z]. Also, for R≥2eE[Z], we have Pr[Z≥R]≤2−R.
Theorem 4.1. (Efron-Stein Inequality [BLM13]) Let X1,…,Xn be independent random variables and let X1′,…,Xn′ be an independent copy of X1,…,Xn. Let Z=f(X1,…,Xn) be a square-integrable function of X. Let us define Zi′=f(X1,…,Xi−1,Xi′,Xi+1,…,Xn) for all i. Then, Var[Z]≤1/2⋅∑i=1nE[(Z−Zi′)2].
Suppose we have an (ϵ,1/3)-estimator for St(A) which uses T samples. There is a standard technique called the median of means (see Theorem 2.1 of [AMS99]) to reduce the failure probability from 1/3 to any desired value δ∈(0,1), using O(T⋅lnδ1) samples. For the sake of completeness, we present the technique and its proof below.
Lemma 4.2. (Median of means) Let Y1,Y2,…,Yv denote the outputs of v independent runs of an (ϵ,1/3)-estimator for St(A), where v=48⋅ln(1/δ). Let Ymed denote the median of Y1,…,Yv. Then, Ymed is an (ϵ,δ)-estimate of St(A).
Proof. Since Yi is an (ϵ,1/3)-estimate of St(A), with probability at least 2/3, we have Yi∈(1±ϵ)St(A). Let Zi=1 if Yi∈(1±ϵ)St(A), and Zi=0 otherwise. Let Z=∑i=1vZi. Then, E[Z]≥(2/3)⋅v. If Ymed∈/(1±ϵ)St(A), at most v/2 of the Yi's belong to (1±ϵ)St(A), i.e., Z≤v/2. Using Lemma 4.1, we get Pr[Ymed∈/(1±ϵ)St(A)]≤Pr[Z≤v/2]≤e−v/48. For v=48⋅ln(1/δ), this probability is at most δ.
Below, we state two lemma from Beretta and Tětek [BT24] that we use in our lower bounds.
Lemma 4.3. (Lemma 4.3 of [BT24]) Let ϵ<1/3. Let N=n with probability 1/2 and N=(1−ϵ)n otherwise. Consider a random instance of the sum estimation problem (U,w) with ∣U∣=N and w(a)=1 for a∈U. Consider a sample of size m and its fingerprint Fm={(ci,w(ai))}i=1,…,l and define the ratio R(Fm)=Pr[Fm∣N=(1−ϵ)n]Pr[Fm∣N=n]. If m=o(n/ϵ) and m=o(n), then Pr[98/100≤R(Fm)≤100/98]≥99/100 for large enough n.
Lemma 4.4. (Lemma 4.4 of [BT24]) Let 0<ϵ<p and set q=p with probability 1/2 and q=p−ϵ, otherwise. Let X1,…,Xm be a sequence of iid Bernoulli random variables with bias q, and let l=∑i=1mXi∼Bin(m,q). Define the ratio R(Fm)=Pr[l∣q=p−ϵ]Pr[l∣q=p]. Then, for m=o(p/ϵ2), Pr[98/100≤R(l)≤100/98]≥99/100, for p and thus ϵ small enough.
5 Algorithm for Sum Estimation
In this section, we describe an algorithm for computing an (ϵ,δ)-estimate of the sum W of the weights of elements in A and analyze the sample complexity of the algorithm. The algorithm has three phases. In the first phase, the algorithm samples elements using proportional sampling until it observes the first collision1. Let Z denote the set of sampled elements until it observes the first collision. The algorithm obtains an estimate T=1/∣Z∣ for the ∥p∥2 of the sampling distribution p. Next, it checks if there exists an element ai∈A for which pi is sufficiently large, say some constant times ∥p∥2 and if such an element exists, sets S={ai}. If there does not exist such an element in A, it independently samples 1/3000T elements following the distribution p. Let S denote the set of sampled elements during this phase. Let w(S)=∑a∈Sw(a) denote the total weight of the elements
1We say a collision happens when the same element is sampled twice.
in S. In the third phase, the algorithm obtains new samples from A to estimate p^ of w(S)/W. The algorithm computes W=w(S)/p^ as an estimate of W. To bound the sample complexity of the algorithm, we analyze the number of samples needed in each phase. First, we bound the number of samples required to observe the first collision. Next, we show that w(S)/W is sufficiently large, and hence, we can estimate Ww(S) using a small number of samples and use it to estimate W.
Let p denote the proportional sampling distribution for A, and let ∥p∥2 denote the l2 norm of p. We show that the number of samples required to observe a collision is closely related to ∥p∥2. In particular, we show that O(1/∥p∥2) samples are sufficient to observe at least one collision with constant probability. Moreover, for the sample S generated as above, the quantity Ww(S) can be shown to be at least some constant times ∥p∥2 with probability at least 8/9. Therefore, using O(ϵ2∥p∥21) samples, we can obtain a good estimate of Ww(S) with constant probability. The sample complexity of the algorithm is at most O((ϵ2∥p∥21+∥p∥2log1/∥p∥2)log1/δ). Next, we state the main claim for Algorithm 1 and give a formal analysis of its sample complexity.
Claim 5.1. Let 0<ϵ,δ<1. Algorithm 1 gives an (ϵ,δ)-estimate W of W and uses at most O((ϵ2∥p∥21+∥p∥2log1/∥p∥2)log1/δ) proportional samples.
Proof. We bound the number ∣Z∣ of samples required to observe the first collision with constant probability. In particular, for ∣Z∣=Θ(∥p∥21), we show that the first while loop terminates with probability at least 7/8. We prove the following result.
Lemma 5.1. We have Pr[∣Z∣≤24∥p∥21]≤1/16 and Pr[∣Z∣>∥p∥215]≤161. In particular, Pr[1/24⋅1/∥p∥2<∣Z∣≤∥p∥215]≥7/8.
Proof. Using a result of Schulte-Geers and Waggoner [SGW22], we obtain, for any η∈(0,1), Pr[∣Z∣≤max{e2,2ln(η1)}∥p∥22]≥1−η and Pr[∣Z∣≤(eη)∥p∥22]≤η. For η=1/16, we obtain the above result.
For the following, we condition on the event E1 that Lemma 5.1 holds. Let T=1/∣Z∣ be an estimate of ∥p∥2. Conditioned on E1, we have ∥p∥2/15<T<24∥p∥2.
Let q=4⋅3000⋅5762⋅452T. Next, the algorithm decides if there exists a heavy hitter element ai in the instance with pi≥q or for all elements ai, we have pi<q−γ=q/2, where we set γ=q/2. Below, we argue that the algorithm with probability at least 0.98 decides correctly whether there exists such a heavy hitter element in the instance.
Claim 5.2. Algorithm 1 decides correctly whether there exists an element ai with pi≥q or pi≤q/2 for all ai∈A, with probability at least 0.98.
Proof. Suppose there exists an element ai∈A with pi≥q. This element is sampled with probability at least q, and will be included in U with probability at least 1−e−10≥0.99. Using a Chernoff bound argument, using a sample size of at least 192/qln1/q, this heavy hitter element with probability at least (1−q4) will have empirical frequency in V at least q−γ/2. Therefore, Algorithm 1 will output Yes with probability at least 0.98.
Algorithm 1 Sum Estimation using Proportional Sampling
1: procedure SUMESTIMATOR(A, ε, δ)
2: r ← 48 log(1/δ)
3: for s = 1 to r do
4: Z ← ∅
5: while true do
6: Sample element a following distribution p
7: if a ∉ Z then
8: Add a to Z
9: else
10: break
11: T = 1/|Z|
12: ▷Estimate ℓ₂ of p and assign its value to T
13: Let q = 4⋅3000⋅5762⋅452T. Let U be a sample of size 10/q following distribution p.
14: Let V denote a multiset of 192/q · log 1/q independent samples from p.
15: Check if there exists an element ai in U that appears in V with empirical frequency at least q−γ/2, where γ=q/2.
16: if Yes then
17: Set S={ai}.
18: else
19: S ← ∅.
20: for j = 1 to 3000T1 do
21: Sample an element a following distribution p
22: Add a to S
23: l ← ϵ2⋅q24ln(120), h ← 0
24: for i = 1 to l do
25: Sample an element a following distribution p
26: if a∈S then
27: h ← h + 1
28: w(S) ← ∑a∈Sw(a)
29: p←lh
30: Ws←pw(S)
31: return W←median(W1,W2,…,Wr)
Suppose for any element ai in A, we have pi<q−γ=q/2. We need to argue that with high probability, none of these elements appear with significantly higher empirical frequency in V. Let us consider any element ai in U with probability pi<q/2. Using a sample size of 192/qln1/q, and using Chernoff bounds, the probability that its empirical frequency in V is at least q−γ/2 is at most q8. Since there are at most 10/q elements in U, the probability that Algorithm 1 identifies any such element as a heavy hitter is at most 0.01.
Let us condition on event E2 that Algorithm 1 correctly decides if there exists ai such that pmax=maxi=1npi≥q or for any ai∈A, we have pmax<q/2. We have Pr[E2]≥0.98. If Algorithm 1 finds a heavy hitter element ai, it sets S={ai}. Since the algorithm might return anything if q/2<pmax=maxi=1npi<q, the heavy hitter element ai detected by the algorithm will have pi≥q/2. If there does not exist any heavy hitters in the instance, the algorithm samples 1/3000T independent samples following distribution p. Let S denote the set of sampled elements. Since ∣S∣=1/3000T, we have 1/72000≤∣S∣⋅∥p∥2≤1/200.
Claim 5.3. With probability at least 0.99, there are no repeated elements in S.
Proof. Using Lemma 5.1, for η=0.01, with probability at least 0.99, the number of samples required for a collision is at least 1/50e⋅1/∥p∥2. Since we have 15T1<1/∥p∥2, the number of samples in S is at most 1/3000T<1/200⋅1/∥p∥2≤1/50e⋅1/∥p∥2. Hence, with probability at least 0.99, there is no repeated element in S.
Let E3 denote the event that there are no repeated elements in S. For the following, we condition on E3.
Lemma 5.2. We have Pr[Ww(S)≥q/2]>8/9.
Proof. If Algorithm 1 detects a heavy hitter element ai in A, then we have w(S)/W=pi≥q/2. If Algorithm 1 did not detect any heavy hitters, we proceed as follows. We can write Ww(S)=∑ai∈SWw(ai)=∑ai∈Spi. We have pmax=maxipi≤q. Let X be any sample following distribution p. We have E[X]=W⋅∥p∥22. Hence, E[w(S)/W]=∣S∣⋅∥p∥22 and Var[w(S)/W]≤∣S∣⋅∥p∥33. Since pmax≤q, we have ∥p∥33≤q⋅∥p∥22. Using this we can write, Var[w(S)/W]≤∣S∣⋅q⋅∥p∥22≤1/3000T⋅q⋅∥p∥22. The standard deviation of w(S)/W will be at most σ(w(S)/W)≤3000Tq∥p∥2. Using Chebyshev's inequality, with probability at least 8/9, w(S)/W≥E[w(S)/W]−3⋅σ(w(S)/W)≥1/3000T⋅T2/576−3⋅3000Tq⋅∥p∥2. For q=4⋅3000⋅452⋅5762T, we will get with probability at least 8/9, w(S)/W≥2⋅3000⋅576T. Hence, with probability at least 8/9, w(S)/W≥min{q,2⋅3000⋅576T}=q.
We have shown that w(S)/W is at least q/2 with probability at least 8/9. We condition on the event E4 that w(S)/W≥q/2. We will show that p=h/l provides an (ϵ/2,1/60)-estimate of w(S)/W for l=O(ϵ2∥p∥21).
Lemma 5.3. h/l is an (ε/2, 1/60) estimate of w(S)/W for l = O(1/ε²‖p‖₂).
Proof. We obtain independent samples Y1,Y2,…,Yl from A. Now, we define a random variable
hi={10Yi∈Sotherwise
Let h=∑i=1lhi denote the number of sampled elements that belong to the set S. We can write E[h]=∑i=1lE[hi]=∑i=1lWw(S)=l⋅Ww(S). Hence, 1/l⋅E[h]=w(S)/W. Using Chernoff bound, we have Pr[∣h−E[h]∣>ϵ/2⋅E[h]]≤2e−31/4⋅E[h]ϵ2. We have Pr[∣h/l−E[h/l]∣>ϵ/2⋅E[h/l]]≤2e−12E[h]ϵ2. We need to choose l such this probability 2e−12l⋅w(S)/W⋅ϵ2=601. Conditioned on E4, this implies l≥ϵ2q24ln(120). Hence, h/l gives an (ϵ/2,1/60) estimate of w(S)/W and the required sample size is l=O(ϵ2∥p∥21).
We have shown that p^=h/l is an (ϵ/2,1/60) estimator of w(S)/W. Algorithm 1 in iteration s returns Ws=w(S)/p^ as an estimate of W. Next, we show that Ws is an (ϵ,1/3)-estimate of W. First, we show that (1−ϵ)W≤Ws≤(1+ϵ)W, and then we bound the probability that Ws falls outside this range. Using Lemma 5.3, we have (1−ϵ/2)Ww(S)≤lh≤(1+ϵ/2)Ww(S). Rearranging the terms and using p^=h/l and ϵ≤1, we obtain (1−ϵ)W≤Ws≤(1+ϵ)W. Next, we bound the failure probability of the event that Ws∈/(1±ϵ)W. Algorithm 1 fails if either E1 or E2 or E3 or E4 does not hold or if p^ is not an (ϵ/2,1/60)-estimator of w(S)/W. The total failure probability can be bounded as 1/8+1/50+1/100+1/9+1/60≤1/3. Once we have an (ϵ,1/3)-estimate of W, we take r=48log(1/δ) independent copies of this estimator and use Lemma 4.2 to obtain an (ϵ,δ)-estimate of W.
Next, we analyse the sample complexity of our algorithm. The number of samples required to observe the first collision is Θ(1/∥p∥2). Checking whether a heavy hitter element exists requires O(1/qln1/q)=O(∥p∥2ln1/∥p∥2) samples. Estimating w(S)/W requires at most O(ϵ2∥p∥21) samples. Repeating this for at most 48log1/δ times, overall sample complexity is O((ϵ2∥p∥21+∥p∥2ln1/∥p∥2)log1/δ).
6 Algorithm for Moment Estimation
In this section, we design an algorithm for an (ϵ,δ)-moment estimation using weighted sampling. We start by describing the high-level idea of our algorithm. Bhattacharya and Pradhan [BP25] have given an algorithm for an (ϵ,1/3)-moment estimation that for h>1 uses O(n/ϵ+n1−1/h/ϵ2) samples. In this work, we design algorithms for an (ϵ,δ) moment estimation with better sample complexity bounds on an instance to instance basis. First, we observe that the sample complexity of the (ϵ,1/3)-moment estimation algorithm of Bhattacharya and Pradhan [BP25] can be written as O(n/ϵ+ϵ2∥p∥h1). However, since the value of ∥p∥h is not known for the proportional sampling distribution p, we cannot directly use their algorithm. One natural idea is to first estimate ∥p∥h of the distribution p, and then run the algorithm of [BP25] with this estimate. In order to accomplish this, we observe that ∥p∥hh captures the probability of a h-way collision for distribution p. Our algorithm keeps on sampling until it observes the first h-way collision and we show that the expected number of samples required to observe a h-way collision can be written as Θ(h/∥p∥h). Next, we observe that the O(n/ϵ) term in the sample complexity for moment estimation by Bhattacharya and Pradhan appears due to the sum estimation algorithm of [BT24] that the authors use as a subroutine in their algorithm. We use Algorithm 1 to estimate the sum of the weights. The overall algorithm as motivated above can be described as follows. In the first phase, we keep on sampling until we observe a h-way collision. Suppose this requires L samples. In the second phase, we obtain independent O(L/(hϵ2)) samples and run the algorithm of Bhattacharya and Pradhan [BP25] with these samples as input. We will show that Algorithm 2 gives an (ϵ,1/3) estimate of Wh(A) for h>1 and the sample complexity of Algorithm 2 is O(∥p∥hh+ϵ2∥p∥h1+ϵ2∥p∥21+∥p∥2ln1/∥p∥2), where the first phase requires O(∥p∥hh) samples to observe a h-way collision, and the second phase requires O(ϵ2∥p∥h1) samples to estimate Wh(A). Next, we present the algorithm and argue its correctness.
Algorithm 2 Moment Estimation using Proportional Sampling
1: procedure MOMENTESTIMATOR(A, h, ϵ)
2: ϵ1←ϵ/2
3: C[i]←0∀i∈[n]
4: while true do
5: Sample an element ai following distribution p
6: C[i]←C[i]+1
7: if C[i] equals h then
8: break
9: L←∑i=1nC[i]
10: W←SUMESTIMATOR(A,ϵ1,1/8)
11: for j=1 to m=hϵ230720⋅L do
12: Sample an element bj from A following distribution p
13: p~j←Ww(bj)
14: Xj←p~jw(bj)h
15: return X=m1∑j=1mXj
Claim 6.1. Let h>1. Algorithm 2 gives an (ϵ,1/3)-estimate of Wh(A) using O(∥p∥hh+ϵ2∥p∥h1+ϵ2∥p∥21+∥p∥2ln1/∥p∥2) samples.
Proof. Our algorithm has two phases. In the first phase, the algorithm keeps on sampling elements until it observes the first h-way collision2. Let L denote the number of samples required to observe the first h-way collision. Then, using a result of Schulte-Geers and Waggoner [SGW22], we get for any η∈(0,1), Pr[L≤max{e2,2ln(η1)}∥p∥hh]≥1−η and Pr[L≥(eη)∥p∥hh]≥1−η. For η=1/16, this implies that Pr[48∥p∥hh≤L≤∥p∥h8h]≥87. Let E1 denote the event that 48∥p∥hh≤L≤∥p∥h8h, and we have Pr[E1]≥7/8. Conditioned on E1, this phase requires at most Θ(∥p∥hh) samples. The algorithm then obtains an (ϵ/2,1/8)-estimate W of the sum of the weights of A using Algorithm 1.
2A h-way collision happens when an element is sampled h times.
Next, the algorithm obtains m=hϵ230720⋅L=O(ϵ2⋅∥p∥h1) independent samples. Let bj denote the element sampled during iteration j, where bj has weight w(bj) and we set p~j=w(bj)/W and Xj=w(bj)h/p~j. We show that X=1/m∑j=1mXj gives an (ϵ,1/3)-estimate of Wh(A).
Let E2 denote the event that W∈[(1−ϵ1)W,(1+ϵ1)W]. Using Algorithm 1 with δ=1/8, we have Pr[E2]≥7/8. Conditioned on E2, for any element bj∈A, we have 1+ϵ1pj≤p~j≤1−ϵ1pj. We can write E[Xj]=∑a∈Ap~aw(a)h⋅pa. This gives (1−ϵ1)Wh(A)≤E[Xj]≤(1+ϵ1)Wh(A). Since X1,X2,…,Xm are independent random variables, using linearity of expectation, we have E[X]=m1∑j=1mE[Xj]=E[Xj]∈[(1−ϵ1)Wh(A),(1+ϵ1)Wh(A)]. Since X is not an unbiased estimator of Wh(A), we need to bound its variance.
Claim 6.2. For m=ϵ2h30720⋅L≥ϵ2∥p∥h640 and ϵ1=ϵ/2, we have Pr[∣X−Wh(A)∣>ϵWh(A)]≤1/40.
For m=ϵ2h30720⋅L≥ϵ2∥p∥h640 and ϵ1=ϵ/2, the above probability is at most 1/40.
Let E3 denote the event that the estimate X is not in [(1−ϵ)Wh(A),(1+ϵ)Wh(A)], and using the above, we get Pr[E3]≤1/40. Our algorithm fails if either E1 fails or E2 fails or E3 becomes true. Overall failure probability is bounded by 1/8+1/8+1/40≤1/3.
Next, we discuss the sample complexity of Algorithm 2. Our algorithm requires at most O(∥p∥hh) samples in the first phase. We used Algorithm 1 as a subroutine to obtain estimate W of the sum of weights, and for this, Algorithm 1 requires at most O(ϵ2∥p∥21+∥p∥2ln1/∥p∥2) samples. In the final phase, we need O(ϵ2∥p∥h1) samples to estimate the moment Wh(A). Hence, Algorithm 2 gives an (ϵ,1/3) estimate of Wh(A) using O(∥p∥hh+ϵ2∥p∥21+∥p∥2ln1/∥p∥2+ϵ2∥p∥h1) samples.
Using Lemma 4.2, one can convert the above (ϵ,1/3)-estimator into an (ϵ,δ)-estimator using O((∥p∥hh+ϵ2∥p∥21+∥p∥2ln1/∥p∥2+ϵ2∥p∥h1)log1/δ) samples.
7 Lower Bound for Sum Estimation
In this section, we prove a lower bound on the number of samples required to obtain an (ϵ,1/3)-estimate of the sum of the weights of the elements of A using proportional sampling. We start by describing the high level idea of the proof. For every input instance I(A,W), where A denotes the set of input elements and W denotes the sum of the weights of the elements in A, we construct another instance I′(A′,W′) such that the sums of the weights of the elements of the two instances differ by at least a factor of (1±ϵ). We will show that, given a small number of samples, it is not possible to decide whether the samples come from I or I′ with probability at least 2/3. We assume that an adversary chooses instance I or I′ with equal probability, and generates m proportional samples from the chosen instance. Let S denote the (multi) set of m sampled elements. The fingerprint Fm of a sample S is defined as a collection of tuples of the form (ca,w(a)), where for each distinct element a∈S, we have a tuple (ca,w(a)), with ca denoting to the number of times a appears in the sample and w(a) denotes the weight of element a. Since our computational model allows only the following two operations, given two sampled elements deciding whether they are the same and querying for the weight of a sampled element, it is sufficient to consider the fingerprints of the samples rather than the actual samples [BT24].
To show the lower bound, we construct instances I and I′ for which the fingerprints of a small sized sample are similar. In particular, we will show that, if we use only m proportional samples whose fingerprint is denoted as Fm, the probability of observing the fingerprint Fm from instance I is nearly the same as the probability of observing it from instance I′. Let E and E′ denote the events that instances I and I′ are chosen, respectively. Given a (multi)set S of m samples, let Fm denote its fingerprint. We define the following ratio R(Fm).
R(Fm)=Pr[Fm∣E]Pr[Fm∣E′]
If this ratio is close to 1, then we show that the Bayes classifier cannot distinguish between E and E′ with probability at least 2/3. Since the Bayes classifier minimizes the probability of a classification error, it follows that no algorithm using m samples can distinguish between I and I′ with probability at least 2/3. A similar result has been proved as Lemma 13 in [BT24], and we give a short proof of this result for completeness.
Claim 7.1. Given two disjoint events E and E′ such that Pr[E]=Pr[E′]=1/2, and a random variable X, let R(X)=Pr[X∣E]Pr[X∣E′]. If Pr[98/100≤R(X)≤100/98]≥24/25, then any classifier that takes X as input, and classifies E and E′, has error probability at least 1/3.
Proof. Let q=Pr[E∣X] and q′=Pr[E′∣X]. Conditioned on 98/100≤R(X)≤100/98, we have 1/q=(q+q′)/q=1+q′/q=1+Pr[E∣X]Pr[E′∣X]=1+Pr[X∣E]Pr[X∣E′]=1+R(X)∈[198/100,198/98]. Hence, q≤100/198. Similarly, q′≤100/198. The probability of a correct classification is Pr[correct classification∣98/100≤R(X)≤100/98]⋅Pr[98/100≤R(X)≤100/98]+Pr[correct classification∣R(X)∈/[98/100,100/98]]⋅Pr[R(X)∈/[98/100,100/98]]≤1/25+100/198<2/3.
Let the instance I(A,W) be defined as follows. The set A of n input elements can be written as A=A1⊎…⊎At, where for any i∈[t], Ai⊆A denotes the subset of ni elements with weight wi and t∈[n]. We refer to each Ai as a block in A. Note that ∑i=1tni=n and ∑i=1tni⋅wi=W. Given such an instance I(A,W), we create another instance I′(A′,W′) as follows. For each i∈[t], we include all elements of Ai in A′, and add ϵni new elements of weight wi in A′. Let ni′=ni+ϵni. The total number of elements in A′ is ∑i=1tni′=(1+ϵ)n, and the total weight of elements in A′ is given as W′=∑i=1twini′=(1+ϵ)W. Let ki=∥p∥22nipi2. Note that we allow the new elements to be added fractionally, when ϵni is a fraction. 3 Next, we state the main claim that we prove in this section.
Theorem 7.1. Let 0<ϵ≤1 be such that ϵ≥1/ni for all i and let t be a constant. Then, any (ϵ/3,1/3)-estimate of W requires Ω(ϵ∥p∥21) proportional samples.
We defined R(Fm) as the ratio of the conditional probabilities of observing the fingerprint Fm given that we sample m elements from instances I′ and I, respectively. We want to bound the probability of obtaining a particular fingerprint Fm, where Fm={(c1,w(a1)),(c2,w(a2)),…,(cl,w(al))}, where l denotes the number of distinct elements in the sample. Let mi denote the number of sampled elements of weight wi and li denote the number of distinct sampled elements with weight wi. Let an element aj of weight wi be sampled cij times. We have ∑i=1t∑j=1licij=∑i=1tmi=m, and ∑i=1tli=l. Let p and p′ denote the proportional sampling distributions for instances I and I′. The probabilities of sampling an element ai∈A of weight wi from I and I′ are pi and pi′, and hence, the probabilities of observing a sample of weight wi from I and I′ are given as nipi and ni′pi′, respectively. Let Pr[Fm∣E] and Pr[Fm∣E′] denote the conditional probabilities of observing fingerprint Fm from I and I′, respectively. Then, we have
3When ϵni is a fraction, we assume an element can be added fractionally. The weight of the element remains wi, however, the probability of sampling the element will be proportional to ϵwi.
First, we show a bound on mi. We show that with high probability either mi=o(ni/ϵ) or mi≤1. When mi=o(ni/ϵ), using the assumption ϵ≥1/ni, we get mi=o(ni).
Lemma 7.1. Let m=o(ϵ∥p∥21). Then, for all i, either mi=o(ϵni) or mi<2 with probability at least 1−200t1.
Proof. Let Zik be a random variable such that Zik=1 if the kth sample is from Ai and 0 otherwise. Then, Pr[Zik=1]=nipi. Let mi=∑k=1mZik denote the total number of samples from Ai. Let μi=E[mi]=mnipi. We analyze two cases based on μi>10t1 and μi≤10t1. For μi>10t1 and δ=10tlog(200t), using Chernoff bound, we get
For μi≤10t1, we get Pr[mi≥2]≤(2m)ni2pi2≤2μi2≤200t1. Since t is a constant, we have mi≤max{O(μi),1} with probability at least 1−1/200t. For m=o(ϵ∥p∥21), we have μi=mnipi=o(ϵ∥p∥2nipi)=o(ϵni⋅niki)=o(ϵni), where ki=∥p∥22nipi2≤1. Hence, mi≤max{o(ni/ϵ),1} with probability at least 1−1/200t.
We condition on the event E1 that Lemma 7.1 holds simultaneously for all i, and we have Pr[E1]≥1−1/200. Conditioned on E1, we have either mi<2 or mi=o(ni/ϵ)=o(ni), since we assume ϵ≥1/ni for all i. For a fixed value of mi, using Claim 7.2, we can write R(Fm)=∏i=1tR(li), where R(li)=((1+ϵ1)mi−li⋅∏j=0li−1(1+(1+ϵ)(ni−j)ϵj)). In order to show that R(Fm) is close to 1, it is sufficient to prove that R(li) is very close to 1 with high probability for all i=1,2,…,t, and then use a union bound. To show this, we first determine a range for each li. Specifically, we define an interval [ai,bi] for li such that Pr[ai≤li≤bi]>1−200t1. Since R(li) is an increasing function of li, it follows that Pr[R(ai)≤R(li)≤R(bi)]≥1−200t1. In the following, we obtain an interval for li∈[ai,bi] conditioned on mi=r, for some number r. Note that conditioned on mi=r, the random variables corresponding to the samples from the ith block are independent. Before fixing the values of ai and bi, we bound the variance of li. A similar result has been proved as Lemma 4.2 of [BT24]. We state the lemma below.
Lemma 7.2. Let mi=r denote the number of sampled elements of weight wi from the instance I. Let there be li distinct elements of weight wi in the sample. Then, Var[li]≤r2/ni. Similarly, when r elements of weight wi are sampled from A′, the variance of the number of distinct sampled elements of weight wi will be at most (1+ϵ)nir2.
Proof. Let Zij be a {0,1}-valued random variable that takes value 1 if an element aj of weight wi appears in the sample and 0 otherwise. Then, li=∑j=1niZij equals the number of distinct elements of weight wi in the sample. We use the Efron-Stein inequality (Theorem 4.1) to bound the variance of li. Let Xi denote the ith sample. We write li=f(X1,X2,…,Xr). Let X1′,X2′,…,Xr′ be an independent copy of X1,X2,…,Xr, and let lik′=f(X1,X2,…,Xk−1,Xk′,Xk+1,…,Xr) denote the number of distinct sampled elements of weight wi, where the kth sample Xk has been resampled as Xk′. Then, we have
li−lik′=⎩⎨⎧10−1Xk does not collide with any Xj for (j=k) and Xk′ collides with Xj′ for (j′=k),Xk,Xk′ both collide or both are unique,Xk′ does not collide with any Xj for (j=k) and Xk collides with Xj′ for (j′=k).
Pr[(li−lik′)=1]=Pr[(Xkdoes not collide with anyXjfor(j=k))∩(Xk′collides withXj′for(j′=k))]=Pr[Xkdoes not collide with anyXjfor(j=k)]⋅Pr[Xk′collides withXj′for(j′=k)]≤1⋅Pr[∪j′=k(Xk′collides withXj′)]≤j′=k∑Pr[Xk′collides withXj′]=j′=k∑Pr[∪a∈Ai(Xk′=Xj′=a)]≤j′=k∑a∈Ai∑Pr(Xk′=Xj′=a)=(r−1)⋅ni⋅1/ni2≤r/ni.
Similarly, we can show that Pr[(li−lik′)=−1]≤r/ni, and hence E[(li−lik′)2]≤2⋅r/ni. Then, by the Efron-Stein inequality, we get Var[li]≤21∑k=1rE[(li−lik′)2]≤21∑k=1r2r/ni=r2/ni.
Next, we bound the difference between the expected number of distinct sampled elements when we sample mi=r elements of weight wi from I and I′, respectively. We show that, conditioned on mi=r, the difference between the expected number of distinct sampled elements when we sample mi elements of weight wi from instances I and I′ is not large. We state the lemma below.
Lemma 7.3. Let mi denote the number of sampled elements of weight wi, and let li denote the number of distinct elements of weight wi in the sample. Then,
EE′[li∣mi=r]−EE[li∣mi=r]≤O(ϵnir2).
Proof. First, we bound the expected number of distinct sampled elements of weight wi when we sample mi elements from I. Let Zij be a {0,1}-valued random variable that takes value 1 if an element aj of weight wi appears in the sample and 0 otherwise. Then, li=∑j=1niZij equals the total number of distinct elements of weight wi in the sample. Conditioned on sampling r elements from Ai, the probability of a particular element aj in Ai is given as (1−(1−1/ni)r). Hence, EE[li∣mi=r]=ni(1−(1−ni1)r). Using the binomial expansion, we get
Next, we obtain a similar expression for the expected number of distinct sampled elements of weight wi when we sample r elements from Ai′. We have EE′[li∣mi=r]=ni(1+ϵ)(1−(1−ni(1+ϵ)1)r). Using the binomial expansion again, we obtain
Let us set ai=EE[li∣mi=r]−20t⋅r/ni and bi=EE′[li∣mi=r]+20t⋅r/ni, and show that the value of li lies in this range [ai,bi] with probability at least 1−200t1.
Similarly, we can show that Pr[li<ai]≤400t1. Hence, Pr[li∈/[ai,bi]]≤200t1. Hence, Pr[li∈[ai,bi]]≥1−1/200t. Now, ∣bi−ai∣=EE′[li∣mi=r]−EE[li∣mi=r]+40t⋅r/ni. Let E2 denote the event that li∈[ai,bi] for all i, and using a union bound, we have Pr[E2]≥1−1/200. We condition on event E2 for the following. Since ai<li<bi, and R(x) is an increasing function of x, we have R(ai)<R(li)<R(bi) with probability at least 1−200t1≥e−1/100t, where we use the inequality e−x≤1−x/2 for x∈[0,1.59]. First, we obtain an upper bound on R(bi) and a lower bound on R(ai). Since R(li) is an increasing function of li, we can write
Hence, R(bi)≥(1−1/200t)≥e−1/100t. At this point, we have an upper bound on R(ai) and a lower bound on R(bi). We need a lower bound on R(ai) and an upper bound on R(bi) for our analysis. We first obtain an upper bound on ∏li=ai+1biR(li−1)R(li).
Lemma 7.4.
∏li=ai+1biR(li−1)R(li)≤e2ϵ⋅∣bi−ai∣.
Proof. We define R(li)=((1+ϵ1)mi−li⋅∏j=0li−1(1+(1+ϵ)(ni−j)ϵj)), and we can write R(li−1)R(li)=(1+ϵ)(1+(1+ϵ)(ni−li+1)ϵ(li−1))=1+ϵ+(ni−li+1)ϵ(li−1)≤1+ϵ+(ni−mi+1)ϵmi. Conditioned on E1, we have either mi=o(ϵni) or mi<2. When mi=o(ϵni), in conjunction with ϵ>ni1, we have mi=o(ni). In either of the two cases above, we obtain the following bound.
Hence, we have ∏li=ai+1biR(li−1)R(li)≤∏li=ai+1bie2ϵ≤e2ϵ∣bi−ai∣.
Using Lemma 7.4, we obtain R(bi)≤e1/100t⋅e2ϵ∣bi−ai∣ and R(ai)≥e−1/100t⋅e−2ϵ∣bi−ai∣. Conditioned on E2, and using R(Fm)=∏i=1tR(li), we can write
We obtain an upper bound on ∑i=1t∣bi−ai∣. Conditioned on E1, we have either mi≤1 or mi=o(ni/ϵ). When mi≤1, we have ∣bi−ai∣=0. For the following calculations, we consider blocks for which mi=O(μi)=O(mnipi)=o(ni/ϵ), for m=o(ϵ∥p∥21).
Using ∑i=1t∣bi−ai∣=o(1/ϵ), we simplify Equation 1 as follows.
e−1001⋅e−o(1)≤R(Fm)≤e1001⋅eo(1).
Simplifying, we get e−1002≤R(Fm)≤e1002. This gives 10098≤R(Fm)≤98100. We bound the failure probability of the event R(Fm)∈/[98/100,100/98] using a union bound on the events E1 and E2. The failure probability is at most 1/200+1/200≤1/100. Therefore, Pr[R(Fm)∈[98/100,100/98]]≥10099. Using Claim 7.1, it follows that the Bayes classifier cannot succeed with probability at least 2/3 in distinguishing whether the samples are from I or I′. Hence, any algorithm that estimates of W within a (1±ϵ) factor with probability at least 2/3 requires Ω(ϵ∥p∥21) proportional samples on any instance I(A,W).
7.1 Lower bound for large ∥p∥2
We show a Ω(ϵ2∥p∥21) lower bound for the sum estimation problem, when ∥p∥2 is at least a constant and ϵ is not too small. We state the main claim below.
Claim 7.3. For ϵ>1/n, there exist instances I(A,W) with ∥p∥2 being a constant for which any (ϵ,1/3) estimator of the sum of the weights requires Ω(ϵ2∥p∥21) samples.
Proof. Let instance I(A,W) have an element a0 of weight w1 and (n−1) elements of weight w2. We have A=A1∪A2, where A1={a0}. Let n1=∣A1∣=1 and n1⋅w1=c1W, for some constant 0<c1<1, and n2=∣A2∣=n−1 and (n−1)w2=c2W, for some constant c2=1−c1>0. We can also write n1p1=c1 and n2p2=c2. Given such an instance I(A,W), we create another instance I′(A′,W′) as follows. We include a0 and all elements of A2 in A′ and add ϵ2n2 new elements of weight w2 in A′, where we set ϵ2=c2ϵ. Note that the total weight of elements in instance I is W and total weight of elements in I′ is W′=W+ϵ2n2w2=W+c2ϵ⋅c2W=W+ϵW=(1+ϵ)W. As before, we assume the adversary chooses instance I or I′ with equal probability and we have Pr[E]=Pr[E′]=1/2. We define q=Pr[a=a0∣E] and q′=Pr[a=a0∣E′].
q=Wc2W=c2q′=W+ϵWc2W+ϵW≤Wc2W+ϵW=q+ϵ
This gives ∣q−q′∣≤ϵ. Now, we define a random variable
Xi={10Weightofsampleisnotequaltow1otherwise
Then, X=∑i=1mXi denotes the number of sampled elements with weight not equal to w1. We define the ratio R(X)=Pr[X∣E]Pr[X∣E]. Since q is a constant, we can write m=o(1/ϵ2)=o(q/ϵ2). Then, using Lemma 4.4, we get Pr[10098≤R(X)≤98100]≥10099. Let FX denote the fingerprint of the sampled elements other than a0. From the given FX, we can reconstruct the fingerprint of the whole sample Fm by adding the tuple (m−X,w(a0)). Hence, Pr[Fm∣E]=Pr[FX∣E] and Pr[Fm∣E′]=Pr[FX∣E′]. Then,
Then, conditioned on L, we get 96/100≤(98/100)2≤R(Fm)≤(100/98)2≤100/96. Then, using a union bound, the total failure probability can be bounded as follows.
Then, Pr[96/100≤R(Fm)≤100/96]≥94/100. Using a similar argument as Claim 7.1, we can say that the Bayes classifier taking Fm and classifying E and E′ has probability of error at least 1/3. Hence, the Bayes classifier does not succeed with probability at least 2/3 in distinguishing the instances. Hence, any algorithm that estimates W within a (1±ϵ) factor with probability at least 2/3 requires Ω(ϵ21) proportional samples. Since p1 is a constant, ∥p∥2 is also a constant. Hence, we can write lower bound as Ω(ϵ2∥p∥21).
8 Conclusions
We provide an improved algorithm for sum estimation using proportional sampling that on an instance with proportional sampling distribution p, computes an (ϵ,δ)-estimate of the sum of the weights of the elements using O((ϵ2∥p∥21+∥p∥2ln1/∥p∥2)log1/δ) proportional samples. We give an almost matching lower bound of Ω(ϵ∥p∥21) proportional samples for any (ϵ,1/3)-sum estimation problem, assuming for all i∈[t],ϵ≥1/ni and t is a constant. We also provide an algorithm that computes an (ϵ,δ)-estimate of the h-th moment of the weights of the elements using O((∥p∥hh+ϵ2∥p∥21+∥p∥2ln1/∥p∥2+ϵ2∥p∥h1)log1/δ) proportional samples.
9 Acknowledgment
Anup Bhattacharya acknowledges the support from the SERB, CRG grant (CRG/2023/002119).
10 AI Usage disclosure
All the main ideas of the paper were generated by the authors. The paper is written entirely by the authors. We used Gemini 3.1 Pro and ChatGPT 5.6 Luna to go over our draft and report any inconsistencies. The responses were used to improve the writing of the paper, in particular, some parts of our sum estimation algorithm and the lower bound.
References
[AMS99] Noga Alon, Yossi Matias, and Mario Szegedy. The space complexity of approximating the frequency moments. J. Comput. Syst. Sci., 58(1):137–147, 1999.
[BC17] Tugkan Batu and Clément L Canonne. Generalized uniformity testing. In 2017 IEEE 58th Annual Symposium on Foundations of Computer Science (FOCS), pages 880–889. IEEE, 2017.
[BCS26] Lorenzo Beretta, Deeparnab Chakrabarty, and C Seshadhri. Faster estimation of the average degree of a graph using random edges and structural queries. In Proceedings of the 2026 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 939–971. SIAM, 2026.
[BLM13] Stéphane Boucheron, Gábor Lugosi, and Pascal Massart. Concentration Inequalities: A Nonasymptotic Theory of Independence. Oxford University Press, 2013.
[BP25] Anup Bhattacharya and Pinki Pradhan. Improved sublinear-time moment estimation using weighted sampling. In Algorithms and Complexity, pages 170–186, Cham, 2025. Springer Nature Switzerland.
[BT24] Lorenzo Beretta and Jakub Tětek. Better sum estimation via weighted sampling. ACM Transactions on Algorithms, 20(3):1–33, 2024.
[DGPP19] Ilias Diakonikolas, Themis Gouleakis, John Peebles, and Eric Price. Collision-based testers are optimal for uniformity and closeness. Chic. J. Theor. Comput. Sci, 25:1–21, 2019.
[ERS18] Talya Eden, Dana Ron, and C Seshadhri. On approximating the number of k-cliques in sublinear time. In Proceedings of the 50th annual ACM SIGACT symposium on theory of computing, pages 722–734, 2018.
[ERS19] Talya Eden, Dana Ron, and C Seshadhri. Sublinear time estimation of degree distribution moments: The arboricity connection. SIAM Journal on Discrete Mathematics, 33(4):2267–2285, 2019.
[MPX07] Rajeev Motwani, Rina Panigrahy, and Ying Xu. Estimating sum by weighted sampling. In ICALP, pages 53–64, 2007.
[MU17] Michael Mitzenmacher and Eli Upfal. Probability and computing: Randomization and probabilistic techniques in algorithms and data analysis. Cambridge university press, 2017.
[SGW22] Ernst Schulte-Geers and Bo Waggoner. Balls and bins—simple concentration bounds. arXiv preprint arXiv:2205.14494, 2022.