# Ordered Bell number

In number theory and enumerative combinatorics, the ordered Bell numbers or Fubini numbers count the weak orderings on a set of $n$ elements. Weak orderings arrange their elements into a sequence allowing ties, such as might arise as the outcome of a horse race.
The ordered Bell numbers were studied in the 19th century by Arthur Cayley and William Allen Whitworth. They are named after Eric Temple Bell, who wrote about the Bell numbers, which count the partitions of a set; the ordered Bell numbers count partitions that have been equipped with a total order. Their alternative name, the Fubini numbers, comes from a connection to Guido Fubini and Fubini's theorem on equivalent forms of multiple integrals. Because weak orderings have many names, ordered Bell numbers may also be called by those names, for instance as the numbers of preferential arrangements or the numbers of asymmetric generalized weak orders.
These numbers may be computed via a summation formula involving binomial coefficients, or by using a recurrence relation. They also count combinatorial objects that have a bijective correspondence to the weak orderings, such as the ordered multiplicative partitions of a squarefree number or the faces of all dimensions of a permutohedron.

## Definitions and examples

Weak orderings arrange their elements into a sequence allowing ties. This possibility describes various real-world scenarios, including certain sporting contests such as horse races. A weak ordering can be formalized axiomatically by a partially ordered set for which incomparability is an equivalence relation. The equivalence classes of this relation partition the elements of the ordering into subsets of mutually tied elements, and these equivalence classes can then be linearly ordered by the weak ordering. Thus, a weak ordering can be described as an ordered partition, a partition of its elements and a total order on the sets of the partition. For instance, the ordered partition {a,b},{c},{d,e,f} describes an ordered partition on six elements in which a and b are tied and both less than the other four elements, and c is less than d, e, and f, which are all tied with each other.
The $n$th ordered Bell number, denoted here $a(n)$, gives the number of distinct weak orderings on $n$ elements. For instance, there are three weak orderings on the two elements a and b: they can be ordered with a before b, with b before a, or with both tied. The figure shows the 13 weak orderings on three elements.
Starting from $n=0$, the ordered Bell numbers $a(n)$ are
When the elements to be ordered are unlabeled (only the number of elements in each tied set matters, not their identities) what remains is a composition or ordered integer partition, a representation of $n$ as an ordered sum of positive integers. For instance, the ordered partition {a,b},{c},{d,e,f} discussed above corresponds in this way to the composition 2 + 1 + 3. The number of compositions of $n$ is exactly $2^{n-1}$. This is because a composition is determined by its set of partial sums, which may be any subset of the integers from 1 to $n-1$.

## History

The ordered Bell numbers appear in the work of Cayley (1859), who used them to count certain plane trees with $n+1$ totally ordered leaves. In the trees considered by Cayley, each root-to-leaf path has the same length, and the number of nodes at distance $i$ from the root must be strictly smaller than the number of nodes at distance $i+1$, until reaching the leaves. In such a tree, there are $n$ pairs of adjacent leaves, that may be weakly ordered by the height of their lowest common ancestor; this weak ordering determines the tree. Mor & Fraenkel (1984) call the trees of this type "Cayley trees", and they call the sequences that may be used to label their gaps (sequences of $n$ positive integers that include at least one copy of each positive integer between one and the maximum value in the sequence) "Cayley permutations".
Pippenger (2010) traces the problem of counting weak orderings, which has the same sequence as its solution, to the work of Whitworth (1886). These numbers were called Fubini numbers by Louis Comtet, because they count the different ways to rearrange the ordering of sums or integrals in Fubini's theorem, which in turn is named after Guido Fubini. The Bell numbers, named after Eric Temple Bell, count the partitions of a set, and the weak orderings that are counted by the ordered Bell numbers may be interpreted as a partition together with a total order on the sets in the partition.
The equivalence between counting Cayley trees and counting weak orderings was observed in 1970 by Donald Knuth, using an early form of the On-Line Encyclopedia of Integer Sequences (OEIS). This became one of the first successful uses of the OEIS to discover equivalences between different counting problems.

## Formulas
### Summation

