English

Efficient Uniform Sampling of Surjections via their Profiles

Data Structures and Algorithms 2026-05-26 v1 Discrete Mathematics Probability

Abstract

In this article, we develop efficient sampling algorithms for random surjections from [n][n] to [k][k] for all nkn \geq k. We make no assumption about nn and kk. In particular, we do not make the common assumption that the ratio nk\frac{n}{k} is constant. All our guarantees are uniform in nn and kk. Our first insight is that all the complexity in sampling random surjections is captured by sampling a smaller structure which we call the \emph{profile} of the surjection. More precisely, the profile associates to each occurring preimage size ss the number of preimages of size ss. Using standard techniques, we show that the problem of sampling surjections reduces to sampling the profile with the induced distribution. This is partly explained by the fact that profiles are always sublinear, with at most 2n\sqrt{2n} entries in the worst case. We provide a complete set of algorithms to directly sample the \emph{profile} of a random surjection with the induced distribution, covering the full parameter space. These algorithms are shown to be optimal up to logarithmic factors in the expected size of the output. Our algorithms are based on exact-size Boltzmann samplers, which are standard rejection-based samplers. We partition the parameter space into three main regions. In each region, we optimize both the rejection rate and the cost of each sampling round. Profiles capture a number of relevant statistics of random surjections and might be of independent interest. In a related context, profiles have been recently studied by Devroye et al. for random mappings. As a spin-off result, we answer an open question from Devroye and Los '25 by providing an optimal algorithm also for the profiles of a random mapping when k>n/lognk > n/\log n. The results of this article are not only of theoretical interest but lead to samplers implementable in practice.

Keywords

Cite

@article{arxiv.2605.24068,
  title  = {Efficient Uniform Sampling of Surjections via their Profiles},
  author = {Arnaud Carayol and Pablo Rotondo},
  journal= {arXiv preprint arXiv:2605.24068},
  year   = {2026}
}
R2 v1 2026-07-22T07:29:10.323Z