A Boltzmann sampler is an algorithm intended for random sampling of combinatorial structures. If the object size is viewed as its energy, and the argument of the corresponding generating function is interpreted in terms of the temperature of the physical system, then a Boltzmann sampler returns an object from a classical Boltzmann distribution. The concept of Boltzmann sampler was proposed by Philippe Duchon, Philippe Flajolet, Guy Louchard and Gilles Schaeffer in 2004.
Description The concept of Boltzmann sampling is closely related to the symbolic method in combinatorics. Let 𝒞 be a combinatorial class with an ordinary generating function C(z) which has a nonzero radius of convergence ρ, i.e. is complex analytic. Formally speaking, if each object c∈𝒞 is equipped with a non-negative integer size ω(c), then the generating function C(z) is defined as
C(z)=∑c∈𝒞zω(c)=∑n=0∞anzn, where an denotes the number of objects c∈𝒞 of size n. The size function is typically used to denote the number of vertices in a tree or in a graph, the number of letters in a word, etc. A Boltzmann sampler for the class 𝒞 with a parameter z such that 0<z<ρ, denoted as Γ𝒞(z) returns an object c∈𝒞 with probability
ℙ(Γ𝒞(z)=c)=zω(c)C(z).
Construction
Finite sets If 𝒞={c1,…,cr} is finite, then an element cj is drawn with probability proportional to zω(cj).
Disjoint union If the target class is a disjoint union of two other classes, 𝒞=𝒜+ℬ, and the generating functions A(z) and B(z) of 𝒜 and ℬ are known, then the Boltzmann sampler for 𝒞 can be obtained as
(Bern(A(z)C(z))⟶Γ𝒜(z)∣Γℬ(z)) where (X⟶f∣g) stands for "if the random variable X is 1, then execute f, else execute g". More generally, if the disjoint union is taken over a finite set, the resulting Boltzmann sampler can be represented using a random choice with probabilities proportional to the values of the generating functions.
Cartesian product If 𝒞=𝒜×ℬ is a class constructed of ordered pairs (a,b) where a∈𝒜 and b∈ℬ, then the corresponding Boltzmann sampler Γ𝒞(z) can be obtained as
Γ𝒞(z)=(Γ𝒜(z),Γℬ(z)), i.e. by forming a pair (a,b) with a and b drawn independently from Γ𝒜(z) and Γℬ(z).
Sequence If 𝒞 is composed of all the finite sequences of elements of 𝒜 with size of a sequence additively inherited from sizes of components, then the generating function of 𝒞 is expressed as C(z)=∑k=0∞A(z)k=11−A(z), where A(z) is the generating function of 𝒜. Alternatively, the class 𝒞 admits a recursive representation 𝒞=1+𝒜×𝒞. This gives two possibilities for Γ𝒞(z).
Γ𝒞(z)=Γ(1+𝒜×𝒞)(z)=(Bern(1C(z))⟶1|(Γ𝒜(z),Γ𝒞(z))) Γ𝒞(z)=(Geom(A(z))⟹Γ𝒞(z)) where (X⟹f) stands for "draw a random variable X; if the value X=x is returned, then execute f independently x times and return the sequence obtained". Here, Geom(p) stands for the geometric distribution ℙ(Geom(p)=k)=pk(1−p).
Recursive classes As the first construction of the sequence operator suggests, Boltzmann samplers can be used recursively. If the target class 𝒞 is a part of the system
{𝒞1=Φ1(𝒞1,…,𝒞n,𝒵),⋮𝒞n=Φn(𝒞1,…,𝒞n,𝒵), where each of the expressions Φk(𝒞1,…,𝒞n,𝒵) involves only disjoint union, cartesian product and sequence operator, then the corresponding Boltzmann sampler is well defined. Given the argument value z, the numerical values of the generating functions can be obtained by Newton iteration.
Labelled structures Boltzmann sampling can be applied to labelled structures. For a labelled combinatorial class 𝒞, exponential generating function is used instead:
C(z)=∑c∈𝒞zω(c)ω(c)!=∑n=0∞anznn!, where an denotes the number of labelled objects c∈𝒞 of size n. The operation of cartesian product and sequence need to be adjusted to take labelling into account, and the principle of construction remains the same. In the labelled case, the Boltzmann sampler for a labelled class 𝒞 is required to output an object c∈𝒞 with probability
ℙ(Γ𝒞(z)=c)=1C(z)zω(c)ω(c)!.
Labelled sets In the labelled universe, a class 𝒞 can be composed of all the finite sets of elements of a class 𝒜 with order-consistent relabellings. In this case, the exponential generating function of the class 𝒞 is written as
C(z)=∑k=0∞A(z)kk!=eA(z) where A(z) is the exponential generating function of the class 𝒜. The Boltzmann sampler for 𝒞 can be described as
Γ𝒞(z)=(Poisson(A(z))⟹Γ𝒞(z)) where Poisson(λ) stands for the standard Poisson distribution ℙ(Poisson(λ)=k)=e−λλkk!.
Labelled cycles In the cycle construction, a class 𝒞 is composed of all the finite sequences of elements of a class 𝒜, where two sequences are considered equivalent if they can be obtained by a cyclic shift. The exponential generating function of the class 𝒞 is written as
C(z)=∑k=0∞A(z)kk=log11−A(z) where A(z) is the exponential generating function of the class 𝒜. The Boltzmann sampler for 𝒞 can be described as
Γ𝒞(z)=(Loga(A(z))⟹Γ𝒞(z)) where Loga(λ) describes the log-law distribution ℙ(Loga(λ)=k)=1log(1−λ)−1λkk.
Properties Let N denote the random size of the generated object from Γ𝒞(z). Then, the size has the first and the second moment satisfying
𝔼z(N)=zC′(z)C(z); 𝔼z(N2)=z2C″(z)+zC′(z)C(z); zddz𝔼z(N)=Varz(N).
Examples
Binary trees The class ℬ of binary trees can be defined by the recursive specification
ℬ=𝒵+𝒵×ℬ×ℬ and its generating function B(z) satisfies an equation B(z)=z+zB(z)2 and can be evaluated as a solution of the quadratic equation
B(z)=1−1−4z22z The resulting Boltzmann sampler can be described recursively by
Γℬ(z)=(Bern(zB(z))⟶𝒵∣(𝒵,Γℬ(z),Γℬ(z)))
Set partitions Consider various partitions of the set {1,2,…,n} into several non-empty classes, being disordered between themselves. Using symbolic method, the class 𝒞 of set partitions can be expressed as
𝒞=Set(Set>0(𝒵)). The corresponding generating function is equal to C(z)=eez−1. Therefore, Boltzmann sampler can be described as
Γ𝒞=(Poisson(ez−1)⟹(Poisson>0(z)⟹𝒵)), where the positive Poisson distribution Poisson>0(λ) is a Poisson distribution with a parameter λ conditioned to take only positive values.
Further generalisations The original Boltzmann samplers described by Philippe Duchon, Philippe Flajolet, Guy Louchard and Gilles Schaeffer only support basic unlabelled operations of disjoint union, cartesian product and sequence, and two additional operations for labelled classes, namely the set and the cycle construction. Since then, the scope of combinatorial classes for which a Boltzmann sampler can be constructed, has expanded.
… excerpt ends here. Continue reading the full article.