Because weak orderings can be described as total orderings on the subsets of a partition, one can count weak orderings by counting total orderings and partitions, and combining the results appropriately. The Stirling numbers of the second kind, denoted $\{{\scriptstyle {n \atop k}}\}$, count the partitions of an $n$-element set into $k$ nonempty subsets. A weak ordering may be obtained from such a partition by choosing one of $k!$ total orderings of its subsets. Therefore, the ordered Bell numbers can be counted by summing over the possible numbers of subsets in a partition (the parameter $k$) and, for each value of $k$, multiplying the number of partitions $\{{\scriptstyle {n \atop k}}\}$ by the number of total orderings $k!$. That is, as a summation formula: $a(n)=\sum _{k=0}^{n}k!\left\{{\begin{matrix}n\\k\end{matrix}}\right\}$ By general results on summations involving Stirling numbers, it follows that the ordered Bell numbers are log-convex, meaning that they obey the inequality $a(n-1)a(n+1)\geq a(n)^{2}$ for all $n>0$.
An alternative interpretation of the terms of this sum is that they count the features of each dimension in a permutohedron of dimension $n$, with the $k$th term counting the features of dimension $n-k$. A permutohedron is a convex polytope, the convex hull of points whose coordinate vectors are the permutations of the numbers from 1 to $n$. These vectors are defined in a space of dimension $n+1$, but they and their convex hull all lie in an $n$-dimensional affine subspace. For instance, the three-dimensional permutohedron is the truncated octahedron, the convex hull of points whose coordinates are permutations of (1,2,3,4), in the three-dimensional subspace of points whose coordinate sum is 10. This polyhedron has one volume ($k=0$), 14 two-dimensional faces ($k=1$), 36 edges ($k=2$), and 24 vertices ($k=3$). The total number of these faces is 1 + 14 + 36 + 24 = 75, an ordered Bell number, corresponding to the summation formula above for $n=3$.
By expanding each Stirling number in this formula into a sum of binomial coefficients, the formula for the ordered Bell numbers may be expanded out into a double summation. The ordered Bell numbers may also be given by an infinite series: $a(n)=\sum _{k=0}^{n}\sum _{j=0}^{k}(-1)^{k-j}{\binom {k}{j}}j^{n}={\frac {1}{2}}\sum _{m=0}^{\infty }{\frac {m^{n}}{2^{m}}}.$
Another summation formula expresses the ordered Bell numbers in terms of the Eulerian numbers $\langle {\scriptstyle {n \atop k}}\rangle$, which count the permutations of $n$ items in which $k$ pairs of consecutive items are in increasing order: $a(n)=\sum _{k=0}^{n-1}2^{k}\left\langle {\begin{matrix}n\\k\end{matrix}}\right\rangle =A_{n}(2),$ where $A_{n}$ is the $n$th Eulerian polynomial. One way to explain this summation formula involves a mapping from weak orderings on the numbers from 1 to $n$ to permutations, obtained by sorting each tied set into numerical order. Under this mapping, each permutation with $k$ consecutive increasing pairs comes from $2^{k}$ weak orderings, distinguished from each other by the subset of the consecutive increasing pairs that are tied in the weak ordering.

### Generating function and approximation

As with many other integer sequences, reinterpreting the sequence as the coefficients of a power series and working with the function that results from summing this series can provide useful information about the sequence. The fast growth of the ordered Bell numbers causes their ordinary generating function to diverge; instead the exponential generating function is used. For the ordered Bell numbers, it is: $\sum _{n=0}^{\infty }a(n){\frac {x^{n}}{n!}}={\frac {1}{2-e^{x}}}.$ Here, the left hand side is just the definition of the exponential generating function and the right hand side is the function obtained from this summation. The form of this function corresponds to the fact that the ordered Bell numbers are the numbers in the first column of the infinite matrix $(2I-P)^{-1}$. Here $I$ is the identity matrix and $P$ is an infinite matrix form of Pascal's triangle. Each row of $P$ starts with the numbers in the same row of Pascal's triangle, and then continues with an infinite repeating sequence of zeros.
Based on a contour integration of this generating function, the ordered Bell numbers can be expressed by the infinite sum $a(n)={\frac {n!}{2}}\sum _{k=-\infty }^{\infty }(\log 2+2\pi ik)^{-(n+1)},\qquad n\geq 1.$ Here, $\log$ stands for the natural logarithm. This leads to an approximation for the ordered Bell numbers, obtained by using only the term for $k=0$ in this sum and discarding the remaining terms: $a(n)\sim {\frac {1}{2}}{n!}\,c^{n+1},$ where $c={\tfrac {1}{\log 2}}\approx 1.4427$. Thus, the ordered Bell numbers are larger than the factorials by an exponential factor. Here, as in Stirling's approximation to the factorial, the $\sim$ indicates asymptotic equivalence. That is, the ratio between the ordered Bell numbers and their approximation tends to one in the limit as $n$ grows arbitrarily large. As expressed in little o notation, the relative error is $1\pm o(1)$, and the $o(1)$ error term decays exponentially as $n$ grows.
Comparing the approximations for $a(n-1)$ and $a(n)$ shows that $\lim _{n\to \infty }{\frac {n\,a(n-1)}{a(n)}}=\log 2.$ For example, taking $n=5$ gives the approximation $375/541\approx 0.693161$ to $\log 2\approx 0.693145$. This sequence of approximations, and this example from it, were calculated by Ramanujan, using a general method for solving equations numerically (here, the equation $e^{x}=2$).

