Abstract 1 Introduction 2 Local sampler for product distributions 3 Sampling 𝒑-biased distributions from static dictionary 4 A lower bound for a 2-local construction with 𝒎=(𝟐ϵ)𝒏 5 A 3-local construction with 𝒎=1.99𝒏 that is 𝟏/poly(𝐧)-close to Ber(𝟏/𝟒)𝐧 6 A lower bound on 3-local constructions with 𝒎=(𝟐ϵ)𝒏 7 A 𝟒-local construction with 𝒎=1.75𝒏 that is 𝐞𝐱𝐩(𝒄𝒏)-close to Ber(𝟏/𝟒)𝐧 References

Local Samplers for Product Distributions

Jordan Horacsek Simon Fraser University, Burnaby, Canada    Chin Ho Lee ORCID North Carolina State University, Raleigh, NC, USA    Igor Shinkar ORCID Simon Fraser University, Burnaby, Canada    Emanuele Viola ORCID Northeastern University, Boston, MA, USA    Renfei Zhou ORCID Carnegie Mellon University, Pittsburgh, PA, USA
Abstract

We obtain several results on sampling product distributions in a local and randomness-efficient fashion:

  1. 1.

    Let D=(D1,D2,,Dn) be a product distribution where the Di have constant support and have dyadic probability masses (i.e., of the form a/2b where a,b are integers). Then D can be sampled in constant time in the bit-probe model (equivalently, in NC0) and randomness complexity (h(D)+ϵ)n, up to an exponentially small statistical error. The dyadic requirement is necessary.

  2. 2.

    Every p-biased distribution can be sampled in constant time in the cell-probe model with randomness complexity h(p)n+npolylog(n), up to a polynomially small statistical distance.

  3. 3.

    We determine the tradeoffs between locality and statistical distance for sampling the 1/4-biased distribution using non-trivial randomness complexity (e.g., 1.99n). For 2 bit probes, essentially no non-trivial approximation is possible; for 3 bit probes, we give a sampler with 1/poly(n) statistical distance and show that this is best possible; finally, 4 bit probes suffice for exponentially small distance.

Our constructions rely on pseudorandom distributions that are bounded uniform on average. These distributions are obtained using various tools from low-density parity-check codes, and recent results on succinct and retrieval data structures by Hu, Liang, Yu, Zhang, and Zhou (STOC 2025).

Keywords and phrases:
Sampling, Succinct data structures, Pseudorandomness
Category:
Track A: Algorithms, Complexity and Games
Funding:
Emanuele Viola: Supported by NSF grant CCF-2430026.
Renfei Zhou: Supported in part by Jane Street Graduate Research Fellowship and MongoDB PhD Fellowship.
Copyright and License:
[Uncaptioned image] © Jordan Horacsek, Chin Ho Lee, Igor Shinkar, Emanuele Viola, and Renfei Zhou; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Pseudorandomness and derandomization
; Theory of computation Data structures design and analysis ; Theory of computation Computational complexity and cryptography
Related Version:
Full Version: https://eccc.weizmann.ac.il/report/2025/164/
Acknowledgements:
We thank the conference reviewers for their comments. Chin Ho Lee is grateful to Cheuk Ting Li for helpful discussion, in particular for pointing out [31] and the references on source simulation.
Editors:
Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele Puppis

1 Introduction

Shannon’s source coding theorem [40], see for example [12, Theorem 3.2.1], says that n i.i.d. samples from a source 𝒟 can be compressed into about nH(𝒟) bits, from which the samples can be decoded with high probability. In Shannon’s original result, the decoder is not explicit; efficient source decoding algorithms were developed in subsequent works (see, for example, [35] and the references therein).

However, source coding places no requirement on the statistical distance between the decoder’s output distribution and the source distribution. Later, Knuth and Yao [31] initiated the study of “source simulation,” more commonly known as sampling. Formally, given a distribution 𝒟, say supported on {0,1}w, the goal is to design a mapping f:{0,1}m{0,1}w such that for a uniformly random 𝒙{0,1}m, the distribution of f(𝒙) is equal (or close) to 𝒟. Knuth and Yao proved optimal bounds on the expected number of uniform bits required for this task.

By a simple concentration argument, one can extend their result to construct samplers for n i.i.d. samples from any distribution 𝒟 with worst-case randomness complexity close to the information-theoretic optimum nH(𝒟). The sampling question has since been studied extensively in both information theory and computer science theory, leading to time- and space-efficient samplers in various settings. We refer readers to [32, Chapter 9] for a brief survey, and to [16] for a summary of more recent developments.

However, achieving randomness complexity close to nH(𝒟) using samplers that run in constant time per output symbol has proved elusive. Somewhat surprisingly, we show that this is possible in various settings. For example, Theorem 1 establishes such a result in the bit-probe (a.k.a. NC0) model for any dyadic source, a restriction that prior work has shown to be necessary.

More broadly, a main motivation for this paper arises from the study of the complexity of distributions. We now elaborate on this perspective and then present our results.

Recent years have witnessed substantial progress on understanding the complexity of sampling distributions, motivated in part by earlier work showing that sampling can be easier than computing. In contrast to the standard task of computing a function, sampling does not require f to output any specific value on a given input x; rather, the focus is solely on the distribution induced by f(𝒙) when 𝒙 is chosen uniformly at random.

For a concrete example, consider the parity function. While classical results in the 80s [24, 41] showed that 𝐀𝐂0 circuits have small correlation with the parity function, the works [2, 8] showed that the uniform distribution on n-bit strings with the same parity can be sampled exactly by the following 2-local function on n1 bits:

(x1,,xn1)(x1,x1x2,x2x3,,xn2xn1,xn1).

Other surprising examples include sampling the inner-product mod 2 function [27] and random permutations [34, 22, 42]. For background and more discussion we refer the readers to [42].

The work [42] initiated a study of the complexity of sampling using restricted computational models and established several lower bounds. Since then, a large body of works have established many exciting unconditional results on sampling distributions in several restricted models, including local functions [42, 45, 17, 28, 29, 30], small-depth circuits [33, 4], one-way space-bounded computation [9], and communication protocols [20, 50]. By now, this line of research has found a wide range of applications in various areas such as randomness extractors [43, 10, 11], data structures [42, 45, 50, 1], low-distortion embeddings [5, 7], quantum and classical separation [48, 21], and coding theory [39]. In fact, jumping ahead, this work will also further develop some of these connections (in particular, to data structures). We refer the readers to the blogpost [46] for more details on these connections.

In this work, we study the complexity of sampling product distributions. The special case of p-biased distributions on n bits, denoted Ber(p)n, is already omnipresent in computer science. For example, the complexity of sampling p-biased distributions has been studied in a series of recent works including [45, 17, 28, 29]. Some of the motivation for this line of research comes from a connection with data structures from [42], discussed more below. Such distributions also arise as noise or random restrictions in various areas ranging from distributed computing, to Boolean function analysis, coding theory, randomized algorithms, and learning theory. For example, in cryptography the Learning Parity with Noise (LPN) problem [6] or its cousin the Learning With Errors (LWE) problem [38] are considered standard hardness assumptions. Instantiation of cryptographic primitives based on these assumptions typically requires perturbing a binary vector with p-biased noise. Hence very efficient (or parallel) implementations typically require correspondingly efficient ways to sample such noise. In pseudorandomness, recent approaches to constructing generators involve summing bounded-independence generators with p-biased distributions, see the monograph [25] and the works [13, 14]. Again, efficient implementations of these generators require efficient samplers for p-biased distributions.

Our main interest in this work is to understand the tradeoffs between locality, input length which we also call seed length or randomness complexity, and statistical distance for sampling product distributions.

To illustrate, let us consider the task of sampling the 1/4-biased distribution on n bits, denoted Ber(1/4)n. On the one hand, the distribution Ber(1/4)n can be sampled with randomness complexity 2n and locality 2. This trivial construction partitions the 2n input bits into n pairs, and for each pair computes AND of the two bits. On the other hand, the result by Knuth and Yao [31] implies that any p-biased distributions on n bits can be sampled with randomness complexity h(p)n+on(1), where h(p)plog2(1/p)+(1p)log2(1/(1p)) is the binary entropy function, which is best possible. However, their result and follow-up works do not take locality of sampling algorithm into account. It is natural to ask whether one can simultaneously achieve small locality and low randomness complexity. This question was explicitly posed in a blog post [44] nearly a decade ago; yet, to the best of our knowledge, the tradeoffs involved remain poorly understood. In particular, the following basic question has remained open:

Can you sample Ber(1/4)n with constant locality and randomness complexity

(h(1/4)+ϵ)n?

Can you even get randomness complexity 1.99n with constant locality?

1.1 Our results

