Understanding iterative method to calculate binomial coefficients for distribution

138 Views Asked by At

I am currently implementing an algorithm which involves calculating binomial coefficients. The paper (https://arxiv.org/pdf/cond-mat/0101295.pdf) recommends the following method for finding B(N,n,p)=${N}\choose{n}$$p^n(1-p)^{N-n}$.

The binomial distribution, Eq. (1), has its largest value for given N and p when $n = n_{max} = pN$. We arbitrarily set this value to 1. (We will fix it in a moment.) Now we calculate B(N, n, p) iteratively for all other n from:

$B(N, n, p) = B(N, n-1, p)\frac{N-n+1}{n}\frac{p}{1-p}, n>n_{max}$

$=B(N, n+1, p)\frac{n+1}{N-n}\frac{1-p}{p}, n<n_{max}$

Then we calculate the normalization coefficient $C = \sum{B(N, n, p)}$ and divide all the B(N, n, p) by it, to correctly normalize the distribution.

Should all values of n be normalised by $n_{max}$ (as this value has been set to 1)? If so, then by starting with B(N,0,p) and calculating B(N,1,p)... the correct values of n will not be considered. How should the coefficients be evaluated?

1

There are 1 best solutions below

2
On BEST ANSWER

The best way to explain the process is to illustrate with an example.

Suppose $N = 6$ and $p = 1/3$. Then the first step says that the maximum is going to be around $n_{\text{max}} = Np = 2$. So we let $B(6, 2, 1/3) = 1$ and compute for $n \in \{3,4,5,6\}$ the recursion $$B(6,n,1/3) = B(6,n-1,1/3) \frac{6-n+1}{n} \frac{1/3}{1 - 1/3} = \frac{7-n}{2n} B(6,n-1,1/3).$$ This gives us the following table of values:

$$\begin{array}{c|c|c} n & \frac{7-n}{2n} & B(6,n,1/3) \\ \hline 2 & - & \color{red}{1} \\ 3 & \frac{4}{6} & \frac{2}{3} \\ 4 & \frac{3}{8} & \frac{1}{4} \\ 5 & \frac{2}{10} & \frac{1}{20} \\ 6 & \frac{1}{12} & \frac{1}{240} \end{array}$$ For the row $n = 2$, we set this value to $1$, which is why I have indicated it in red, as these are not the actual probabilities (but they are likelihoods), because we have not done the final step. Next, we have to use the backward recursion to compute $B$ for the other values of $n$: $$B(6,n,1/3) = B(6,n+1,1/3) \frac{\color{blue}{n}+1}{6-n} \frac{1-1/3}{1/3} = \frac{2(n+1)}{6-n} B(6,n+1,1/3).$$ Note that you have an error in your formula; it should be lowercase $n$, not uppercase $N$. This gives $$\begin{array}{c|c|c} n & \frac{2(n+1)}{6-n} & B(6,n,1/3) \\ \hline 2 & - & \color{red}{1} \\ 1 & \frac{4}{5} & \frac{4}{5} \\ 0 & \frac{2}{6} & \frac{4}{15} \\ \end{array}$$

As the final step, we add all of the values of $B$ for every $n \in \{0, 1, \ldots, 6\}$. This gives us a total of $$\sum_{n=0}^6 B(6,n,1/3) = \frac{243}{80},$$ and this is the normalizing value we need to divide $B(6,n,1/3)$ by to get the desired probabilities. In particular,

$$\begin{array}{c|c} n & \binom{6}{n} (1/3)^n (1 - 1/3)^{6-n} \\ \hline 0 & \frac{64}{729} \\ 1 & \frac{64}{243} \\ 2 & \frac{80}{243} \\ 3 & \frac{160}{729} \\ 4 & \frac{20}{243} \\ 5 & \frac{4}{243} \\ 6 & \frac{1}{729} \\ \end{array}$$