### Recurrence and modular periodicity

As well as the formulae above, the ordered Bell numbers may be calculated by the recurrence relation
    $a(n)=\sum _{i=1}^{n}{\binom {n}{i}}a(n-i).$
The intuitive meaning of this formula is that a weak ordering on $n$ items may be broken down into a choice of some nonempty set of $i$ items that go into the first equivalence class of the ordering, together with a smaller weak ordering on the remaining $n-i$ items. There are ${\tbinom {n}{i}}$ choices of the first set, and $a(n-i)$ choices of the weak ordering on the rest of the elements. Multiplying these two factors, and then summing over the choices of how many elements to include in the first set, gives the number of weak orderings, $a(n)$. As a base case for the recurrence, $a(0)=1$ (there is one weak ordering on zero items). Based on this recurrence, these numbers can be shown to obey certain periodic patterns in modular arithmetic: for sufficiently large $n$,
$a(n+4)\equiv a(n){\pmod {10}},$
$a(n+20)\equiv a(n){\pmod {100}},$
$a(n+100)\equiv a(n){\pmod {1000}},$
$a(n+500)\equiv a(n){\pmod {10000}}.$
Many more modular identities are known, including identities modulo any prime power. Peter Bala has conjectured that this sequence is eventually periodic (after a finite number of terms) modulo each positive integer $k$, with a period that divides Euler's totient function of $k$, the number of residues mod $k$ that are relatively prime to $k$.

## Applications
### Combinatorial enumeration

