Showing posts with label combinatorics. Show all posts
Showing posts with label combinatorics. Show all posts

Sunday, January 24, 2016

Big numbers, big confusion; small numbers, bigger confusion.

I can make something almost impossible happen. And so can you.

Let's start by defining what "almost impossible" means. Less than one-in-a-trillion chance? How about less than one in a trillion-trillion chance? One in a trillion-trillion-trillion chance?

Ok, lets take a breath here. What's this trillion-trillion and trillion-etc stuff?

(In my observation, economists say million, billion, trillion, and all their audiences hear is "big number." Innumeracy over scale has bad consequences when applied to public policy.)

One trillion is 1,000,000,000,000. (Yes, I'm using American billions, pretty much like everyone else now does.) This is written as $10^{12}$. A trillion trillion is $10^{12} \times 10^{12} = 10^{24}$ and a trillion-trillion-trillion is $10^{36}$, a one followed by thirty-six zeros.

To put that number in perspective, the age of the Earth is about $4.5$ billion years, or about $1.42 \times 10^{17}$ seconds. That's 142,000 trillion seconds. Note that this is much smaller than a trillion-trillion seconds (it's over one seven-millionth of a trillion-trillion), let alone a trillion-trillion-trillion. If you had seven million planets the same age as the Earth, and you picked at random one specific second in the history in one specific planet you'd would have about a one in a trillion-trillion chance of picking this precise second on this planet. A one in a trillion-trillion-trillion chance is one trillion times smaller than that.

So, something that has a one in a trillion-trillion-trillion chance of happening has to be a very low probability event. Shall we call anything less likely than that "almost impossible"? We shall.

So, here's how I make something almost impossible happen, over and over again, and you can too: shuffle a deck of cards.

Using only 52 cards (no jokers), there are $52! = 52\times 51 \times \ldots \times 2$ possible card shuffles, and $52! \approx 8.1 \times 10^{67}$. That number is $8.1\times 10^{31}$ times bigger than a trillion-trillion-trillion.

And yet, every card shuffle produces an event with 1-in-$8.1 \times 10^{67}$ probability. You and I can generate scores of these "almost impossible" events using a simple deck of cards.

(A little thinking will lead an attentive reader to the solution to this apparent paradox. It's not a paradox. I will post a solution here in a few days, if I remember :-)

-- -- -- --

Just for fun, a simple brain teaser:

Imagine you have two decks of 52 cards (blue and red); what has more possible combinations, shuffling the two decks together and dividing into two piles of 52 cards by separating in the middle of the full shuffled two decks, or shuffling the two decks separately each into its pile?

(Yes, it's obvious for anyone conversant with combinatorics, but apparently not everyone is conversant with combinatorics. Common answer: "it's the same.")

Monday, December 12, 2011

How many possible topologies can a N-node network have?

Short answer, for an undirected network: $2^{N(N-1)/2}$.

Essentially the number of edges is $N(N-1)/2$ so the number of possible topologies is two raised to the number of edges, capturing every possible case where an edge can either be present or absent. For a directed network the number of edges is twice that of those in an undirected network so the number of possible topologies is the square (or just remove the $/2$ part from the formula above).

To show how quickly things get out of control, here are some numbers:

$N=1 \Rightarrow 1$ topology
$N=2 \Rightarrow 2$ topologies
$N=3 \Rightarrow 8$ topologies
$N=4 \Rightarrow 64$ topologies
$N=5 \Rightarrow 1024$ topologies
$N=6 \Rightarrow 32,768$ topologies
$N=7 \Rightarrow 2,097,152$ topologies
$N=8 \Rightarrow 268,435,456$ topologies
$N=9 \Rightarrow 68,719,476,736$ topologies
$N=10 \Rightarrow 35,184,372,088,832$ topologies
$N=20 \Rightarrow 1.5693 \times 10^{57}$ topologies
$N=30 \Rightarrow 8.8725 \times 10^{130}$ topologies
$N=40 \Rightarrow 6.3591 \times 10^{234}$ topologies
$N=50 \Rightarrow 5.7776 \times 10^{368}$ topologies

This is the reason why any serious analysis of a network requires the use of mathematical modeling and computer processing: our human brains are not equipped to deal with this kind of exploding complexity.

And for the visual learners, here's a graph denoting the pointlessness of trying to grasp network topologies "by hand" (note logarithmic vertical scale):

Number of network topologies as a function of the number of nodes

Thursday, July 28, 2011

A simple, often overlooked, problem with models

There are just too many possibilities.

Let's say we have one dependent variable, $y$, and ten independent variables, $x_1,\ldots,x_{10}$. How many models can we build? For simplicity let's keep our formulation linear (in the usual sense of the word, that is linear in the coefficients; see footnote).

Inexcusably wrong answer: 11 models.

Wrong answer: 1024 models.

Right-ish answer: $1.8 \times 10^{308}$ models.

Right answer: an infinity of models.

Ok, 1024 is the number of models which include at most one instance of each variable and no interaction. Something like

$ y = \beta_0 + \beta_1 \, x_1 +  \beta_3 \, x_3 + \beta_7 \, x_7$ ,

of which there are $2^{10}$ models. (Since the constant $\beta_0$ can be zero by calibration, we'll include it in all models -- otherwise we'd have to demean the $y$.)

Once we consider possible interactions among variables, like $x_1 x_7 x_8$ for example, a three-way interaction, there are $2^{10}$ variables and interactions and therefore $2^{2^{10}}= 1.8 \times 10^{308}$ possible models with all interactions. For comparison, the number of atoms in the known universe is estimated to be in the order of $10^{80}$.

Of course, each variable can enter the model in a variety of functional forms: $x_1^{2}$, $\log(x_7)$, $\sin(5 \, x_9)$ or $x_3^{-x_{2}/2}$, for example, making it an infinite number of possibilities. (And there can be interactions between these different functions of different variables, obviously.)

(Added on August 11th.) Using polynomial approximations for generalized functions, say to the fourth degree, the total number of interactions is now $5^{10}=9765625$, as any variable may enter an interaction in one of five orders (0 through 4), and the total number of models is $2^{5^{10}}$ or around $10^{3255000}$. (End of addition.)

So here's a combinatorial riddle for statisticians: how can you identify a model out of, let's be generous, $1.8 \times 10^{308}$ with data in the exa- or petabyte range? That's almost three hundred orders of magnitude too little, methinks.

The main point is that any non-trivial set of variables can be modeled in a vast number of ways, which means that a limited number of models presented for appreciation (or review) necessarily includes an inordinate amount of judgement from the model-builder.

It's unavoidable, but seldom acknowledged.

--------------

The "linear in coefficients" point is the following. Take the following formulation, which is clearly non-linear in the $x$:

$y = \beta_0 + \beta_1 \, x_1^{1/4} + \beta_2 \, x_1 \, x_7$

but can be made linear very easily by making two changes of variables: $ z_1 =  x_1^{1/4}$ and $z_2 =  x_1 \, x_7$.

In contrast, the model $y = \alpha \, \sin( \omega \, t )$ cannot be linearized in coefficients $\alpha$ and $\omega$.