# Hypothesis Space Entropy

In [Why quantitative finance is so hard](https://www.lesswrong.com/posts/knCyLy9Yjbczet7gD/why-quantitative-finance-is-so-hard) I explained why the entropy of your dataset must exceed the entropy of your hypothesis space. I used a simple hypothesis space with $n$ equally likely hypotheses each with $m$ tunable parameters. Real life is not usually so homogeneous.

# No Tunable Parameters

Consider an inhomogeneous hypothesis space with zero tunable parameters. Instead of $H=\log n$ which works for homogeneous hypothesis spaces, we must use more complicated entropy equation.

$$H=-\sum_{i=1}^n\rho_i\ln\rho_i$$

This equation makes intuitive sense. It vanishes when one $\rho_{i=j}$ equals 1 and all other $\rho_{i\neq j}$ equal 0. Our equation is extremized when all $\rho_i$ are equal at $\frac1n$. $H=\log n$ is the maximal case when $\rho_i=\frac1n\forall i\in\{1,\ldots,n\}$[^1].

[^1]: Proof: $$\begin{eqnarray*}H&=&-\sum_{i=1}^n\rho_i\ln\rho_i\\ &=&-\sum_{i=1}^n\frac1n\ln\frac1n\\ &=&-\ln\frac1n\\ &=&-\ln(n^{-1})\\ &=&\ln n\\ \end{eqnarray*}$$

# With Tunable Parameters

Suppose each hypothesis $i$ has $m_i$ tunable parameters. We can plug $m_i$ into our entropy equation.

$$H=\sum_{i=1}^n\rho_i(m_i-\ln\rho_i)$$

Our old equation $H=m+\log n$ is just the special case where all $\rho_i$ are homogenous and $m_i$ are homogeneous too. 

We have so far treated $m_i$ as representative of each hypothesis's tunable parameters. More generally, $m_i$ represents each hypothesis's internal entropy. If we think of hypotheses as a weighted tree, $m_i$ is what you get when you iterate one level down the tree. Our variable $H$ identifies the root of the tree. Suppose $i$th branch of the next level down is called $H_i$.

$$H=\sum_{i=1}^n\rho_i(H_i-\ln\rho_i)$$

We can define the entropy of the rest of the tree with a recursive equation.

$$\begin{eqnarray*}
H_\mu&=&\sum_{i=1}^n\rho_i(H_{\mu,i}-\ln\rho_i)\\
&=&\sum_{i=1}^n\left(\rho_iH_{\mu,i}-\rho_i\ln\rho_i\right)
\end{eqnarray*}$$

There are two parts to this equation: the **recursive component** $\rho_iH_{\mu,i}$ and the **branching component** $-\rho_i\ln\rho_i$.

## Branching component $-\rho_i\ln\rho_i$

The $-\rho_i\ln\rho_i$ component is maximized when $\rho_i=\frac1e$.

$$\begin{eqnarray*}
-\rho_i\ln\rho_i&=&-\frac1e\ln\frac1e\\
&=&\frac1e\ln e\\
&=&\frac1e
\end{eqnarray*}$$

The branching component tops out at $\frac1e$. It can never contribute a massive quantity of entropy to your hypothesis space because it is limited to $\frac1e$ entropy per level of the tree.

$$0\leq-\rho_i\ln\rho_i\leq\frac1e$$

The branching factor is mostly unimportant. The bulk of our entropy comes from the recursive component.

## Recursive component $\rho_iH_{\mu,i}$

Fix $\rho_i$ at a positive value. There is no limit to how big $H_{\mu,i}$ can become. You can make it arbitrarily large just by adding parameters. Consequently $\rho_iH_{\mu,i}$ can become arbitrarily large too. In real world situations we should expect the recursive components of our hypothesis space to dominate the branching components.

If $\rho_i$ vanishes then the recursive component disappears. This might explain why human minds like to round "extremely unlikely" $\epsilon>\rho_i>0$ to "impossible" $\rho_i=0$ when $H_{\mu,i}$ is large. It removes lots of entropy from our hypothesis space still being right almost all of the time. This may be related to synaptic pruning.

# Lessons for Hypothesis Space Design

Once again, we have confirmed that having hypotheses with lots of parameters is a worse problem that having lots of hypotheses to choose between. More generally, one or more hypotheses with exceptionally high entropy dominate the total entropy of your hypothesis space. If you want better priors then the first step of your optimization should be to eliminate these complex subtrees from your hypothesis space.