We resolve the aforementioned basic question in the affirmative. Somewhat surprisingly, we show that with constant locality we can sample any product distribution (in particular, Ber(1/4)n) with nearly optimal randomness complexity. This result requires the distribution to be dyadic, i.e., all probability masses are of the form a/2b for integers a,b. The dyadic requirement is necessary: for example, Ber(1/3)n cannot be sampled locally, even approximately. This follows from the techniques in [45], though the result there is stated for the Hamming slice; alternatively, see [28, Theorem 1.10]. Thus, our results illustrate a stark contrast between sampling Ber(p)n for dyadic and non-dyadic values of p. Henceforth, we denote statistical distance by dist.

Theorem 1 (Special case of Theorem 8).

Let D=(D1,D2,,Dn) be a product distribution where each Di is dyadic and supported on {0,1}w. For every ϵ>0, there is a Ow,ϵ(1)-local f with input length H(D)+ϵwn such that dist(f(U),D)eΩw,ϵ(n).

By increasing the locality to O(logn), we can approximate any distribution by a dyadic one and sample any arbitrary product distribution to within distance 1/poly(n) (see Corollary 9).

The above result is in the bit-probe model. Our next result is in the cell-probe model, where the input randomness is organized in words of O(logn) bits, and one probe reads an entire word. We show how to sample Ber(p)n with randomness complexity h(p)n+O~(n) to within distance 1/poly(n), in constant time.

Theorem 2.

The distribution Ber(p)n can be sampled using h(p)n+npolylog(n) uniform bits within statistical distance 1/poly(n) with O(1) word-probes.

Returning to the bit-probe model, recall the trivial sampler of Ber(1/4)n that is 2-local and uses randomness complexity 2n. We ask ourselves what can be achieved using constant locality and non-trivial randomness complexity (2ϵ)n. We determine the tradeoff between locality and statistical distance: For 2 bit-probes, no non-trivial approximation is possible; for 3 bit-probes, we give a sampler with 1/poly(n) error and show that this is best possible; finally, 4 bit-probes suffice for exponentially small distance. We state these results in two theorems, the first focusing on negative results, the other on positive.

Theorem 3 (Theorem 19 and Theorem 25).

For ϵ>0 and f:{0,1}(2ϵ)n{0,1}n be any d-local function. We have

