Bell Numbers
Combinatorics
The Bell numbers describe all the ways you can group the elements of a set. They hide in plain sight in statistical mechanics, organizing stuff, neural networks, and Bayesian inference.
Why organizing stuff is difficult
You're writing some program and you're trying to figure out how to organize it.
You write an integrator that uses Simpson's rule, then one that does Monte Carlo,
then one that does the trapezoidal rule — do you make separate functions? Do you
make a class? What about your date parser — does it go in io.py or
string_utils.py? Does your rounding helper go in math.py
or format.py? The scheme is vague, and there are many different ways
to organize things — and "many different ways" is something approximating a Bell
number of ways.
| functions | ways to organize them |
|---|---|
| 5 | 52 |
| 10 | 115,975 |
| 15 | 1,382,958,545 |
| 20 | 51,724,158,235,372 |
Twenty functions has more partition schemes than there are seconds in 1.6 million years. Most of those schemes are equally valid; a few are "obviously right" because of coupling and cohesion; and the criteria for "right" are themselves vague. You're navigating a Bell-numbered space with a fuzzy objective. No wonder file structure debates take so long.