This series of posts are inspired by two questions that Jarrett Byrnes asked:

1. Given the extinction of E predators out of N, what is the probability that a prey species will still have at least one predator remaining?
2. Given E out of N, what then is the probability that all prey species will have at least one predator remaining?

As Jarrett and I have been discovering, these are actually quite difficult questions to answer in a general manner, i.e. for all topologies of a certain size!

Say we have a two trophic level food web with N predators, what is the probability that a prey species has at least one predator remaining after the extinction of E predators? The solution provided here depends on having the out-degree of prey species, and finding the probability that all predators of a prey species become extinct as a result of E. Say that the out-degree of the prey species is $s$, then that probability is a hypergeometric solution
$p(s=0 \vert E) = \binom{s}{s} \binom{N-s}{E-s} \binom{N}{E}^{-1}$
which reduces to
$p(s=0 \vert E) = \frac{E!(N-s)!}{N!(E-s)!}$
The probability then of a prey species having at least one prey is 1 minus the above
$p(s\geq 1 \vert E) = 1 - \frac{E!(N-s)!}{N!(E-s)!}$
that is, the sum of the probabilities of having 1 predator, 2 predators, etc.

## Example

Let the adjacency matrix of a food web be
$\mathbf{A} = \left ( \begin{array}{c c} 1 & 0\\ 1 & 1\\ 1 & 1 \end{array} \right )$
where predators are rows and prey are columns. Our prey out-degree set is therefore {3, 2}. For E=1, both prey will have at least one predator since their out-degrees both exceed 1. For E=2, the possible resulting topologies are
$\left ( \begin{array}{c c} 0 & 0\\ 0 & 0\\ 1 & 1 \end{array} \right ) \textrm{,} \left ( \begin{array}{c c} 0 & 0\\ 1 & 1\\ 0 & 0 \end{array} \right ) \textrm{and} \left ( \begin{array}{c c} 1 & 0\\ 0 & 0\\ 0 & 0 \end{array} \right )$
For s=2
$p(s\geq 1\vert E=2) = 1 - \frac{2!(3-2)!}{3!(2-2)!} = \frac{2}{3}$
This is correct since our prey species of out-degree 2 (second column of A) has at least one predator in two of our three post-extinction topologies. The probability should be zero for s=3 (since E<s). If we add a third prey species, with s=1, making
$\mathbf{A} = \left ( \begin{array}{c c c} 1 & 0 & 1\\ 1 & 1 & 0\\ 1 & 1 & 0 \end{array} \right )$
then for E=1, the post-extinction topologies are
$\left ( \begin{array}{c c c} 0 & 0 & 0\\ 1 & 1 & 0\\ 1 & 1 & 0 \end{array} \right ) \textrm{,} \left ( \begin{array}{c c c} 1 & 0 & 1\\ 0 & 0 & 0\\ 1 & 1 & 0 \end{array} \right ) \textrm{and} \left ( \begin{array}{c c c} 1 & 0 & 1\\ 1 & 1 & 0\\ 0 & 0 & 0 \end{array} \right )$
The probability that this third species has at least one prey is also 2/3.
$p(s\geq 1\vert E=1) = 1 - \frac{1!(3-1)!}{3!(1-1)!} = \frac{2}{3}$

## A further example

So far so good, right? Well, Jarrett posed this example,
$\mathbf{A} = \left ( \begin{array}{ccc}1 & 0 & 0\\ 1 & 1 & 1\\ 0 & 0 & 1 \end{array} \right )$
Notice that we now have two prey of out-degree 2. For E=1, the post-extinction topologies are
$\left ( \begin{array}{ccc} 0 & 0 & 0\\ 1 & 1 & 1\\ 0 & 0 & 1 \end{array} \right ) \textrm{,} \left ( \begin{array}{ccc}1 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 1 \end{array} \right ) \textrm{and} \left ( \begin{array}{ccc}1 & 0 & 0\\ 1 & 1 & 1\\ 0 & 0 & 0 \end{array} \right )$
Applying the above formula yields
$p(s\geq 1\vert E=1) = 1 - \frac{(3-1)!}{3!(1-1)!} = \frac{2}{3}$
which is correct, since two of the three topologies maintain at least one predator for each prey. When E=2, the topologies become
$\left ( \begin{array}{ccc} 0 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 1 \end{array} \right ) \textrm{,} \left ( \begin{array}{ccc}0 & 0 & 0\\ 1 & 1 & 1\\ 0 & 0 & 0 \end{array} \right ) \textrm{and} \left ( \begin{array}{ccc}1 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 0 \end{array} \right )$
Obviously, $p(s\geq 1\vert E=1) = 1/3$. But the formula gives
$p(s\geq 1\vert E=1) = \left [ 1 - \frac{2!(3-1)!}{3!(2-1)!}\right ] \left [ 1 - \frac{2!(3-2)!}{3!(2-2)!}\right ]^{2} = \frac{4}{27}$
What went wrong?! The answer points to just how devilish the questions are, and how deceptive! There are two species of out-degree 2 (s=2) in the food web, hence the second term in the formula is squared (see above). BUT, the predator-prey topologies of the species are different, meaning that simple hypergeometric counting cannot work. We literally must list and examine all the post-extinction topologies, but this is prohibitively impractical for food webs and networks of even modest size (a dozen species). So there we stand. We currently have a partial solution, and I will explore the difficulty and the partial solution in the next post.