dist(f(U),Ber(1/4)n){1eΩ(n)if d=2nO(1)if d=3.
Theorem 4 (Theorem 23 and Theorem 28).

For d{3,4}, there is an ϵ>0 and a d-local sampler f:{0,1}(2ϵ)n{0,1}n such that

dist(f(U),Ber(1/4)n){nΩ(1)if d=3eΩ(n)if d=4.

Our constructions are explicit in the following sense. The claimed samplers (viewed, for example, as circuits) can be constructed by an efficient randomized algorithm, with a small error probability. Jumping ahead, the error probability arises from the need of constructing certain matrices (cf. Lemma 11) for which we do not know of a deterministic construction. However, at least in the cell-probe model we also obtain a deterministic construction of the sampler (see full version of this paper).

While we have focused on product distributions, we mention that a body of works has established strong negative results for sampling distributions in NC0 or even AC0 regardless of the input length of the sampler. For example, [33] has shown the existence of linear maps that cannot be sampled in AC0. Still, there remains some interesting open questions. For example, it would be interesting to sample random walks on graphs (equivalently, Markov chains), a problem studied in [47].

1.2 Proof overview

We now give an overview of the proofs. We focus on sampling Ber(1/4)n, which captures all the key ideas in our arguments.

Broadly speaking, we obtain Theorems 1 and 2 by concatenating independent blocks of local samplers with variable input lengths that are close to optimal on average, followed by sampling their inputs locally and randomness-efficiently. The latter relies on sampling distributions that are bounded-uniform in an average-case sense. Henceforth, we call a sampler for each block a block-sampler.

Overview of Theorem 1

A building block of our construction is a (possibly inefficient) block-sampler of Ber(1/4)b with expected randomness complexity close to the optimal h(1/4)b. Such construction dates back to the work of Knuth and Yao [31]. To illustrate the basic idea, consider sampling one bit, i.e., Ber(1/4)1. We can do so as follows. First, read an input bit. If it’s 0, output 0; otherwise, read another input bit and output it. This samples perfectly Ber(1/4)1. While in the worst case we use a trivial randomness complexity 2, the expected number of input bits read is only 1.25, which is much better. This idea can be realized using a prefix-free encoding so that the expected number of bits read is close to optimal.

Given such a block-sampler, we divide the n output bits in blocks of length b=Oϵ(1), and consider sampling each block with an independent copy of the block-sampler. By concentration inequalities, with high probability over the randomness of the input bits, the actual number of random bits used to sample a typical output is close to optimal.

We next derandomize this construction. To do so, we sample the inputs to the block-samplers pseudorandomly via a local linear transformation. Specifically, we take a nearly optimal number of uniform bits and multiply them by a sparse matrix that expands them into input bits of the block-samplers.

The key property we need from the matrix is that most small subsets of its rows, corresponding to the coordinates read by the block-samplers, are linearly independent. This condition is strictly weaker than bounded uniformity, which requires every small subset of rows to be linearly independent. Indeed, the Plotkin bound implies that no matrix satisfying the stronger requirement can achieve optimal seed length. So exploiting this weaker condition is crucial in our construction.

Although the required matrix property seems relatively basic, we are not aware of any result in the literature that can be applied directly. So, we give a self-contained analysis showing that a suitable random construction satisfies this property with high probability.

Overview of Theorem 2

Theorem 2 is obtained via a new connection between sampling and succinct data structure. While a link between these two areas was already observed in [42] (see Claim 6 below) and used in a number of following works, our connection is different. The work [42] pointed out that a succinct data structure is immediately a non-trivial sampler, but the statistical distance can be quite large and close to 1. This connection can be used to establish data-structure lower bounds from sampling lower bounds that rule out even such large statistical distance, but it is not clear how one can use it to obtain useful samplers, even with statistical distance 1/2. Indeed, we are not aware of any construction of samplers that is based on data structure. Moreover, as our target distribution is not uniform on a set, it is not clear we can use any existing data structure directly in a blackbox way. Instead, we leverage and adapt the techniques used in recent exciting progress on the set membership (and dictionary) data structure problems [26], in particular the use of retrieval data structures.

To explain we begin with a key concept, originating in [37] (see also [15]).

Definition 5 (Spillover representation).

Given an injective map from a set S to {0,1}M×[K], the spillover representation of an element in S is its corresponding element (m,k){0,1}M×[K], where k is called the spill.

The work [42] observed the following connection between sampling the uniform distribution over a set and membership data structure.

Claim 6.

Suppose a set of n keys in a universe U can be represented by a spillover representation (m,k){0,1}M×[K] with M+log2Klog2(Un)+ϵ. Then a uniform key can be sampled from {0,1}M×[K] with error ϵ.

Proof.

The error is at most the probability that a uniform element from {0,1}M×[K] is not a spillover representation of any keys. Using 11/xlog2x for x>0, this probability is

1(Un)2MKlog2(2MK(Un))ϵ.

We divide the n bits into blocks of B=polylog(n) bits, as opposed to Oϵ(1) bits in Theorem 1. To sample a block with constant word-probes, we now use a succinct membership data structure by Yu [49]. It shows that one can represent B-bit strings of Hamming weight s by spillover representations in {0,1}M×[K] so that each string can be retrieved using O(1) word-probes to the representation. Moreover, the redundancy M+log2Klog(Bs) is 1/poly(n) small.

A critical point here is that to sample Ber(1/4)B, the weight s is not fixed, but a random variable distributed according to the binomial distribution Bin(B,1/4). Consequently, both M and K are random variables induced by s.

To sample Ber(1/4)B, as in [26] we encode a distribution that is close to Bin(B,1/4) into the first O(1) words in each representation with a 1/poly(n) increase in redundancy. This gives us a block-sampler for Ber(1/4)B: we first sample the first O(1) words to determine the Hamming weight 𝒔, followed by sampling a uniform string of Hamming weight 𝒔 using the spill representation in {0,1}M(𝒔)×[K(𝒔)]. One can show that M(𝒔)+log2K(𝒔)h(1/4)B+1/poly(n) in expectation over 𝒔. Now we can apply Claim 6 to obtain a O(1)-word-probe block-sampler for Ber(1/4)B.

Our plan is to concatenate the Ln/B independent copies of the block-sampler to sample the n bits. However, as the size of a representation depends on 𝒔, sampling the L representations (𝒎i,𝒌i){0,1}M(𝒔i)×[K(𝒔i)] together with small redundancy becomes a challenge. The issue here is what we alluded to before. The M(𝒔i) and K(𝒔i) are both random variables, so we need to put together data structures of varying length, which is not obvious: where are the relevant input bits for a specific output bit?

The work [26] addressed this challenge using augmented retrieval data structure. We will not define it here, but the key observation behind their construction is that the random variable M(𝒔) typically is at least Mminlog(BB/4B2/3)=h(1/4)BΘ(B1/3), which is much larger than its deviation Δmaxlog2(BB/4)Mmin=O(B1/3). Based on this observation, [26] constructs random sparse matrices to concatenate the L representations with polylog(n) redundancy. Here, we use the same random sparse matrices to sample the L spillover representations for the block-samplers. However, unlike [26], our construction does not achieve polylog(n) redundancy, because in contrast to the data structure setting, a (local) sampler cannot first sample the sizes M(𝒔) (and K(𝒔)) for the L block-samplers and then decide which portions of input bits are read by each block-sampler.

Also, the data structure in [26] requires switching between spillover representations over symbols with different alphabet sizes with small redundancy. In the sampling setting, we also have to ensure these transformations also maintain closeness to the uniform distribution (see Lemma 14).

We refer the readers to Section 3.3 for more details.

Overview of Theorem 3 and Theorem 4

Our 2-local lower bound is based on a win-win argument. Given a sampler f:{0,1}m{0,1}n where m=(2ϵ)n. We consider the bipartite graph representing the input-output dependency of f.

Suppose there is a subset of m inputs which connects to n100m neighbors, then for every fixing of these input bits, f restricted to the n bits is a 1-local, which can be shown to be exponentially far from Ber(1/4)n, and this remains so after summing over all 2m fixings of the inputs.

Therefore, if m=Ω(n), then the result follows. Otherwise, by removing these input vertices and their neighbors, we are left with a 2-local map from (2Ω(ϵ))n′′ bits to n′′=Ω(n) bits where every input has bounded degree. So we can decompose the outputs into Ω(n) groups so that each group depends on disjoint inputs. We show that each group has some constant distance away from the 1/4-biased distribution. So the overall distance is at least 1eΩ(n).

Our 3-local lower bound (Theorem 25) is shown by finding a set of output coordinates of size k=O(log(n)) which depend on at most 2k1 inputs. Indeed, by granularity it follows that we see all zeros on these k coordinates with probability either 0 or at least 2(2k1)=24k, while Ber(1/4)k outputs all zeros with probability 14k. Therefore, the statistical distance of our sampler to Ber(1/4)n is at least 14k. In order to find such a set, we consider the bipartite graph representing the input-output dependency of the sampler. Noting that the degree of each output vertex is at most 3, the problem essentially reduces to finding a cycle of length O(logn) in any graphs whose average degree is bounded above by 2.

The construction of our 3-local and 4-local samplers (Theorem 4) is inspired by the recent iterative framework in constructing pseudorandom generators [25]. Recall that the output of the trivial 2-local sampler is the bitwise AND xny for two independent uniform n-bit strings x and y. The work [23] suggested the following equivalent view of xny.

Claim 7.

Let 𝒙,𝒚{0,1}n be independent, where 𝒙 is uniform. Then

dist(𝒙n𝒚,Ber(1/4)n)Pr𝑺[n][𝒚𝑺 is not uniform on {0,1}𝑺].
Proof.

We can think of sampling Ber(1/4)n by first sampling a uniform 𝒙 follows by sampling an independent uniform string on the subset 𝑺 of the 1-coordinates of 𝒙.

Therefore, to get close to Ber(1/4)n, it suffices for 𝒚 to be uniform on a uniform subset 𝑺 of its n coordinates with high probability. To generate such 𝒚, our 3-local sampler assigns each yi to two input bits zi,zi according to a 3-regular expander graph G, where yi corresponds to the edge (zi,zi). Then we let yi be zizi. To analyze the construction, we show that a random subgraph of G has no cycle with probability 11/poly(n). That means the yi’s are uniform when restricted to most subsets chosen by x, and the result follows.

Our 4-local sampler construction follows the same idea. Again, we use n uniform bits to select a random subset 𝑺[n]. Then to sample 𝒚, we use a 3-local LDPC code by Gallager [18] instead of an expander. By analyzing the weight distribution of the code, we show that a random subset of rows in the corresponding parity-check matrix is full rank with probability 1eΩ(n).

2 Local sampler for product distributions

In this section, we prove Theorem 1.

Theorem 8.

Let q be an integer and D1,,Dn be n distributions on {0,1}w, where the probability Di(s) is an integer multiple of 2q for every i[n] and s{0,1}w. Let D=D1××Dn be the product distribution of the Di’s.

For every ϵ>0, there exists a sampler f:{0,1}m({0,1}w)n with input length mH(D)+ϵqn and locality O(qϵ2log(1ϵ)) such that dist(f(Um),D)<2Ω(ϵ3nq2). The sampler f is adaptive, in the sense that for each output query, f makes O(qϵ2log(1ϵ)) sequential queries to the inputs, where each query may depend on the previous queries.

The following is an almost immediate corollary from Theorem 8.

Corollary 9.

Let D1,,Dn be n distributions on {0,1}w for w=O(logn). The product distribution DD1××Dn can be sampled using H(D)+O(nlogn) bits with locality O(logn) and error 1/poly(n).

Proof.

We can approximate each Di with a distribution Di whose probability masses are integer multiples of 2(w+log2(n/γ)) such that |Di(s)Di(s)|2γn2w for all s{0,1}w, and in particular dist(Di,Di)γ/n for all i[n] (cf. [42, Lemma 5.2]). Setting γ=1/nC for a sufficiently large constant C, the two distributions D and DD1××Dn are 1/poly(n)-close in total variation distance. Note that for each i[n] we have

H(Di)H(Di)s{0,1}w|Di(s)log2(1Di(s))Di(s)log2(1Di(s))|.

Since |Di(s)Di(s)|2γn2w, each term in the sum is at most 2γn2wlog2(n2w2γ), and hence

H(Di)H(Di)+2w2γn2wlog2(n2w2γ)=2γnlog2(n2w2γ).

Therefore, H(D)H(D)+1/poly(n), and the corollary follows by applying Theorem 8 on D.

We now turn to the proof of Theorem 8. We first apply the following lemma, which is a special case of [31], which gives optimal bounds on the average-case randomness complexity of sampling an arbitrary distribution.

Lemma 10 ([31]).

Let D be any distribution on {0,1}w, where there is some q such that D(s) is an integer multiple of 2q for all s{0,1}w. Then D can be sampled exactly by a decision tree f:{0,1}q{0,1}w, where the expected depth of a leaf is at most H(D)+2.

Lemma 10 and its more general statement in [31] follows from an application of Kraft’s inequality. (A proof can be found in [32, Theorem 55].) For the proof of Theorem 8, we also need a sparse matrix with the following properties.

Lemma 11.

Fix k and a sufficiently small α>0. Let dln(1/α)/α and mmax{k12h(α),αn}. Let 𝒮 be any distribution supported on subsets S[n] of size k. There exists a matrix M𝔽2n×m with at most d ones in each row, such that if we sample a subset of its rows 𝐒 according to 𝒮, then the corresponding submatrix M𝐒𝔽2k×m is full rank with probability at least

Pr𝑺𝒮[M𝑺 is full rank]12Ω(αlog(1α)n).
 Remark 12.

In Lemma 11 we are looking for a matrix M such that most subsets of k rows are linearly independent, where most is with respect to the distribution 𝒮. We note that with the required parameters we cannot possibly hope for a binary matrix where any k rows are linearly independent, as such matrix would correspond to a parity-check matrix of a linear error correcting codes with block length m, minimum distance k, and dimension at least mk, which is impossible over small alphabet (e.g., by Plotkin’s bound, stating that a linear code of length m with minimum distance k has dimension at most m2k+o(1)).

The proof of Lemma 11 is available in the full version of the paper.

Proof of Theorem 8.

Divide the Di’s into n/t blocks each of size t=8/ϵ. Let D(j) be the product of the Di’s in the j-th block. Note that D(j) is supported on {0,1}tw and its probability mass on each outcome is an integer multiple of 2qt. We first apply Lemma 10 to sample each D(j) independently with a qt-local block-sampler using qt bits. Let f:{0,1}qn{0,1}wn be the concatenation of the n/t block-samplers. We will sample the qn-bit input of f pseudorandomly by applying the sparse matrix from Lemma 11 to a seed of some length m.

For each input z{0,1}qn of f, let Sz[qn] denote the subset of positions read by f to evaluate f(z){0,1}wn. We emphasize that Sz are the only positions read by f to evaluate f(z). Note that Sz can be written as Sz=Sz1Szn/t, where Szj{(j1)t+1,(j1)t+2,,jt} is the subset of bits read by the j-th block-sampler. By Lemma 10, for a uniform 𝒛{0,1}qn, we have 𝔼[|S𝒛j|]H(D(j))+2 for every j[n/t]. Therefore,

𝔼𝒛[|S𝒛|]i=1n/tH(D(j))+2(n/t)H(D)+(ϵ/4)n.

Let kH(D)+(ϵ/2)n. By Hoeffding’s inequality, we have

Pr[|S𝒛|k]Pr[|S𝒛|𝔼z[|Sz|]+ϵn/4]eΩ((ϵn)2(n/t)(qt)2)eΩ(ϵ3q2n).

Define α>0 so that 112h(α)=(1+ϵ/2) (and therefore α=Θ(ϵ/log(1/ϵ)). Let

mk112h(α)=k(1+ϵ2)=(H(D)+ϵn2)(1+ϵ2)H(D)+ϵqn,

where the last inequality follows from H(D)log2(|supp(D)|)qn.

Let M be the qn×m matrix obtained by applying Lemma 11 with 𝒮 equal to the distribution of S𝒛 conditioned on |S𝒛|k and our choice of α. Our sampler f:{0,1}m{0,1}wn takes an input x{0,1}m and output f(Mx).

Clearly the input length of f is m=H(D)+ϵn. The locality of f is at most qtd=O(qϵ2log2(1ϵ)), where d=O(log(1/α)/α)=O(log2(1/ϵ)/ϵ) is row-sparsity of M given by Lemma 11.

We now analyze the error. By Lemma 11, we have

Pr𝒛[MS𝒛 is full rank|S𝒛|k]12Ω(αlog(1α)qn)12Ω(ϵqn).

Let us condition on the event that both |S𝒛|k and MS𝒛 is full rank. Then for a uniformly random input 𝒙{0,1}m to f, the k bits in the coordinates in S𝒛 of M𝒙 are uniformly random, and thus in each of the n/t blocks the output is distributed according to D(j). Therefore,

dist(f(Um),D)Pr𝒛{0,1}qn[|S𝒛|k]+2Ω(ϵqn)eΩ(ϵ3q2n),

as required.

3 Sampling 𝒑-biased distributions from static dictionary

In this section we prove Theorem 2, restated below.

Theorem 2. [Restated, see original statement.]

The distribution Ber(p)n can be sampled using h(p)n+npolylog(n) uniform bits within statistical distance 1/poly(n) with O(1) word-probes.

In Section 3.1, we establish several claims that will be used in our construction. In Section 3.2, we show how to construct a local block-sampler with near-optimal average-case randomness complexity. In Section 3.3, we show how to concatenate these block-samplers in a local fashion.

3.1 Changing bases

In this subsection, we establish local transformations between uniform distributions on sequences over different domains with little overheads and errors.

Claim 13.

The uniform distribution over [K] can be sampled by m elements in [q] with error K/qm.

Proof.

We think of [q]m as {0,,qm1}. Given a uniform 𝒖{0,,qm1}, we output 𝒖K. The statistical distance is at most the probability that 𝒖 lies in the last qmmodK elements, which is at most K/qm.

Lemma 14.

Given p,qpoly(n), there is a function f:[q]m[p]n such that

  • mnlogqp+O(logqn);

  • each output coordinate depends on O(logqn) many input coordinates;

  • for every subset S[n], if the coordinates f(U)S depends on are ϵ-close to uniform, then f(U)S is (ϵ+1/poly(n))-close to uniform over [p]S.

Proof.

We modify the proof in [15, Section 4] as follows. They showed that one can represent xp[p]n by a spillover representation (xq,y)[q]m×[K] where K=poly(n) and

mlog2q+log2Knlog2p+1poly(n).

Moreover, each element of [p]n only depends on O(logqn) coordinates of [q]m×[K]. It follow from Claim 6 that the uniform distribution on [p]n can be sampled from the uniform distribution on [q]m×[K] with error 1/poly(n), with each output coordinate depending on at most O(logqn) of the input coordinates. Finally, we use Claim 13 to sample the uniform distribution over [K] using O(logqn) elements of [q] with error 1/poly(n).

3.2 Sampling 𝒑-biased distributions on polylog bits

In this subsection, we show how to sample polylog(n) many p-biased bits with O(1)-word probes.

Theorem 15.

Let Bpolylog(n) and C>0 be any constant. The distribution Ber(p)B can be sampled from {0,1}𝐌×[𝐊] with error 1/poly(n), where 𝐊poly(n), with the following properties:

  • A distribution supported on [pBB2/3,pB+B2/3] that is nΩ(C)-close to Bin(B,p) can be sampled using the first tClog2n bits of {0,1}𝑴.

  • Given a sample 𝒔, the lengths M𝒔𝑴 and K(𝒔)𝑲 are fixed and

    𝔼𝒔[M(𝒔)+log2K(𝒔)]h(p)B+1nC.
  • Given both 𝒔 and K(𝒔), each output coordinate of a sample can be computed from O(1) many words of 𝒎{0,1}𝑴.

The proof of Theorem 15 follows [26], where we encode the distribution of 𝒔 into the succinct data structure in [49] with a small increase in redundancy.

Lemma 16 (Lemma 28 in [49]).

Let Bpolylog(n), and C>0 be any constant. A size-s subset S[B] can be represented by a spillover representation (m,k){0,1}M×[K] such that

  • K=poly(n),

  • M+logKlog(Bs)+O(1/nC),

  • each query can be answered with O(1) word probes to m and k.

The proof of Theorem 15 is similar to [26, Lemma 4.2]. We include a proof sketch in the full version of the paper.

3.3 Concatenation

In this subsection, we explain how to sample the inputs of the L=n/B copies of the block-sampler in Theorem 15. Specifically, we will sample the L spill representations (𝒎i,𝒌i){0,1}M(𝒔i)×[K(𝒔i)] in a local and randomness-efficient way.

To illustrate the conceptual idea, let us for simplicity consider sampling only the 𝒎i’s but not the 𝒌i, using L𝔼[M(𝒔)]+O~(n) bits.

Recall that in Theorem 15, is a distribution that approximates Bin(B,p) and is supported on [pBB2/3,pB+B2/3]. For every fixed s in supp(), the sampler will sample from the uniform distribution on {0,1}M(s)×[K(s)] a spill representation of a size-s subset in [B]. Without loss of generality, we will assume M(s) is an integer multiple of the word size w=O(logn) and K(s)nC for a large enough C. This can be achieved by moving O(w) bits in M(s) to the spill, which can only change the spill size K(s) by a factor of at most 2O(w)poly(n).

We now make some observations about M(s) for ssupp(). Henceforth, we will treat bits as words, and view {0,1}M(s) as W(s)M(s)w 𝔽2w-elements. Note that we have W(s)[Wmin,Wmax], where

Wmin 1wlog2(BpBB2/3)=h(p)(B/w)Θ(B1/3/w) and
Wmax 1wlog2(BpB)h(p)(B/w).

Thus, we can write W(s)=Wmin+Δ(s), where Wmin does not depend on s and Δ(s)ΔmaxWmaxWmin=Θ(B1/3). Therefore, we can make the following conclusion on the concatenation of the L samplers:

  • it always reads a fixed set of W¯minLWmin coordinates;

  • it reads at most Δ¯thrLlogn additional coordinates with probability 11/poly(n);

  • it reads at most Δ¯maxLΔmax additional coordinates in the worst-case.

Moreover, the maximum deviation Δ¯max is much smaller than W¯min. Specifically, we have Δ¯maxW¯min/logn. Based on this observation, we can apply the following sparse matrix used in the augmented retrieval data structure in [26] to sample the W(𝒔1)++W(𝒔L) input elements to the L block-samplers.

Lemma 17.

Let 𝔽 be a finite field of size at least nC. Let 𝐒[Δ¯max] be a random subset of size at most Δ¯thr. Suppose W¯minΔ¯maxlogn. Then there exists a (W¯min+Δ¯max)×(W¯min+Δ¯thr) matrix G over 𝔽 with O(1) nonzeros in every row such that

Pr𝑺[G[W¯min]×𝑺 is full rank]11nC/2.

The parameters in our lemma are slightly different from the one in [26], so, we give a proof sketch in the full version of this paper.

Here the random subset 𝑺 in Lemma 17 corresponds to the random subset of the LWmax coordinates read by all L samplers modulo their first Wmin elements. By concentration bounds, 𝑺 has size at most Llogn with high probability. It follows from Lemma 17 that the number of uniform words used by the sampler is W¯min+Δ¯maxL𝔼[W(𝒔)]+O~(n), as desired.

We now briefly discuss how to sample the L spills using the same idea. First, we will assume that K(s) is prime and treat [K(s)] as a field, by embedding [K(s)] into the closest prime field, which has little effect on the error and seed length (see Claim 13).

Note that the K(si)’s depend on si’s and therefore are not all identical. Nevertheless, as is supported on [pBB2/3,pB+B2/3], there are at most 2B2/3+1=polylog(n) many possible values for K(s). Let us denote these values by K1,,Kq for some q2B2/3+1, and define pjPr𝒔[K(𝒔)=Kj]=s:K(s)=Kj(s). Let Nj=Nj(s1,,sL) denote the number of K(si)’s equal to Kj. Over the random choice of 𝒔1,,𝒔L, the random variable 𝑵j is distributed close to Bin(L,pj), and thus is at most pjL+O(Llogn) with probability at least 11/poly(n).

One complication is that pjL can be smaller than Llogn. So, in order to apply Lemma 17, we will sample the 𝑵j 𝔽Kj-elements together with a fraction of the W¯min 𝔽2w-elements. (We will convert the 𝔽2w-elements to 𝔽Kj-elements via Lemma 14.)

3.3.1 Proof of Theorem 2

Our goal is to sample random elements

𝒘(𝒘1,,𝒘L)(𝔽2wWmax)Land𝒌j[Kj]L:j[q],

so that with probability 11/poly(n) over (𝒔1,,𝒔L)L, each 𝒘i is 1/poly(n)-close to uniform on the first W(𝒔i) elements, and 𝒌j is 1/poly(n)-close to uniform on the first 𝑵j elements, using h(p)n+npolylog(n) uniform bits. Moreover, each output element depends on O(1) words of size w=O(logn) bits.

We first partition these elements into q+1 parts and sample each part individually using Lemma 17. For each block i[L], let Ii be the first Wmin=Θ(B) positions of wi, and Ii¯ its remaining Δmax=WmaxWmin=Θ(B1/3) positions. We then partition their union i=1LIi into q+1 sets J0J1Jq, where |Ji|LWmin4q for i[q] (and so |J0|=3LWmin4). Note that the coordinates in Ji’s are always read by the sampler, and the rest may not be. We will apply Lemma 17 to sample

  1. 1.

    (Words) the 𝔽2w-elements in J0 and i=1qIi¯.

  2. 2.

    (Spills) [Kj]L and the 𝔽2w-elements in Jj for each j[q].

Let W¯minLWmin and W¯maxLWmax.

Sampling the words

Let Δ¯wd,maxLΔmax, Δ¯wd,thrLlogn, and Δ(s)W(s)Wmin for every ssupp(). Note that 𝔼[i=1LΔ(𝒔i)]=L𝔼[W(𝒔)Wmin]=o(Llogn). By Hoeffding’s inequality, we have

Pr𝒔1,,𝒔L[i=1LΔ(𝒔i)Δ¯wd,thr]11/poly(n).

Conditioned on this event, let 𝑺 be the subset of coordinates in i=1LIi¯ (determined by 𝒔1,,𝒔L) that are read by the sampler (in addition to i=1LIi). We have |𝑺|Δ¯wd,thr, and

i=1q|Ii¯|logn=Δ¯wd,maxlogn34W¯min=|T0|.

By Lemma 17, there is a (34W¯min+Δ¯wd,max)×(34W¯min+Δ¯wd,thr) matrix M over 𝔽2w with O(1) nonzeros in each row such that for a uniform 𝒖, we have

Pr𝑺[M𝒖 is uniform on i=1LIi𝑺]11/poly(n).

Note that WminW(s)] for any ssupp(), and thus W¯minL𝔼[W(𝒔)]. Therefore, the number of uniform bits used to sample this part is at most

(3W¯min4+Δ¯wd,thr)w3L𝔼[M(𝒔)]4+Llog3/2n. (1)
Sampling the spills

We now explain how to sample the spills and the remaining words. We will use the following result from number theory [3].

Lemma 18.

For every sufficiently large n, there is a prime between n and n+n0.525.

For each j[q], let Δj,thrpjL+Llogn, and Pj be the smallest prime that is at least Kj, which, by Lemma 18, is at most Kj+Kj0.525. The sampling procedure consists of 3 main steps:

  1. 1.

    use Claim 13 and 14 to sample [Kj]L and the W¯min4q word-elements by a distribution D over a tuple of 𝔽Pj-elements.

  2. 2.

    use Lemma 17 to sample the distribution D using uniform 𝔽Pj elements.

  3. 3.

    use Lemma 14 to sample these uniform 𝔽Pj elements using uniform words.

We now describe each step in more detail. First, by Claim 13, for any subset S[L], if a distribution 𝒟 is ϵ-close to uniform on 𝔽PjS, then 𝒟 is (ϵ+δ)-close to uniform on [Kj]S, where

δLKj0.525Kj+Kj0.5252LKj0.4751/poly(n). (2)

Next, we apply Lemma 14 to obtain a local-sampler mapping 𝔽PjFj to 𝔽2wW¯min/(4q) with error 1/poly(n), where

FjW¯min4qwlog2Pj+O(logPjn)=Θ(n/B2/3).

Recall that 𝑵jBin(L,pj) with 𝔼[𝑵j]=pjL and Δj,thr=pjL+Llogn. By Hoeffding’s inequality, we have

Pr𝒔1,,𝒔L[𝑵jΔj,thr]11/poly(n).

Conditioned on this event, let 𝑺[L] be the coordinates read by the sampler. We have |𝑺|Δj,thr. Note that FjLlogL=Θ(nBlogn). By Lemma 17, there is a (Fj+L)×(Fj+Δj,thr) matrix M over 𝔽Pj with O(1) nonzero elements in each row such that for a uniform 𝒖𝔽PjFj+Δj,thr, we have

Pr𝑺[M𝒖 is uniform on [Fj]×𝑺]11/poly(n).

Finally, we use Lemma 14 again to sample 𝒖 from {0,1}mj with error 1/poly(n), where

mj (Fj+Δj,thr)log2Pj+O(log2n)
W¯min4qw+pjLlog2Pj+O(Llog23/2n)
W¯min4qw+pjLlog2Kj+O(Llog23/2n).

Closeness to uniform follows from Lemma 14, and locality follows since each sampler is O(1) word-local, and thus their composition is also O(1) word-local.

We now analyze the number of uniform bits used to sample this part. Observe that j=1Lpjlog2Kj=s(s)log2K(s)=𝔼[K(𝒔)]. Therefore, the number of bits used is

j=1qmj LWmin4w+Lj=1qpjlog2Kj+B2/3O(Llog23/2n)
L𝔼[M(𝒔)]4+L𝔼[log2K(𝒔)]+B2/3O(Llog23/2n). (3)

Summing Equations 1 and 3, the number of bits used by the sampler is at most

L𝔼[M(s)+log2K(𝒔)]+B2/3O(Llog23/2n)h(p)n+npolylog(n).

This completes the proof of Theorem 2.

4 A lower bound for a 2-local construction with 𝒎=(𝟐ϵ)𝒏

In this section, we prove Theorem 19, which says that for any 2-local mapping with seed length is (2ϵ)n, its distance to Ber(1/4)n approaches 1 as n increases.

Theorem 19.

Let n be sufficiently large. Fix ϵ>0, and let m=(2ϵ)n. Let f:{0,1}m{0,1}n be a 2-local mapping. Then

dist(f(Um),Ber(1/4)n)1exp(cϵn),

for some absolute constant c>0.

Before proving the theorem, we will prove several claims that will be needed later.

Proposition 20.

Let f:{0,1}m{0,1}n be a 1-local mapping. Then

dist(f(U),Ber(1/4)n)12en/128.

Note that since f is 1-local, we may assume without loss of generality that mn.

Proof.

For each i[m] corresponding to the input bit xi, let N(i) be the output bits that depend on xi. Note that we may assume without loss of generality that |N(i)|1 for all i[m], as otherwise we can remove the i’th coordinate. Since f is 1-local, the sets N(i) and N(i) are disjoint for ii, and the distributions f(xi)|N(i) and f(xi)|N(i) are independent. Next we consider the following two cases:

  • If m>n/2, we may pick for each i[m] one output coordinate jiN(i). Note that the corresponding output bit has distribution Ber(1/2), and the joint distribution f(Um)(ji)i[m] is Ber(1/2)m. Thus

    dist(f(U),Ber(1/4)n) dist(Ber(1/2)m,Ber(1/4)m)
    Pr[Bin(m,1/2)3m/8]Pr[Bin(m,1/4)3m/8]
    (1em/64)em/3612em/6412en/128.
  • If mn/2, then |supp(f(Um))|2m2n/2. On the other hand for any subset A{0,1}n of size at most 2m it holds that Pr[Ber(1/4)nA]Pr[Bin(n,1/4)n/8], as Ber(1/4)n assigns higher probability to the elements of lower weight and (nn/8)1n2h(1/8)n2n/22m. Therefore, we have

    dist(Ber(1/4)n,f(U))1Pr[Bin(n,1/4)n/8]1en/64.

This completes the proof of Proposition 20.

Claim 21.

Let f:{0,1}m{0,1}2 be a 2-local mapping. Let i[m] be a coordinate of the input, and let N(i) be the output bits that are influenced by the i’th input bit. If |N(i)|2, then dist(f(Um)|N(i),Ber(1/4)|N(i)|)1/8.

Proof.

Take any two distinct coordinates j,jN(i). These two coordinates depend on at most three input bits, and hence all probabilities of f(Um){j,j} are integer multiples of 1/8. On the other hand, the distribution Ber(1/4)2 has probabilities (1/16,3/16,3/16,9/16), and thus, each possible 2-bit string contributes at least 18 to each term of the summation in the definition of the distance. Therefore dist(f(Um)|N(i),Ber(1/4)|N(i)|)12(4116)=1/8.

We are now ready to prove Theorem 19.

Proof of Theorem 19.

Given a 2-local mapping f:{0,1}m{0,1}n with m=(2ϵ)n, define a bipartite graph G=(IO,E), where the vertices in I correspond to the m coordinates of the input, O corresponds to the n coordinates of the output, and (i,o)E if the o’th output bit depends on the i’th input coordinate. That is, |I|=m, |O|=n, and |E|=2n since f is 2-local.

We fix two large constants C=99, and d=4(C+1)/ϵ=400/ϵ. Let II be a maximal subset of I such that |N(I)|C|I|, and consider the following two cases.

Case 1: |𝑵(𝑰)|>𝒏/𝒅.

In this case, for any fixing of the inputs (xi)iI, the mapping (fj)jN(I) is 1-local. Therefore, conditioning on (xi)iI being fixed, by Proposition 20 the 1-local mapping satisfies

dist(f(Um),Ber(1/4)n)dist(f(UI),Ber(1/4)|N(I)|)12e|N(I)|128.

Accounting for all 2|I| assignments to the input bits in I we get

dist(f(Um),Ber(1/4)n)12s{0,1}|I|2eN|(I)|128142|I|e|N(I)|128.

Next, we use the assumption that |I||N(I)|/C and |N(I)|n/d together with our choice of C=99 and d=4(C+1)/ϵ=400/ϵ to get

dist(f(Um),Ber(1/4)n) 142|N(I)|/Ce|N(I)|/128
14e1/128ln(2)/Cdn
1exp(Ω(ϵn)).

This proves Theorem 19 in case of |N(I)|n/d.

Case 2: |𝑵(𝑰)|𝒏/𝒅.

In this case our strategy is the following. We will remove N(I) from the output coordinates. The remaining mapping f:{0,1}m{0,1}n will satisfy the property that m<(2ϵ/2)n and each input coordinate influences at most C output nodes. This will allow us to find a collection 𝒪 of Ω(ϵn) disjoint subsets of output coordinates (Oi)i𝒪 such that

  1. 1.

    dist(f(Um)|Oi,Ber(1/4)|Oi|)1/8 for all Oi𝒪,

  2. 2.

    (f(Um)|Oi)Oi𝒪 are jointly independent.

Then, by a Chernoff bound we conclude that dist(f(Um),Ber(1/4)n)1exp(Ω(ϵn)). We describe the details below.

Note that by maximality of I we have |N(i)N(I)|C for all iII. Therefore, by removing N(I) from the set of outputs, we get a graph G=(I=I,O,E) such that the degree of each iI is at most C.

Since we removed at most n/d=ϵn/400 output vertices, the new graph has m=(2ϵ)n inputs and n(1ϵ/400)n outputs. Therefore, m(2ϵ)n for

ϵ=2mn=22ϵ1ϵ/400>ϵ/2.

Therefore, we now have a 2-local mapping f:{0,1}m=(2ϵ)n{0,1}n with ϵ>ϵ/2 such that each input coordinate of f influences at most C output bits, and f has the same distribution as f on the remaining output coordinates.

Let J={iI:degG(i)2}.

Claim 22.

|J|ϵ2Cn.

Proof.

The proof is a simple application of Markov’s inequality. Since deg(v)C for all iI, we have

2n(2ϵ)n=𝔼iI[deg(i)]Pr[deg(i)1]+CPr[deg(i)>1]1+CPr[deg(i)>1].

Since deg(i) is an integer, we get Pr[deg(i)2]=Pr[deg(i)>1]ϵ(2ϵ)C>ϵ2C, as required. Now, since each input coordinate in J has degree at most C, we can find a subset KJ of size |K||K|/(C+1) such that N(i) and N(i) do not have common neighbours for all distinct i,iK. Indeed, this is achieved by taking any iJ, adding it to K and removing from J all neighbours of N(i).

This gives us a collection of input coordinates KI of size |K||J|/(C+1)ϵ2C(C+1)n, such that each iK has deg(i)2 and (f(Um)|N(i))iK are jointly independent.

By Claim 21 we have dist(f(Um)|N(i),Ber(1/4)|N(i)|)1/8 for all iK. Therefore, applying Chernoff’s bound on (f(Um)|N(i))iK we get

dist(f(Um),Ber(1/4)n) dist(f(Um),Ber(1/4)n)
12e(1/8)2|K|12
12eϵn82122C(C+1)
1exp(Ω(ϵn)).

This completes the proof of Theorem 19.

5 A 3-local construction with 𝒎=1.99𝒏 that is 𝟏/poly(𝐧)-close to Ber(𝟏/𝟒)𝐧

In this section, we show that in contrast to Theorem 19, if we allow the sampler to be 3-local, we can approximate the distribution Ber(1/4)n within distance of 1/poly(n), and this is optimal up to constant factor in the exponent.

Theorem 23.

Fix an integer t3 and let ϵ=1/3t. Let nN be sufficiently large and let m=(2ϵ)n. Then, there is a 3-local mapping f:{0,1}m{0,1}n such that

dist(f(Um),Ber(1/4)n)(12ϵn)29ϵ53.

In particular, for m=(21/9)n there is a 3-local mapping f:{0,1}m{0,1}n such that

dist(f(Um),Ber(1/4)n)2n1/3.
Proof of Theorem 23

We start with a graph G=(V,E) that is 3-regular graph with k vertices and 1.5k edges such that the girth of G is 23log2|V|=23log2k. Indeed, such graphs exist [36, Theorem 5.13].

Claim 24.

Let p=2t for some t3, and let 𝑮p=(V,Ep) be a random subgraph of G obtained by keeping each edge in E with probability p independently. Then Pr[𝑮p has a cycle]<k2t53.

Proof.

By the assumption, G has no cycle of length <23log2(k). For any 23log2k, the number of cycles of length is at most k322. Therefore,

Pr[𝑮p has a cycle of length ]k322p=3k4(2p).

Taking the union bound over all lengths >23log2(k), we get

Pr[𝑮p has a cycle]<3k4=23log2(k)(2p)=3k4(2p)23log2(k)12p<1k2t53, (4)

as required.

Given the graph G above, we define a graph G=(V,E) by subdividing each edge of G into t3 edges. The number of vertices in G is |V|=|V|+(t1)|E|=k+1.5(t1)k=(1.5t0.5)k, and the number of edges is |E|=1.5tk.

Let n=|E|=1.5tk and m=|V|+|E|=(3t0.5)k=(21/3t)n=(2ϵ)n. Define g:{0,1}mn{0,1}n by gi(y)=yuiyvi, where (ui,vi) are the endpoints of the i’th edge in G. By Claim 7, we have

dist(f(Um),Ber(1/4)n)Pr𝑺[g(𝒚) restricted to the coordinates in 𝑺 is not uniform],

where 𝑺 is a uniform subset of [n]. We will show that

Pr𝑺[g(𝒚)𝑺 is not uniform]Pr[𝑮1/2 has a cycle], (5)

where 𝑮1/2 is a random subgraph of G obtained by keeping each edge with probability 1/2. This proves Theorem 23 by combining ˜24 with the observation that Pr[𝑮1/2 has a cycle]=Pr[𝑮2t has a cycle].

To prove Equation 5, we will index the edges in E with [n], and view each S[n] as the corresponding subset ES of edges in E. Denote by F the event that the edge set ES induces a forest in G, i.e., the subgraph (V,ES) does not contain a cycle. Observe that if ESF, then for a uniform 𝒚{0,1}mn, the coordinates g(𝒚)S=(𝒚ui𝒚vi)iES are uniformly distributed. Using the natural correspondence between E𝑺 and 𝑮1/2, this clearly implies Equation 5. Therefore,

Pr𝑺[g(𝒚)𝑺 is not uniform]Pr[𝑮1/2 has a cycle]=Pr[𝑮2t has a cycle]1k2t53.

This concludes the proof of Theorem 23. ∎

In the full version of the paper, we show that Theorem 23 is tight.

6 A lower bound on 3-local constructions with 𝒎=(𝟐ϵ)𝒏

In this section we prove a lower bound on the distance for all 3-local constructions with m=1.99n.

Theorem 25.

Let n be sufficiently large. Fix ϵ>0, and let m=(2ϵ)n. Then, for any 3-local mapping f:{0,1}m{0,1}n it holds that

dist(f(Um),Ber(1/4)n)nO(1/ϵ).
Proof.

Let G=(V=IO,E) be a bipartite graph, where |I|=m=(2ϵ)n represents the input bits of f, |O|=n represents the output bits, and (i,o)E if and only if the o’th output bit of f depends on the i’th input bit.

We prove Theorem 25 by finding a small set of outputs SO such that its neighbourhood N(S) (i.e., the input bits of S) is small. Specifically, we will find a set SO of size |S|=k=O(log(n)) such that |N(S)|2k1. This indeed suffices, as for the distribution Ber(1/4)k the probability of sampling all zeros in S is exactly 4k, while the granularity of the inputs to S implies that f outputs all zeros in S with probability either 0 or at least 2|N(S)|=24k. Therefore,

|Pr[f(Um)|S0]Pr[(Ber(1/4)n)|S0]|4k.

In order to find such set S, note that the graph G has |V|=(3ϵ)n vertices and |E|=3n edges. Therefore, |E|=(1+ϵ)|V| for ϵ=ϵ/(3ϵ).

We use the following lemma, saying that any sufficiently dense graph contains a set of vertices S that span at least |S|+1 edges, such that |S|=O(log(n)).

Lemma 26 (Theorem 2 in [19]).

Let G=(V,E) be a multigraph with |V|2 vertices and |E|=m(1+ϵ)|V| edges for some ϵ=ϵ(|V|)(0,1]. There exists a set of vertices SV of size |S|8log(|V|)1/ϵ spanning at least |S|+1 edges.

Applying Lemma 26 to G, we get a subset of the vertices CV of size |C|8log(|V|)1/ϵ that spans at least |C|+1 edges. By taking the minimal such subset C, we may assume111Otherwise, if C has a vertex with degC(v)1, we can remove v from C, and the remaining subset C will also satisfy the property that |C|8log(|V|)1/ϵ and it spans at least |C|+1 edges. that all vertices vC have at least two neighbours in C.

The key step of the proof is summarized in the following claim.

Claim 27.

Let G=(V=IO,E) be the bipartite subgraph of G induced by C with I=IC and O=OC, and let k=|O|. Then |NG(O)|2k1.

Proof.

Since |E||V|+1, there must be at least one vertex in G of degree 3. Recall that all vertices in O have degree either 2 or 3, and denote by t the number of vertices in O of degree 3. Consider the following two cases.

  • t=0: Since all vertices in O have degree 2, the set I must have a vertex of degree 3 in G. Furthermore, |E|=2|O|=2k, and hence by counting degrees of the vertices in I, we have |I|k1. Finally, note that each vO has at most one neighbour outside C, and thus |NG(O)||I|+|O|(k1)+k=2k1.

  • t1: By counting the degrees of O in G note that |E|=2(kt)+3t=2k+t. Similarly, by counting the degrees of I in G, we have |E|2|I|. Finally, there are exactly kt nodes vO with one neighbour outside C, and t nodes vO with no neighbours outside C. Therefore,

    |NG(O)||I|+(kt)|E|/2+(kt)(k+t/2)+(kt)2kt/2.

    Since |NG(O)| is an integer and t1, it follows that |NG(O)|2k1.

In both cases we showed that |NG(O)|2k1, as required. Therefore, letting S=CO, we get a set of size k=|S||C|8log(|V|)1/ϵ8log(3n)3/ϵ such that |N(S)|2k1. By the discussion above this implies that

dist(f(U),Ber(1/4)n)|Pr[f(Um)|S0]Pr[(Ber(1/4)n)|S0]|4k(3n)48/ϵ.

This completes the proof of Theorem 25.

7 A 𝟒-local construction with 𝒎=1.75𝒏 that is 𝐞𝐱𝐩(𝒄𝒏)-close to Ber(𝟏/𝟒)𝐧

In this section we prove that 4-local samplers can approximate the distribution Ber(1/4)n within exponentially small distance.

Theorem 28.

Let n be sufficiently large, and let m=(21/4)n. Then, there exists a 4-local mapping f:{0,1}m{0,1}n such that

dist(f(Um),Ber(1/4)n)2cn,

for some absolute constant c>0.

The proof of Theorem 28 relies on the following lemma.

Lemma 29.

Let m,n be parameters such that nm2n, and let M𝔽2n×(mn) be a matrix such that every row of M has exactly d ones. Then, there exists a (d+1)-local sampler f:{0,1}m{0,1}n satisfying

dist(f(Um),Ber(1/4)n)Pr𝑺[n][the rows of M𝑺 are linearly dependent], (6)

where MS is the submatrix of M obtained by taking only the rows of M with indices in S.

Proof.

Define f:{0,1}n×{0,1}mn by f(x,y)=xnMy. Clearly, f is (d+1)-local. By Claim 7, for a uniform subset 𝑺[n],

dist(𝒙n(M𝒚),Ber(1/4)n) Pr[M𝒚 is not uniform on {0,1}𝑺]
=Pr[M𝑺 is linear dependent].

Next we state a result about the existence of a sparse matrix which satisfies the conditions in Lemma 29. We show the existence of such matrix by adapting Gallager’s result on random sparse matrices [18]. Its proof can be found in the full version of this paper.

Theorem 30.

For a sufficiently large n there exists a matrix M𝔽2n×0.75n with exactly 3 ones in every row and 4 ones in each column such that for a uniform subset 𝐒[n],

Pr[M𝑺 is linearly dependent]20.05n.

Theorem 28 immediately follows from applying Lemma 29 to Theorem 30.

Proof of Theorem 28.

Let M𝔽2n×0.75n be the matrix from Theorem 30, which has 3 ones in each row. By Lemma 29, there is a 4-local sampler f:{0,1}1.75n{0,1}n such that dist(f(Um),Ber(1/4)n)Pr[M𝑺 is linear dependent]20.05n.

References

  • [1] Yaroslav Alekseev, Mika Göös, Konstantin Myasnikov, Artur Riazanov, and Dmitry Sokolov. Sampling permutations with cell probes is hard. In 58th Annual Symposium on Theory of Computing (STOC), 2026.
  • [2] László Babai. Random oracles separate PSPACE from the polynomial-time hierarchy. Inform. Process. Lett., 26(1):51–53, 1987. doi:10.1016/0020-0190(87)90036-6.
  • [3] R. C. Baker, G. Harman, and J. Pintz. The difference between consecutive primes. II. Proc. London Math. Soc. (3), 83(3):532–562, 2001. doi:10.1112/plms/83.3.532.
  • [4] Chris Beck, Russell Impagliazzo, and Shachar Lovett. Large deviation bounds for decision trees and sampling lower bounds for AC0-circuits. In 53rd Annual Symposium on Foundations of Computer Science (FOCS), pages 101–110, 2012. doi:10.1109/FOCS.2012.82.
  • [5] Itai Benjamini, Gil Cohen, and Igor Shinkar. Bi-lipschitz bijection between the boolean cube and the hamming ball. Israel J. Math., 212(2):677–703, 2016. doi:10.1007/s11856-016-1302-0.
  • [6] Avrim Blum, Adam Kalai, and Hal Wasserman. Noise-tolerant learning, the parity problem, and the statistical query model. J. ACM, 50(4):506–519, 2003. doi:10.1145/792538.792543.
  • [7] Lucas Boczkowski and Igor Shinkar. On mappings on the hypercube with small average stretch. Combin. Probab. Comput., 32(2):334–348, 2023. doi:10.1017/s0963548322000281.
  • [8] R. B. Boppana and J. C. Lagarias. One-way functions and circuit complexity. Inform. and Comput., 74(3):226–240, 1987. doi:10.1016/0890-5401(87)90022-8.
  • [9] Eshan Chattopadhyay, Jesse Goodman, and David Zuckerman. The space complexity of sampling. In 13th Innovations in Theoretical Computer Science Conference (ITCS), pages 40:1–40:23, 2022. doi:10.4230/LIPIcs.ITCS.2022.40.
  • [10] Eshan Chattopadhyay and David Zuckerman. Explicit two-source extractors and resilient functions. Ann. of Math. (2), 189(3):653–705, 2019. doi:10.4007/annals.2019.189.3.1.
  • [11] Gil Cohen and Leonard J. Schulman. Extractors for near logarithmic min-entropy. In 57rd Annual Symposium on Foundations of Computer Science (FOCS), pages 178–187, 2016. doi:10.1109/FOCS.2016.27.
  • [12] Thomas M. Cover and Joy A. Thomas. Elements of information theory. John Wiley & Sons, Inc., New York, 1991. doi:10.1002/0471200611.
  • [13] Harm Derksen, Peter Ivanov, Chin Ho Lee, and Emanuele Viola. Pseudorandomness, symmetry, smoothing: I. In 39th Computational Complexity Conference (CCC), volume 300, pages 18:1–18:27, 2024. doi:10.4230/lipics.ccc.2024.18.
  • [14] Harm Derksen, Peter Ivanov, Chin Ho Lee, and Emanuele Viola. Pseudorandomness, symmetry, smoothing: Ii, 2024. doi:10.48550/arXiv.2407.12110.
  • [15] Yevgeniy Dodis, Mihai Pătraşcu, and Mikkel Thorup. Changing base without losing space. In 43rd Annual Symposium on Theory of Computing (STOC), pages 593–602, 2010. doi:10.1145/1806689.1806771.
  • [16] Thomas L. Draper and Feras A. Saad. Efficient online random sampling via randomness recycling. In 37st Annual Symposium on Discrete Algorithms (SODA), pages 2473–2511, 2026. doi:10.1137/1.9781611978971.89.
  • [17] Yuval Filmus, Itai Leigh, Artur Riazanov, and Dmitry Sokolov. Sampling and certifying symmetric functions. In 27th International Workshop on Randomization and Approximation Techniques in Computer Science (RANDOM), pages 36:1–36:21, 2023. doi:10.4230/lipics.approx/random.2023.36.
  • [18] R. G. Gallager. Low-density parity-check codes. IRE Trans., IT-8:21–28, 1962. doi:10.1109/tit.1962.1057683.
  • [19] Alexander Golovnev, Tom Gur, and Igor Shinkar. Derandomization of cell sampling. In 2023 Symposium on Simplicity in Algorithms (SOSA), pages 278–284, 2023. doi:10.1137/1.9781611977585.ch26.
  • [20] Mika Göös and Thomas Watson. A lower bound for sampling disjoint sets. ACM Trans. Comput. Theory, 12(3):20:1–20:13, 2020. doi:10.1145/3404858.
  • [21] Daniel Grier, Daniel M. Kane, Jackson Morris, Anthony Ostuni, and Kewen Wu. Quantum advantage from sampling shallow circuits: beyond hardness of marginals. In 17th Innovations in Theoretical Computer Science Conference (ITCS), pages 73:1–73:14, 2026. doi:10.4230/lipics.itcs.2026.73.
  • [22] Torben Hagerup. Fast parallel generation of random permutations. In 18th International Colloquium on Automata, Languages, and Programming (ICALP), pages 405–416, 1991. doi:10.1007/3-540-54233-7_151.
  • [23] Elad Haramaty, Chin Ho Lee, and Emanuele Viola. Bounded independence plus noise fools products. SIAM J. Comput., 47(2):493–523, 2018. doi:10.1137/17M1129088.
  • [24] Johan Torkel Hastad. Computational Limitations of Small Depth Circuits. PhD thesis, Massachusetts Institute of Technology, 1986.
  • [25] Pooya Hatami and William Hoza. Paradigms for unconditional pseudorandom generators. Found. Trends Theor. Comput. Sci., 16(1-2):1–210, 2024. doi:10.1561/0400000109.
  • [26] Yang Hu, Jingxun Liang, Huacheng Yu, Junkai Zhang, and Renfei Zhou. Optimal static dictionary with worst-case constant query time. In 57th Annual Symposium on Theory of Computing (STOC), pages 278–289, 2025. doi:10.1145/3717823.3718278.
  • [27] Russell Impagliazzo and Moni Naor. Efficient cryptographic schemes provably as secure as subset sum. J. Cryptology, 9(4):199–216, 1996. doi:10.1007/s001459900012.
  • [28] Daniel M. Kane, Anthony Ostuni, and Kewen Wu. Locality bounds for sampling Hamming slices. In 56th Annual Symposium on Theory of Computing (STOC), pages 1279–1286, 2024. doi:10.1145/3618260.3649670.
  • [29] Daniel M. Kane, Anthony Ostuni, and Kewen Wu. Locally sampleable uniform symmetric distributions. In 57th Annual Symposium on Theory of Computing (STOC), pages 1807–1816, 2025. doi:10.1145/3717823.3718243.
  • [30] Daniel M. Kane, Anthony Ostuni, and Kewen Wu. Symmetric distributions from shallow circuits, 2025. doi:10.48550/arXiv.2511.14127.
  • [31] Donald E. Knuth and Andrew C. Yao. The complexity of nonuniform random number generation. In Algorithms and complexity (Proc. Sympos., Carnegie-Mellon Univ., Pittsburgh, Pa., 1976), pages 357–428. Academic Press, New York-London, 1976.
  • [32] Cheuk Ting Li. Channel simulation: Theory and applications to lossy compression and differential privacy. Foundations and Trends in Communications and Information Theory, 21(6):847–1106, December 2024. doi:10.1561/0100000141.
  • [33] Shachar Lovett and Emanuele Viola. Bounded-depth circuits cannot sample good codes. Comput. Complexity, 21(2):245–266, 2012. doi:10.1007/s00037-012-0039-3.
  • [34] Yossi Matias and Uzi Vishkin. Converting high probability into nearly-constant time—with applications to parallel hashing. In 23th Annual Symposium on Theory of Computing (STOC), pages 307–316, 1991. doi:10.1145/103418.103453.
  • [35] Arya Mazumdar, Venkat Chandar, and Gregory W. Wornell. Local recovery in data compression for general sources. In 2015 IEEE International Symposium on Information Theory (ISIT), pages 2984–2988, 2015. doi:10.1109/ISIT.2015.7283004.
  • [36] Moshe Morgenstern. Existence and explicit constructions of q+1 regular ramanujan graphs for every prime power q. J. Combin. Theory Ser. B, 62(1):44–62, 1994. doi:10.1006/jctb.1994.1054.
  • [37] Mihai Patrascu. Succincter. In 49th Annual Symposium on Foundations of Computer Science (FOCS), pages 305–313, 2008. doi:10.1109/FOCS.2008.83.
  • [38] Oded Regev. On lattices, learning with errors, random linear codes, and cryptography. J. ACM, 56(6):34:1–34:40, 2009. doi:10.1145/1568318.1568324.
  • [39] Ronen Shaltiel and Jad Silbak. Explicit codes for poly-size circuits and functions that are hard to sample on low entropy distributions. In 56th Annual Symposium on Theory of Computing (STOC), pages 2028–2038, 2024. doi:10.1145/3618260.3649735.
  • [40] C. E. Shannon. A mathematical theory of communication. Bell System Tech. J., 27:379–423, 623–656, 1948. doi:10.1002/j.1538-7305.1948.tb01338.x.
  • [41] Roman Smolensky. Algebraic methods in the theory of lower bounds for boolean circuit complexity. In 23th Annual Symposium on Theory of Computing (STOC), pages 77–82, 1987. doi:10.1145/28395.28404.
  • [42] Emanuele Viola. The complexity of distributions. SIAM J. Comput., 41(1):191–218, 2012. doi:10.1137/100814998.
  • [43] Emanuele Viola. Extractors for circuit sources. SIAM J. Comput., 43(2):655–672, 2014. doi:10.1137/11085983X.
  • [44] Emanuele Viola. Is nature a low-complexity sampler?, 2014. URL: https://emanueleviola.wordpress.com/2014/11/09/is-nature-a-low-complexity-sampler/.
  • [45] Emanuele Viola. New sampling lower bounds via the separator. In 38th Computational Complexity Conference (CCC), pages 26:1–26:23, 2023. doi:10.4230/lipics.ccc.2023.26.
  • [46] Emanuele Viola. 15 years of complexity of distributions, 2024. URL: https://emanueleviola.wordpress.com/2024/11/11/15-years-of-complexity-of-distributions/.
  • [47] Emanuele Viola, Omri Weinstein, and Huacheng Yu. How to store a random walk. In 31st Annual Symposium on Discrete Algorithms (SODA), pages 426–445, 2020. doi:10.5555/3381089.3381115.
  • [48] Adam Bene Watts and Natalie Parham. Unconditional quantum advantage for sampling with shallow circuits. In 17th Innovations in Theoretical Computer Science Conference (ITCS), pages 17:1–17:12, 2026. doi:10.4230/lipics.itcs.2026.17.
  • [49] Huacheng Yu. Nearly optimal static Las Vegas succinct dictionary. SIAM J. Comput., 51(3):STOC20–174–STOC20–249, 2022. doi:10.1137/20M1363649.
  • [50] Huacheng Yu and Wei Zhan. Sampling, flowers and communication. In 15th Innovations in Theoretical Computer Science Conference (ITCS), pages 100:1–100:11, 2024. doi:10.4230/lipics.itcs.2024.100.