As has already been mentioned, the ordered Bell numbers count weak orderings, permutohedron faces, Cayley trees, Cayley permutations, and equivalent formulae in Fubini's theorem. Weak orderings in turn have many other applications. For instance, in horse racing, photo finishes have eliminated most but not all ties, called in this context dead heats, and the outcome of a race that may contain ties (including all the horses, not just the first three finishers) may be described using a weak ordering. For this reason, the ordered Bell numbers count the possible number of outcomes of a horse race. In contrast, when items are ordered or ranked in a way that does not allow ties (such as occurs with the ordering of cards in a deck of cards, or batting orders among baseball players), the number of orderings for $n$ items is a factorial number $n!$, which is significantly smaller than the corresponding ordered Bell number.
Problems in many areas can be formulated using weak orderings, with solutions counted using ordered Bell numbers. Velleman & Call (1995) consider combination locks with a numeric keypad, in which several keys may be pressed simultaneously and a combination consists of a sequence of keypresses that includes each key exactly once. As they show, the number of different combinations in such a system is given by the ordered Bell numbers. In seru, a Japanese technique for balancing assembly lines, cross-trained workers are allocated to groups of workers at different stages of a production line. The number of alternative assignments for a given number of workers, taking into account the choices of how many stages to use and how to assign workers to each stage, is an ordered Bell number. As another example, in the computer simulation of origami, the ordered Bell numbers give the number of orderings in which the creases of a crease pattern can be folded, allowing sets of creases to be folded simultaneously.
In number theory, an ordered multiplicative partition of a positive integer is a representation of the number as a product of one or more of its divisors. For instance, 30 has 13 multiplicative partitions, as a product of one divisor (30 itself), two divisors (for instance 6 · 5), or three divisors (3 · 5 · 2, etc.). An integer is squarefree when it is a product of distinct prime numbers; 30 is squarefree, but 20 is not, because its prime factorization 2 · 2 · 5 repeats the prime 2. For squarefree numbers with $n$ prime factors, an ordered multiplicative partition can be described by a weak ordering on its prime factors, describing which prime appears in which term of the partition. Thus, the number of ordered multiplicative partitions is given by $a(n)$. On the other hand, for a prime power with exponent $n$, an ordered multiplicative partition is a product of powers of the same prime number, with exponents summing to $n$, and this ordered sum of exponents is a composition of $n$. Thus, in this case, there are $2^{n-1}$ ordered multiplicative partitions. Numbers that are neither squarefree nor prime powers have a number of ordered multiplicative partitions that (as a function of the number of prime factors) is between these two extreme cases.
A parking function, in mathematics, is a finite sequence of positive integers with the property that, for every $i$ up to the sequence length, the sequence contains at least $i$ values that are at most $i$. A sequence of this type, of length $n$, describes the following process: a sequence of $n$ cars arrives on a street with $n$ parking spots. Each car has a preferred parking spot, given by its value in the sequence. When a car arrives on the street, it parks in its preferred spot, or, if that is full, in the next available spot. A sequence of preferences forms a parking function if and only if each car can find a parking spot on or after its preferred spot. The number of parking functions of length $n$ is exactly $(n+1)^{n-1}$. For a restricted class of parking functions, in which each car parks either on its preferred spot or on the next spot, the number of parking functions is given by the ordered Bell numbers. Each restricted parking function corresponds to a weak ordering in which the cars that get their preferred spot are ordered by these spots, and each remaining car is tied with the car in its preferred spot. The permutations, counted by the factorials, are parking functions for which each car parks on its preferred spot. This application also provides a combinatorial proof for upper and lower bounds on the ordered Bell numbers of a simple form, $n!\leq a(n)\leq (n+1)^{n-1}.$
The ordered Bell number $a(n)$ counts the number of faces in the Coxeter complex associated with a Coxeter group of type $A_{n-1}$. Here, a Coxeter group can be thought of as a finite system of reflection symmetries, closed under repeated reflections, whose mirrors partition a Euclidean space into the cells of the Coxeter complex. For instance, $a(3)=13$ corresponds to $A_{2}$, the system of reflections of the Euclidean plane across three lines that meet at the origin at $60^{\circ }$ angles. The complex formed by these three lines has 13 faces: the origin, six rays from the origin, and six regions between pairs of rays.
Kemeny (1956) uses the ordered Bell numbers to analyze n-ary relations, mathematical statements that might be true of some choices of the $n$ arguments to the relation and false for others. He defines the "complexity" of a relation to mean the number of other relations one can derive from the given one by permuting and repeating its arguments. For instance, for $n=2$, a relation on two arguments $x$ and $y$ might take the form $y=f(x)$. By Kemeny's analysis, it has $a(n)=3$ derived relations. These are the given relation $y=f(x)$, the converse relation $x=f(y)$ obtained by swapping the arguments, and the unary relation $x=f(x)$ obtained by repeating an argument. (Repeating the other argument produces the same relation.)
Ellison & Klein (2001) apply these numbers to optimality theory in linguistics. In this theory, grammars for natural languages are constructed by ranking certain constraints, and (in a phenomenon called factorial typology) the number of different grammars that can be formed in this way is limited to the number of permutations of the constraints. A paper reviewed by Ellison and Klein suggested an extension of this linguistic model in which ties between constraints are allowed, so that the ranking of constraints becomes a weak order rather than a total order. As they point out, the much larger magnitude of the ordered Bell numbers, relative to the corresponding factorials, allows this theory to generate a much richer set of grammars.

### Other

If a fair coin (with equal probability of heads or tails) is flipped repeatedly until the first time the result is heads, the number of tails follows a geometric distribution. The moments of this distribution are the ordered Bell numbers.
Although the ordinary generating function of the ordered Bell numbers fails to converge, it describes a power series that (evaluated at ${\tfrac {1}{n}}$ and then multiplied by ${\tfrac {2}{n}}$) provides an asymptotic expansion for the resistance distance of opposite vertices of an $n$-dimensional hypercube graph. Truncating this series to a bounded number of terms and then applying the result for unbounded values of $n$ approximates the resistance to arbitrarily high order.
In the algebra of noncommutative rings, an analogous construction to the (commutative) quasisymmetric functions produces a graded algebra WQSym whose dimensions in each grade are given by the ordered Bell numbers.
In spam filtering, the problem of assigning weights to sequences of words with the property that the weight of any sequence exceeds the sum of weights of all its subsequences can be solved by using weight $W(n)$ for a sequence of $n$ words, where $W(n)$ is obtained from the recurrence equation $W(n)=1+\sum _{k=1}^{n-1}{\binom {n}{k}}W(n-1),$ with base case $W(1)=0$. This recurrence differs from the one given earlier for the ordered Bell numbers, in two respects: omitting the $W(0)$ term from the sum (because only nonempty sequences are considered), and adding one separately from the sum (to make the result exceed, rather than equalling, the sum). These differences have offsetting effects, and the resulting weights are the ordered Bell numbers.