Local Samplers for Product Distributions
Abstract
We obtain several results on sampling product distributions in a local and randomness-efficient fashion:
-
1.
Let be a product distribution where the have constant support and have dyadic probability masses (i.e., of the form where are integers). Then can be sampled in constant time in the bit-probe model (equivalently, in NC0) and randomness complexity , up to an exponentially small statistical error. The dyadic requirement is necessary.
-
2.
Every -biased distribution can be sampled in constant time in the cell-probe model with randomness complexity , up to a polynomially small statistical distance.
-
3.
We determine the tradeoffs between locality and statistical distance for sampling the -biased distribution using non-trivial randomness complexity (e.g., ). For 2 bit probes, essentially no non-trivial approximation is possible; for 3 bit probes, we give a sampler with 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, PseudorandomnessCategory:
Track A: Algorithms, Complexity and GamesFunding:
Emanuele Viola: Supported by NSF grant CCF-2430026.Copyright and License:
2012 ACM Subject Classification:
Theory of computation Pseudorandomness and derandomization ; Theory of computation Data structures design and analysis ; Theory of computation Computational complexity and cryptographyAcknowledgements:
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 PuppisSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
Shannon’s source coding theorem [40], see for example [12, Theorem 3.2.1], says that i.i.d. samples from a source can be compressed into about 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 , the goal is to design a mapping such that for a uniformly random , the distribution of 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 i.i.d. samples from any distribution with worst-case randomness complexity close to the information-theoretic optimum . 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 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 to output any specific value on a given input ; rather, the focus is solely on the distribution induced by when is chosen uniformly at random.
For a concrete example, consider the parity function. While classical results in the 80s [24, 41] showed that circuits have small correlation with the parity function, the works [2, 8] showed that the uniform distribution on -bit strings with the same parity can be sampled exactly by the following -local function on bits:
Other surprising examples include sampling the inner-product mod 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 -biased distributions on bits, denoted , is already omnipresent in computer science. For example, the complexity of sampling -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 -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 -biased distributions, see the monograph [25] and the works [13, 14]. Again, efficient implementations of these generators require efficient samplers for -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 -biased distribution on bits, denoted . On the one hand, the distribution can be sampled with randomness complexity and locality . This trivial construction partitions the input bits into 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 -biased distributions on bits can be sampled with randomness complexity , where 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 with constant locality and randomness complexity
?
Can you even get randomness complexity 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, ) with nearly optimal randomness complexity. This result requires the distribution to be dyadic, i.e., all probability masses are of the form for integers . The dyadic requirement is necessary: for example, 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 for dyadic and non-dyadic values of . Henceforth, we denote statistical distance by .
Theorem 1 (Special case of Theorem 8).
Let be a product distribution where each is dyadic and supported on . For every , there is a -local with input length such that .
By increasing the locality to ), we can approximate any distribution by a dyadic one and sample any arbitrary product distribution to within distance (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 bits, and one probe reads an entire word. We show how to sample with randomness complexity to within distance , in constant time.
Theorem 2.
The distribution can be sampled using uniform bits within statistical distance with word-probes.
Returning to the bit-probe model, recall the trivial sampler of that is -local and uses randomness complexity . We ask ourselves what can be achieved using constant locality and non-trivial randomness complexity . We determine the tradeoff between locality and statistical distance: For bit-probes, no non-trivial approximation is possible; for 3 bit-probes, we give a sampler with 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 and be any -local function. We have
Theorem 4 (Theorem 23 and Theorem 28).
For , there is an and a -local sampler such that
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 , 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 with expected randomness complexity close to the optimal . Such construction dates back to the work of Knuth and Yao [31]. To illustrate the basic idea, consider sampling one bit, i.e., . We can do so as follows. First, read an input bit. If it’s 0, output ; otherwise, read another input bit and output it. This samples perfectly . While in the worst case we use a trivial randomness complexity , the expected number of input bits read is only , 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 output bits in blocks of length , 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 . 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.
Definition 5 (Spillover representation).
Given an injective map from a set to , the spillover representation of an element in is its corresponding element , where 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 keys in a universe can be represented by a spillover representation with . Then a uniform key can be sampled from with error .
Proof.
The error is at most the probability that a uniform element from is not a spillover representation of any keys. Using for , this probability is
We divide the bits into blocks of bits, as opposed to 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 -bit strings of Hamming weight by spillover representations in so that each string can be retrieved using word-probes to the representation. Moreover, the redundancy is small.
A critical point here is that to sample , the weight is not fixed, but a random variable distributed according to the binomial distribution . Consequently, both and are random variables induced by .
To sample , as in [26] we encode a distribution that is close to into the first words in each representation with a increase in redundancy. This gives us a block-sampler for : we first sample the first words to determine the Hamming weight , followed by sampling a uniform string of Hamming weight using the spill representation in . One can show that in expectation over . Now we can apply Claim 6 to obtain a -word-probe block-sampler for .
Our plan is to concatenate the independent copies of the block-sampler to sample the bits. However, as the size of a representation depends on , sampling the representations together with small redundancy becomes a challenge. The issue here is what we alluded to before. The and 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 typically is at least , which is much larger than its deviation . Based on this observation, [26] constructs random sparse matrices to concatenate the representations with redundancy. Here, we use the same random sparse matrices to sample the spillover representations for the block-samplers. However, unlike [26], our construction does not achieve redundancy, because in contrast to the data structure setting, a (local) sampler cannot first sample the sizes (and ) for the 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 where . We consider the bipartite graph representing the input-output dependency of .
Suppose there is a subset of inputs which connects to neighbors, then for every fixing of these input bits, restricted to the bits is a 1-local, which can be shown to be exponentially far from , and this remains so after summing over all fixings of the inputs.
Therefore, if , then the result follows. Otherwise, by removing these input vertices and their neighbors, we are left with a -local map from bits to bits where every input has bounded degree. So we can decompose the outputs into groups so that each group depends on disjoint inputs. We show that each group has some constant distance away from the -biased distribution. So the overall distance is at least .
Our 3-local lower bound (Theorem 25) is shown by finding a set of output coordinates of size which depend on at most inputs. Indeed, by granularity it follows that we see all zeros on these coordinates with probability either 0 or at least , while outputs all zeros with probability . Therefore, the statistical distance of our sampler to is at least . 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 in any graphs whose average degree is bounded above by 2.
The construction of our -local and -local samplers (Theorem 4) is inspired by the recent iterative framework in constructing pseudorandom generators [25]. Recall that the output of the trivial -local sampler is the bitwise AND for two independent uniform -bit strings and . The work [23] suggested the following equivalent view of .
Claim 7.
Let be independent, where is uniform. Then
Proof.
We can think of sampling 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 , it suffices for to be uniform on a uniform subset of its coordinates with high probability. To generate such , our 3-local sampler assigns each to two input bits according to a 3-regular expander graph , where corresponds to the edge . Then we let be . To analyze the construction, we show that a random subgraph of has no cycle with probability . That means the ’s are uniform when restricted to most subsets chosen by , and the result follows.
Our 4-local sampler construction follows the same idea. Again, we use uniform bits to select a random subset . Then to sample , we use a -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 .
2 Local sampler for product distributions
In this section, we prove Theorem 1.
Theorem 8.
Let be an integer and be distributions on , where the probability is an integer multiple of for every and . Let be the product distribution of the ’s.
For every , there exists a sampler with input length and locality such that . The sampler is adaptive, in the sense that for each output query, makes 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 be distributions on for . The product distribution can be sampled using bits with locality and error .
Proof.
We can approximate each with a distribution whose probability masses are integer multiples of such that for all , and in particular for all (cf. [42, Lemma 5.2]). Setting for a sufficiently large constant , the two distributions and are -close in total variation distance. Note that for each we have
Since , each term in the sum is at most , and hence
Therefore, , and the corollary follows by applying Theorem 8 on .
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 be any distribution on , where there is some such that is an integer multiple of for all . Then can be sampled exactly by a decision tree , where the expected depth of a leaf is at most .
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 and a sufficiently small . Let and . Let be any distribution supported on subsets of size . There exists a matrix with at most ones in each row, such that if we sample a subset of its rows according to , then the corresponding submatrix is full rank with probability at least
Remark 12.
In Lemma 11 we are looking for a matrix such that most subsets of 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 rows are linearly independent, as such matrix would correspond to a parity-check matrix of a linear error correcting codes with block length , minimum distance , and dimension at least , which is impossible over small alphabet (e.g., by Plotkin’s bound, stating that a linear code of length with minimum distance has dimension at most ).
The proof of Lemma 11 is available in the full version of the paper.
Proof of Theorem 8.
Divide the ’s into blocks each of size . Let be the product of the ’s in the -th block. Note that is supported on and its probability mass on each outcome is an integer multiple of . We first apply Lemma 10 to sample each independently with a -local block-sampler using bits. Let be the concatenation of the block-samplers. We will sample the -bit input of pseudorandomly by applying the sparse matrix from Lemma 11 to a seed of some length .
For each input of , let denote the subset of positions read by to evaluate . We emphasize that are the only positions read by to evaluate . Note that can be written as , where is the subset of bits read by the -th block-sampler. By Lemma 10, for a uniform , we have for every . Therefore,
Let . By Hoeffding’s inequality, we have
Define so that (and therefore . Let
where the last inequality follows from .
Let be the matrix obtained by applying Lemma 11 with equal to the distribution of conditioned on and our choice of . Our sampler takes an input and output .
Clearly the input length of is . The locality of is at most , where is row-sparsity of given by Lemma 11.
We now analyze the error. By Lemma 11, we have
Let us condition on the event that both and is full rank. Then for a uniformly random input to , the bits in the coordinates in of are uniformly random, and thus in each of the blocks the output is distributed according to . Therefore,
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 can be sampled using uniform bits within statistical distance with 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 can be sampled by elements in with error .
Proof.
We think of as . Given a uniform , we output . The statistical distance is at most the probability that lies in the last elements, which is at most .
Lemma 14.
Given , there is a function such that
-
;
-
each output coordinate depends on many input coordinates;
-
for every subset , if the coordinates depends on are -close to uniform, then is -close to uniform over .
Proof.
We modify the proof in [15, Section 4] as follows. They showed that one can represent by a spillover representation where and
Moreover, each element of only depends on coordinates of . It follow from Claim 6 that the uniform distribution on can be sampled from the uniform distribution on with error , with each output coordinate depending on at most of the input coordinates. Finally, we use Claim 13 to sample the uniform distribution over using elements of with error .
3.2 Sampling -biased distributions on polylog bits
In this subsection, we show how to sample many -biased bits with -word probes.
Theorem 15.
Let and be any constant. The distribution can be sampled from with error , where , with the following properties:
-
A distribution supported on that is -close to can be sampled using the first bits of .
-
Given a sample , the lengths and are fixed and
-
Given both and , each output coordinate of a sample can be computed from many words of .
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 , and be any constant. A size- subset can be represented by a spillover representation such that
-
,
-
,
-
each query can be answered with word probes to and .
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 copies of the block-sampler in Theorem 15. Specifically, we will sample the spill representations in a local and randomness-efficient way.
To illustrate the conceptual idea, let us for simplicity consider sampling only the ’s but not the , using bits.
Recall that in Theorem 15, is a distribution that approximates and is supported on . For every fixed in , the sampler will sample from the uniform distribution on a spill representation of a size- subset in . Without loss of generality, we will assume is an integer multiple of the word size and for a large enough . This can be achieved by moving bits in to the spill, which can only change the spill size by a factor of at most .
We now make some observations about for . Henceforth, we will treat bits as words, and view as -elements. Note that we have , where
Thus, we can write , where does not depend on and . Therefore, we can make the following conclusion on the concatenation of the samplers:
-
it always reads a fixed set of coordinates;
-
it reads at most additional coordinates with probability ;
-
it reads at most additional coordinates in the worst-case.
Moreover, the maximum deviation is much smaller than . Specifically, we have . Based on this observation, we can apply the following sparse matrix used in the augmented retrieval data structure in [26] to sample the input elements to the block-samplers.
Lemma 17.
Let be a finite field of size at least . Let be a random subset of size at most . Suppose . Then there exists a matrix over with nonzeros in every row such that
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 coordinates read by all samplers modulo their first elements. By concentration bounds, has size at most with high probability. It follows from Lemma 17 that the number of uniform words used by the sampler is , as desired.
We now briefly discuss how to sample the spills using the same idea. First, we will assume that is prime and treat as a field, by embedding into the closest prime field, which has little effect on the error and seed length (see Claim 13).
Note that the ’s depend on ’s and therefore are not all identical. Nevertheless, as is supported on , there are at most many possible values for . Let us denote these values by for some , and define . Let denote the number of ’s equal to . Over the random choice of , the random variable is distributed close to , and thus is at most with probability at least .
One complication is that can be smaller than . So, in order to apply Lemma 17, we will sample the -elements together with a fraction of the -elements. (We will convert the -elements to -elements via Lemma 14.)
3.3.1 Proof of Theorem 2
Our goal is to sample random elements
so that with probability over , each is -close to uniform on the first elements, and is -close to uniform on the first elements, using uniform bits. Moreover, each output element depends on words of size bits.
We first partition these elements into parts and sample each part individually using Lemma 17. For each block , let be the first positions of , and its remaining positions. We then partition their union into sets , where for (and so ). Note that the coordinates in ’s are always read by the sampler, and the rest may not be. We will apply Lemma 17 to sample
-
1.
(Words) the -elements in and .
-
2.
(Spills) and the -elements in for each .
Let and .
Sampling the words
Let , , and for every . Note that . By Hoeffding’s inequality, we have
Conditioned on this event, let be the subset of coordinates in (determined by ) that are read by the sampler (in addition to ). We have , and
By Lemma 17, there is a matrix over with nonzeros in each row such that for a uniform , we have
Note that for any , and thus . Therefore, the number of uniform bits used to sample this part is at most
| (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 , there is a prime between and .
For each , let , and be the smallest prime that is at least , which, by Lemma 18, is at most . The sampling procedure consists of 3 main steps:
We now describe each step in more detail. First, by Claim 13, for any subset , if a distribution is -close to uniform on , then is -close to uniform on , where
| (2) |
Next, we apply Lemma 14 to obtain a local-sampler mapping to with error , where
Recall that with and . By Hoeffding’s inequality, we have
Conditioned on this event, let be the coordinates read by the sampler. We have . Note that . By Lemma 17, there is a matrix over with nonzero elements in each row such that for a uniform , we have
Finally, we use Lemma 14 again to sample from with error , where
Closeness to uniform follows from Lemma 14, and locality follows since each sampler is word-local, and thus their composition is also word-local.
We now analyze the number of uniform bits used to sample this part. Observe that . Therefore, the number of bits used is
| (3) |
Summing Equations 1 and 3, the number of bits used by the sampler is at most
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 -local mapping with seed length is , its distance to approaches 1 as increases.
Theorem 19.
Let be sufficiently large. Fix , and let . Let be a 2-local mapping. Then
for some absolute constant .
Before proving the theorem, we will prove several claims that will be needed later.
Proposition 20.
Let be a 1-local mapping. Then
Note that since is 1-local, we may assume without loss of generality that .
Proof.
For each corresponding to the input bit , let be the output bits that depend on . Note that we may assume without loss of generality that for all , as otherwise we can remove the ’th coordinate. Since is 1-local, the sets and are disjoint for , and the distributions and are independent. Next we consider the following two cases:
-
If , we may pick for each one output coordinate . Note that the corresponding output bit has distribution , and the joint distribution is . Thus
-
If , then . On the other hand for any subset of size at most it holds that , as assigns higher probability to the elements of lower weight and . Therefore, we have
This completes the proof of Proposition 20.
Claim 21.
Let be a 2-local mapping. Let be a coordinate of the input, and let be the output bits that are influenced by the ’th input bit. If , then .
Proof.
Take any two distinct coordinates . These two coordinates depend on at most three input bits, and hence all probabilities of are integer multiples of 1/8. On the other hand, the distribution has probabilities , and thus, each possible 2-bit string contributes at least to each term of the summation in the definition of the distance. Therefore .
We are now ready to prove Theorem 19.
Proof of Theorem 19.
Given a 2-local mapping with , define a bipartite graph , where the vertices in correspond to the coordinates of the input, corresponds to the coordinates of the output, and if the ’th output bit depends on the ’th input coordinate. That is, , , and since is 2-local.
We fix two large constants , and . Let be a maximal subset of such that , and consider the following two cases.
Case 1: .
In this case, for any fixing of the inputs , the mapping is 1-local. Therefore, conditioning on being fixed, by Proposition 20 the 1-local mapping satisfies
Accounting for all assignments to the input bits in we get
Next, we use the assumption that and together with our choice of and to get
This proves Theorem 19 in case of .
Case 2: .
In this case our strategy is the following. We will remove from the output coordinates. The remaining mapping will satisfy the property that and each input coordinate influences at most output nodes. This will allow us to find a collection of disjoint subsets of output coordinates such that
-
1.
for all ,
-
2.
are jointly independent.
Then, by a Chernoff bound we conclude that . We describe the details below.
Note that by maximality of we have for all . Therefore, by removing from the set of outputs, we get a graph such that the degree of each is at most .
Since we removed at most output vertices, the new graph has inputs and outputs. Therefore, for
Therefore, we now have a 2-local mapping with such that each input coordinate of influences at most output bits, and has the same distribution as on the remaining output coordinates.
Let .
Claim 22.
.
Proof.
The proof is a simple application of Markov’s inequality. Since for all , we have
Since is an integer, we get , as required. Now, since each input coordinate in has degree at most , we can find a subset of size such that and do not have common neighbours for all distinct . Indeed, this is achieved by taking any , adding it to and removing from all neighbours of .
This gives us a collection of input coordinates of size , such that each has and are jointly independent.
By Claim 21 we have for all . Therefore, applying Chernoff’s bound on we get
This completes the proof of Theorem 19.
5 A 3-local construction with that is -close to
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 within distance of , and this is optimal up to constant factor in the exponent.
Theorem 23.
Fix an integer and let . Let be sufficiently large and let . Then, there is a 3-local mapping such that
In particular, for there is a 3-local mapping such that
Proof of Theorem 23
We start with a graph that is -regular graph with vertices and edges such that the girth of is . Indeed, such graphs exist [36, Theorem 5.13].
Claim 24.
Let for some , and let be a random subgraph of obtained by keeping each edge in with probability independently. Then .
Proof.
By the assumption, has no cycle of length . For any , the number of cycles of length is at most . Therefore,
Taking the union bound over all lengths , we get
| (4) |
as required.
Given the graph above, we define a graph by subdividing each edge of into edges. The number of vertices in is , and the number of edges is .
Let and . Define by , where are the endpoints of the ’th edge in . By Claim 7, we have
where is a uniform subset of . We will show that
| (5) |
where is a random subgraph of obtained by keeping each edge with probability . This proves Theorem 23 by combining ˜24 with the observation that .
To prove Equation 5, we will index the edges in with , and view each as the corresponding subset of edges in . Denote by the event that the edge set induces a forest in , i.e., the subgraph does not contain a cycle. Observe that if , then for a uniform , the coordinates are uniformly distributed. Using the natural correspondence between and , this clearly implies Equation 5. Therefore,
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 .
Theorem 25.
Let be sufficiently large. Fix , and let . Then, for any -local mapping it holds that
Proof.
Let be a bipartite graph, where represents the input bits of , represents the output bits, and if and only if the ’th output bit of depends on the ’th input bit.
We prove Theorem 25 by finding a small set of outputs such that its neighbourhood (i.e., the input bits of ) is small. Specifically, we will find a set of size such that . This indeed suffices, as for the distribution the probability of sampling all zeros in is exactly , while the granularity of the inputs to implies that outputs all zeros in with probability either 0 or at least . Therefore,
In order to find such set , note that the graph has vertices and edges. Therefore, for .
We use the following lemma, saying that any sufficiently dense graph contains a set of vertices that span at least edges, such that .
Lemma 26 (Theorem 2 in [19]).
Let be a multigraph with vertices and edges for some . There exists a set of vertices of size spanning at least edges.
Applying Lemma 26 to , we get a subset of the vertices of size that spans at least edges. By taking the minimal such subset , we may assume111Otherwise, if has a vertex with , we can remove from , and the remaining subset will also satisfy the property that and it spans at least edges. that all vertices have at least two neighbours in .
The key step of the proof is summarized in the following claim.
Claim 27.
Let be the bipartite subgraph of induced by with and , and let . Then .
Proof.
Since , there must be at least one vertex in of degree . Recall that all vertices in have degree either 2 or 3, and denote by the number of vertices in of degree 3. Consider the following two cases.
-
: Since all vertices in have degree 2, the set must have a vertex of degree in . Furthermore, , and hence by counting degrees of the vertices in , we have . Finally, note that each has at most one neighbour outside , and thus .
-
: By counting the degrees of in note that . Similarly, by counting the degrees of in , we have . Finally, there are exactly nodes with one neighbour outside , and nodes with no neighbours outside . Therefore,
Since is an integer and , it follows that .
In both cases we showed that , as required. Therefore, letting , we get a set of size such that . By the discussion above this implies that
This completes the proof of Theorem 25.
7 A -local construction with that is -close to
In this section we prove that 4-local samplers can approximate the distribution within exponentially small distance.
Theorem 28.
Let be sufficiently large, and let . Then, there exists a -local mapping such that
for some absolute constant .
The proof of Theorem 28 relies on the following lemma.
Lemma 29.
Let be parameters such that , and let be a matrix such that every row of has exactly ones. Then, there exists a -local sampler satisfying
| (6) |
where is the submatrix of obtained by taking only the rows of with indices in .
Proof.
Define by . Clearly, is -local. By Claim 7, for a uniform subset ,
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 there exists a matrix with exactly 3 ones in every row and 4 ones in each column such that for a uniform subset ,
Theorem 28 immediately follows from applying Lemma 29 to Theorem 30.
Proof of Theorem 28.
Let be the matrix from Theorem 30, which has 3 ones in each row. By Lemma 29, there is a 4-local sampler such that .
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 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 regular ramanujan graphs for every prime power . 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.
