# An exact, unconditional, nuisance-agnostic test for contingency tables

Miguel Araujo-Voces
Departamento de Bioquímica y Biología Molecular
Universidad de Oviedo, Oviedo, Spain
<EMAIL_ADDRESS>
&Víctor Quesada
Departamento de Bioquímica y Biología Molecular
Universidad de Oviedo, Oviedo, Spain
CIBERONC, Madrid, Spain
<EMAIL_ADDRESS>

###### Abstract

Exact tests greatly improve the analysis of contingency tables when marginals
are low. For instance, researchers often use Fisher’s exact test, which is
conditional, or Barnard’s test, which is unconditional but needs to deal with
a nuisance parameter. Here, we describe the m-test, an exact, unconditional
test for the study of _d x m_ binomial contingency tables. When comparing
binomial trials, the m-test is related to Barnard’s exact test. However, the
nuisance parameter is integrated over all its possible values, instead of
maximized or otherwise estimated. According to Monte Carlo simulations, this
strategy yields a higher statistical power than other exact tests. We also
provide a package to perform the m-test in R.

_K_ eywords Primary 62H17 $\cdot$ secondary 65Y15 $\cdot$ exact test $\cdot$
unconditional $\cdot$ Fisher’s test $\cdot$ Barnard’s test $\cdot$ nuisance
parameter

## Introduction

Numerous experimental designs involve repeatedly measuring an outcome in
multiple groups to determine whether the probability of those outcomes is the
same in all groups. Such experiments yield results that can be expressed in
the form of a contingency table. Predictably, researchers have developed
multiple statistical tests to extract conclusions from these tables [1]. The
radical improvement of our computational capacity in the last decades has
renewed the interest for exact tests that take into account the combinatorial
nature of these experiments.

The most widely used exact test to study _2 x 2_ contingency tables is
Fisher’s test [2]. The model for this test is conditional to both marginals
for the table being fixed. The natural way for this condition to be true is
for the experiment to exhaust all the elements in each group. For instance, in
the lady tasting tea experiment described by Fisher, all cups prepared are
tasted [3]. Relaxing this constraint leads to unconditional tests, which, in
exchange for this advantage, need to deal with a nuisance parameter. Since the
description of this problem and possible solutions by Barnard [4], multiple
treatments have been developed and tested for this problem [5].

Here, we present the m-test, an unconditional binomial exact test that
integrates all possible values of the nuisance parameter. With enough
computing power, the test is easy to apply to general _d x m_ contingency
tables. We have also developed a freely available R package to perform the
m-test.

## Two-sided _2 x m_ test

The m-test assumes a model similar to that of Barnard’s test. We compare
multiple experiments ($E$), where a dichotomic outcome (success or failure) is
repeatedly measured $n$ times under the assumption that the probability of
success $\theta$ is always the same (Bernouilli trials). The result of $E$ can
then be expressed as the number of successes ($s$) and failures ($f$). If $m$
independent experiments are performed on the same system with
$n_{i}=s_{i}+f_{i}$ trials per experiment, the probability $P$ of a set of
results is:

$P\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}&\ldots&s_{m}\\\
f_{1}&\ldots&f_{j}&\ldots&f_{m}\end{smallmatrix}\bigr{)}=\binom{n_{1}}{s_{1}}\ldots\binom{n_{j}}{s_{j}}\ldots\binom{n_{m}}{s_{m}}\theta^{\sum_{i=1}^{m}{s_{i}}}\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}}$
(1)

In this equation, $\theta$ is called the nuisance parameter, as its value is
unknown in the general case. Taking this limitation into account, the m-test
considers all its possible values by integrating (1) over the probability
space:

$P\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}&\ldots&s_{m}\\\
f_{1}&\ldots&f_{j}&\ldots&f_{m}\end{smallmatrix}\bigr{)}=\left[\prod_{i=1}^{m}\binom{n_{i}}{s_{i}}\right]\int_{0}^{1}\theta^{\sum_{i=1}^{m}{s_{i}}}\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}}d\theta$
(2)

Although (2) can be solved by using the Euler integral of the first kind, it
is more convenient to observe some properties, as outlined in Proofs 1 and 2
of the Supplementary Material:

$\begin{split}P\bigl{(}\begin{smallmatrix}0&\ldots&0&\ldots&0\\\
n_{1}&\ldots&n_{j}&\ldots&n_{m}\end{smallmatrix}\bigr{)}&=\frac{1}{\left(1+\sum_{i=1}^{m}{n_{i}}\right)}\\\
P\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}+1&\ldots&s_{m}\\\
f_{1}&\ldots&f_{j}-1&\ldots&f_{m}\end{smallmatrix}\bigr{)}&=\frac{f_{j}\left(1+\sum_{i=1}^{m}{s_{i}}\right)}{\left(s_{j}+1\right)\sum_{i=1}^{m}{f_{i}}}P\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}&\ldots&s_{m}\\\
f_{1}&\ldots&f_{j}&\ldots&f_{m}\end{smallmatrix}\bigr{)}\end{split}$ (3)

The equations in (3) can be used to build an iterative algorithm to compute
every possible result with fixed $n_{i}$ values (Figure 1). In turn, this
allows the fast calculation of p-values with fixed column marginals. Notably,
these equations can be applied to _d x m_ contingency tables with a minor
tweak, as shown in Proofs 3 and 4 of the Supplementary Material.

## One-sided _2 x 2_ test

Similar to the two-sided test, in a _2 x 2_ contingency table we can integrate
the nuisance parameters under a null hypothesis stating that the probability
of success in the first experiment is higher than in the second experiment:

$P^{-}\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}=\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta$
(4)

In (4), the second nuisance parameter $q$ —the probability of success in the
second experiment —is integrated over all the values lower than $\theta$.
Similar to the two-sided test, and as shown in Proofs 5-7 of the Supplementary
Material,

$\begin{split}P^{-}\begin{pmatrix}0&n_{2}\\\
n_{1}&0\end{pmatrix}&=\frac{1}{\left(n_{1}+n_{2}+1\right)\left(n_{1}+n_{2}+2\right)\binom{n_{1}+n_{2}}{n_{1}}}\\\
P^{-}\begin{pmatrix}s_{1}+1&s_{2}\\\
f_{1}-1&f_{2}\end{pmatrix}&=P^{-}\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}+\frac{P\begin{pmatrix}s_{1}+1&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}}{n_{1}+1}\\\ P^{-}\begin{pmatrix}s_{1}&s_{2}-1\\\
f_{1}&f_{2}+1\end{pmatrix}&=P^{-}\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}+\frac{P\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}+1\end{pmatrix}}{n_{2}+1}\end{split}$ (5)

Again, (5) provides the basis for an algorithm to calculate the p-value under
the one-sided null hypothesis with fixed column marginals (Figure 1). In this
case, the result must be normalized by multiplying by 2, since only half of
the probability space for $q$ is integrated.

Figure 1: m-test probabilities ($P$) for a _2 x 2_ contingency table with
column marginals $n_{1}=s_{1}+f_{1}=10$ and $n_{2}=s_{2}+f_{2}=7$. Left, two-
sided test. Right, one-sided test.

## Implementation

Using a generalized form of (3) explained in Proofs 6 and 7 of the
Supplementary Material and (5), we coded the mtest package for R.This package
uses Rcpp for speed and can calculate p-values for a _2 x 2_ table with column
marginals of 400 in a few seconds on a standard laptop computer. It can also
calculate two-sided p-values for arbitrary _d x m_ contingency tables.
However, since the number of possible results with fixed column marginals
escalates very quickly with additional outcomes, those marginals must be kept
relatively low. As a reference, a p-value from a _2 x 5_ table and column
marginals of 16 takes about 30 seconds to calculate in the same computer.

The mtest package also provides a Monte Carlo function to simulate results
under the null hypothesis, both one-sided and two-sided. In addition to
providing benchmarking capabilities for the package, this function can be used
to find an approximate solution for complex contingency tables while limiting
the number of calculation steps. Several examples are provided as R notebooks
when downloading mtest to illustrate these features.

## Test power

Using the Monte Carlo function, we simulated 200,000 results under the two-
sided null hypothesis and 200,000 results under the alternative hypothesis.
This allowed us to estimate the false positive and true positive rates at
different significance levels. With these data, we characterized the
discrimination capabilities and the power of the m-test compared to Fisher’s
test and Barnard’s test (Figure 2). In these benchmarks, the m-test
consistently showed a higher statistical power than the other exact tests,
while receiver operation characteristic (ROC) curves of all three tests were
similar. Although power depends on the model chosen for the simulation and
there are circumstances in which it may not hold, this result suggests that
the m-test may offer a more powerful alternative to existing exact tests.

Figure 2: Receiver operation characteristic (ROC, left) and power (right)
representations for m-test, Fisher’s test and Barnard’s test in simulated _2 x
2_ contingency tables with column marginals of 10 and 7. _TPR_ , true positive
rate; _FPR_ , false positive rate; _alpha_ , significance level.

## Methods

The mtest package was coded in R version 4.0.4 using the Rcpp [6] and usethis
[7] packages in Rstudio 1.4.1106. Multiple test results were benchmarked
against the corresponding original definitions by numerical integration using
wxMaxima 16.04.2. The package can be downloaded and installed from
https://github.com/vqf/mtest. Figures were generated from R notebooks which
are available at https://github.com/vqf/mtest/tree/main/Figs. Fisher’s tests
were run with the fisher.test function; Barnard’s tests were calculated using
the Barnard package [8].

### Calculation of p-values

Both functions m.test (two-sided) and os.m.test (one-sided) perform the
calculation of p-values following the corresponding equations in two steps.
First, the probability of the problem result is calculated and used as an
offset. Then, the probability of every possible result with the same column
marginals is calculated. Each of those probabilities is added to the resulting
p-value if it is not higher than the offset.

In the one-sided test, according to equation (5), each probability is never
lower than the previous value. This allows the calculation of p-values without
visiting every possible result. This property can also be used to improve the
calculation of two-sided p-values in the future, once the symmetries involved
(apparent in Figure 1) are characterized. On the other hand, column marginals
higher than 100 can lead to underflow conditions, which prompt a warning from
the package.

### Monte Carlo simulations

The m-test mc function simulates different _d x m_ contingency tables $N$
times by repeating two steps: probability assignment and trial. For the
probability assignment of $d$ outcomes, $d-1$ pseudorandom numbers
$\left\\{r_{1},r_{2},\ldots,r_{d-1}\right\\}\in\left[\left.0,1\right)\right.$
are generated and sorted. For each trial, a pseudorandom number in
$\left[\left.0,1\right)\right.$ is generated. Outcome $o_{i}$ is selected if
the trial number is in the $\left[\left.r_{i-1},r_{i}\right)\right.$ interval,
where $r_{0}=0$ and $r_{d}=1$.

## Acknowledgements

M. A-V. is supported by the European Research Council. V. Q. is supported by
the Spanish Ministerio de Ciencia, Innovación y Universidades
(RTI2018-096859-B-I00), including FEDER funding. The authors would like to
thank Gonzalo Quesada and Dr. Magda Hamczyk for their advice, and Dr. Carlos
López-Otín for his work, his teachings and his dreams.

## Supplementary Material

### Definitions

  * Result:

Tabulation of multiple experiments with $n_{j}$ trials that yield different
outcomes. In the case of a _2 x m_ contingency table, those outcomes can be
labelled success ($s_{j}$) and failure ($f_{j}$), with $s_{j}+f_{j}=n_{j}$.
The result will be expressed as a matrix with the numbers of successes and
failures of each experiment, one experiment per column:

$\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}&\ldots&s_{m}\\\
f_{1}&\ldots&f_{j}&\ldots&f_{m}\end{smallmatrix}\bigr{)}$

For the general _d x m_ contingency table, we label each outcome from $o_{1}$
to $o_{d}$:

$\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}&\cdots&o_{1,m}\\\
o_{2,1}&\cdots&o_{2,j}&\cdots&o_{2,m}\\\ \vdots&\ddots&\vdots&\ddots&\vdots\\\
o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)$

  * Two-sided _2 x m_ null hypothesis:

The probability of success of each experiment ($\theta$) is the same.
Therefore, the probability $P$ of obtaining the result is:

$P\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}&\ldots&s_{m}\\\
f_{1}&\ldots&f_{j}&\ldots&f_{m}\end{smallmatrix}\bigr{)}=\binom{n_{1}}{s_{1}}\ldots\binom{n_{j}}{s_{j}}\ldots\binom{n_{m}}{s_{m}}\int_{0}^{1}\theta^{\sum_{i=1}^{m}{s_{i}}}\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}}d\theta$

  * One-sided null hypothesis:

For a _2 x 2_ contingency table, the probability of success in the first
experiment ($\theta$) is higher than in the second experiment ($q$).
Therefore, the probability of obtaining the result is:

$P^{-}\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}=\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta$

  * Two-sided with _d x m_ table:

Let $\theta_{i}$ be the probability of outcome $o_{i,j}\forall
j\in\\{1,2,\ldots m\\}$. By symmetry, since no outcome is privileged, any
ordering of $\theta_{i}$ must yield the same result. Given that
$\sum_{i=1}^{m}{\theta_{i}}=1$, there are $\left(d-1\right)$ degrees of
freedom and $\left(d-1\right)!$ independent orderings of $\theta_{i}$. Taking
$\theta_{d}$ as the dependent variable,

$\begin{multlined}P\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}&\cdots&o_{1,m}\\\
o_{2,1}&\cdots&o_{2,j}&\cdots&o_{2,m}\\\ \vdots&\ddots&\vdots&\ddots&\vdots\\\
o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)=\left(d-1\right)!\prod_{j=1}^{m}\binom{n_{j}}{o_{1,j}o_{2,j}\ldots
o_{d,j}}\int_{0}^{1}\theta_{1}^{\sum_{j=1}^{m}{o_{1},j}}\int_{1-\theta_{1}}^{1}\theta_{2}^{\sum_{j=1}^{m}{o_{2},j}}\ldots\\\
\ldots\int_{1-\sum_{j=1}^{d-2}\theta_{j}}^{1}\theta_{d-1}^{\sum_{j=1}^{m}{o_{d-1},j}}\theta_{d}^{\sum_{j=1}^{m}{o_{d,j}}}d\theta_{d-1}\ldots
d\theta_{2}d\theta_{1}\end{multlined}P\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}&\cdots&o_{1,m}\\\
o_{2,1}&\cdots&o_{2,j}&\cdots&o_{2,m}\\\ \vdots&\ddots&\vdots&\ddots&\vdots\\\
o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)=\left(d-1\right)!\prod_{j=1}^{m}\binom{n_{j}}{o_{1,j}o_{2,j}\ldots
o_{d,j}}\int_{0}^{1}\theta_{1}^{\sum_{j=1}^{m}{o_{1},j}}\int_{1-\theta_{1}}^{1}\theta_{2}^{\sum_{j=1}^{m}{o_{2},j}}\ldots\\\
\ldots\int_{1-\sum_{j=1}^{d-2}\theta_{j}}^{1}\theta_{d-1}^{\sum_{j=1}^{m}{o_{d-1},j}}\theta_{d}^{\sum_{j=1}^{m}{o_{d,j}}}d\theta_{d-1}\ldots
d\theta_{2}d\theta_{1}$

Let $l_{i}=1-\sum_{j=1}^{i}\theta_{j}$. Therefore,
$\theta_{1}=\left(1-l_{1}\right)$, $l_{d}=0$, $\theta_{i}=l_{i-1}-l_{i}$ and
$d\theta_{i}=-dl_{i}$ (as $l_{i-1}$ does not include $\theta_{i}$).

$\begin{multlined}P\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}&\cdots&o_{1,m}\\\
o_{2,1}&\cdots&o_{2,j}&\cdots&o_{2,m}\\\ \vdots&\ddots&\vdots&\ddots&\vdots\\\
o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)=\left(d-1\right)!\prod_{j=1}^{m}\binom{n_{j}}{o_{1,j}o_{2,j}\ldots
o_{d,j}}\int_{0}^{1}\left(1-l_{1}\right)^{\sum_{j=1}^{m}{o_{1},j}}\ldots\\\
\ldots\int_{0}^{l_{1}}\left(l_{1}-l_{2}\right)^{\sum_{j=1}^{m}{o_{2},j}}\int_{0}^{l_{d-2}}\left(l_{d-2}-l_{d-1}\right)^{\sum_{j=1}^{m}{o_{d-1},j}}l_{d-1}^{\sum_{j=1}^{m}{o_{d,j}}}dl_{d-1}\ldots
dl_{2}dl_{1}\end{multlined}P\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}&\cdots&o_{1,m}\\\
o_{2,1}&\cdots&o_{2,j}&\cdots&o_{2,m}\\\ \vdots&\ddots&\vdots&\ddots&\vdots\\\
o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)=\left(d-1\right)!\prod_{j=1}^{m}\binom{n_{j}}{o_{1,j}o_{2,j}\ldots
o_{d,j}}\int_{0}^{1}\left(1-l_{1}\right)^{\sum_{j=1}^{m}{o_{1},j}}\ldots\\\
\ldots\int_{0}^{l_{1}}\left(l_{1}-l_{2}\right)^{\sum_{j=1}^{m}{o_{2},j}}\int_{0}^{l_{d-2}}\left(l_{d-2}-l_{d-1}\right)^{\sum_{j=1}^{m}{o_{d-1},j}}l_{d-1}^{\sum_{j=1}^{m}{o_{d,j}}}dl_{d-1}\ldots
dl_{2}dl_{1}$

### Proofs

###### Proof 1.

$P\bigl{(}\begin{smallmatrix}0&\ldots&0&\ldots&0\\\
n_{1}&\ldots&n_{j}&\ldots&n_{m}\end{smallmatrix}\bigr{)}=\frac{1}{\left(1+\sum_{i=1}^{m}{n_{i}}\right)}$

$\displaystyle P\bigl{(}\begin{smallmatrix}0&\ldots&0&\ldots&0\\\
n_{1}&\ldots&n_{j}&\ldots&n_{m}\end{smallmatrix}\bigr{)}$
$\displaystyle=\cancelto{1}{\binom{n_{1}}{0}\ldots\binom{n_{j}}{0}\ldots\binom{n_{m}}{0}}\int_{0}^{1}\left(1-\theta\right)^{\sum_{i=1}^{m}{n_{i}}}d\theta=$
(1.1)
$\displaystyle=-\frac{1}{\left(1+\sum_{i=1}^{m}{n_{i}}\right)}\left[\left(1-\theta\right)^{\left(1+\sum_{i=1}^{m}{n_{i}}\right)}\right]_{0}^{1}=\frac{1}{\left(1+\sum_{i=1}^{m}{n_{i}}\right)}\qed$
(1.2)

###### Proof 2.

$P\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}+1&\ldots&s_{m}\\\
f_{1}&\ldots&f_{j}-1&\ldots&f_{m}\end{smallmatrix}\bigr{)}=\frac{f_{j}\left(1+\sum_{i=1}^{m}{s_{i}}\right)}{\left(s_{j}+1\right)\sum_{i=1}^{m}{f_{i}}}P\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}&\ldots&s_{m}\\\
f_{1}&\ldots&f_{j}&\ldots&f_{m}\end{smallmatrix}\bigr{)}$

$\displaystyle P\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}+1&\ldots&s_{m}\\\ f_{1}&\ldots&f_{j}-1&\ldots&f_{m}\end{smallmatrix}\bigr{)}$ $\displaystyle=\binom{n_{1}}{s_{1}}\ldots\binom{n_{j}}{s_{j}+1}\ldots\binom{n_{m}}{f_{m}}\int_{0}^{1}\theta^{1+\sum_{i=1}^{m}{s_{i}}}\left(1-\theta\right)^{-1+\sum_{i=1}^{m}{f_{i}}}d\theta$ (2.1) Integrating by parts with:  $u=\theta^{1+\sum_{i=1}^{m}{s_{i}}}$ | $dv=\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}-1}d\theta$
---|---
$du=\left(1+\sum_{i=1}^{m}{s_{i}}\right)\theta^{\sum_{i=1}^{m}{s_{i}}}d\theta$ | $v=-\frac{\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}}}{\sum_{i=1}^{m}{f_{i}}}$
$\displaystyle=\begin{multlined}\binom{n_{1}}{s_{1}}\ldots\frac{f_{j}}{s_{j}+1}\binom{n_{j}}{s_{j}}\ldots\binom{n_{m}}{f_{m}}\frac{1}{\sum_{i=1}^{m}{f_{i}}}\cancelto{0}{\left[\theta^{1+\sum_{i=1}^{m}{s_{i}}}\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}}\right]_{0}^{1}}+\\\
+\binom{n_{1}}{s_{1}}\ldots\frac{f_{j}}{s_{j}+1}\binom{n_{j}}{s_{j}}\ldots\binom{n_{m}}{f_{m}}\frac{1+\sum_{i=1}^{m}{s_{i}}}{\sum_{i=1}^{m}{f_{i}}}\int_{0}^{1}\theta^{\sum_{i=1}^{m}{s_{i}}}\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}}d\theta\end{multlined}\binom{n_{1}}{s_{1}}\ldots\frac{f_{j}}{s_{j}+1}\binom{n_{j}}{s_{j}}\ldots\binom{n_{m}}{f_{m}}\frac{1}{\sum_{i=1}^{m}{f_{i}}}\cancelto{0}{\left[\theta^{1+\sum_{i=1}^{m}{s_{i}}}\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}}\right]_{0}^{1}}+\\\
+\binom{n_{1}}{s_{1}}\ldots\frac{f_{j}}{s_{j}+1}\binom{n_{j}}{s_{j}}\ldots\binom{n_{m}}{f_{m}}\frac{1+\sum_{i=1}^{m}{s_{i}}}{\sum_{i=1}^{m}{f_{i}}}\int_{0}^{1}\theta^{\sum_{i=1}^{m}{s_{i}}}\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}}d\theta$
(2.6)
$\displaystyle=\frac{f_{j}\left(1+\sum_{i=1}^{m}{s_{i}}\right)}{\left(s_{j}+1\right)\sum_{i=1}^{m}{f_{i}}}\binom{n_{1}}{s_{1}}\ldots\binom{n_{j}}{s_{j}}\ldots\binom{n_{m}}{f_{m}}\int_{0}^{1}\theta^{\sum_{i=1}^{m}{s_{i}}}\left(1-\theta\right)^{\sum_{i=1}^{m}{f_{i}}}d\theta$
(2.7)
$\displaystyle=\frac{f_{j}\left(1+\sum_{i=1}^{m}s_{i}\right)}{\left(1+s_{i}\right)\sum_{i=1}^{m}{f_{j}}}P\bigl{(}\begin{smallmatrix}s_{1}&\ldots&s_{j}&\ldots&s_{m}\\\
f_{1}&\ldots&f_{j}&\ldots&f_{m}\end{smallmatrix}\bigr{)}\qed$ (2.8)

###### Proof 3.

$P\left(\begin{smallmatrix}0&\cdots&0&\cdots&0\\\ 0&\cdots&0&\cdots&0\\\
\vdots&\ddots&\vdots&\ddots&\vdots\\\
n_{1}&\cdots&n_{j}&\cdots&n_{m}\end{smallmatrix}\right)=\frac{\left(d-1\right)!}{1+\sum_{i=1}^{m}{n_{i}}}$

$\displaystyle P\left(\begin{smallmatrix}0&\cdots&0&\cdots&0\\\
0&\cdots&0&\cdots&0\\\ \vdots&\ddots&\vdots&\ddots&\vdots\\\
n_{1}&\cdots&n_{j}&\cdots&n_{m}\end{smallmatrix}\right)$
$\displaystyle=\left(d-1\right)!\prod_{j-1}^{m}\binom{n_{j}}{n_{j}}\int_{0}^{1}\int_{0}^{l_{1}}\ldots\int_{0}^{l_{d-2}}l_{d-1}^{\sum_{i=1}^{m}{n_{i}}}dl_{d-1}\ldots
dl_{2}dl_{1}$ (3.1)
$\displaystyle=\frac{\left(d-1\right)!}{1+\sum_{i=1}^{m}{n_{i}}}\cancelto{1}{\left[\left[\ldots\left[l_{d-1}^{1+\sum_{i=1}^{m}{n_{i}}}\right]_{0}^{l_{d-2}}\ldots\right]_{0}^{l_{1}}\right]_{0}^{1}}\qed$
(3.2)

###### Proof 4.

$P\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}+1&\cdots&o_{1,m}\\\
o_{2,1}&\cdots&o_{2,j}-1&\cdots&o_{2,m}\\\
\vdots&\ddots&\vdots&\ddots&\vdots\\\
o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)=\frac{o_{2,j}\left(1+\sum_{i=1}^{m}{o_{1},i}\right)}{\left(o_{1,j}+1\right)\sum_{i=1}^{m}{o_{2,i}}}P\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}&\cdots&o_{1,m}\\\
o_{2,1}&\cdots&o_{2,j}&\cdots&o_{2,m}\\\ \vdots&\ddots&\vdots&\ddots&\vdots\\\
o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)$

Without loss of generality we can consider

$\displaystyle P\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}+1&\cdots&o_{1,m}\\\ o_{2,1}&\cdots&o_{2,j}-1&\cdots&o_{2,m}\\\ \vdots&\ddots&\vdots&\ddots&\vdots\\\ o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)$ $\displaystyle=\begin{multlined}\left(d-1\right)!\binom{n_{j}}{\left(o_{1,j}+1\right)\left(o_{2,j}-1\right)\ldots o_{d,j}}\\\ \prod_{\begin{subarray}{c}k=1\\\ k\neq j\end{subarray}}^{m}\binom{n_{k}}{o_{1,k}o_{2,k}\ldots o_{d,k}}\int_{0}^{1}\left(1-l_{1}\right)^{\sum_{i=1}^{m}{o_{3},i}}\int_{0}^{l_{1}}\left(l_{1}-l_{2}\right)^{\sum_{i=1}^{m}{o_{4},i}}\ldots\\\ \ldots\int_{0}^{l_{d-2}}\left(l_{d-2}-l_{d-1}\right)^{\left(1+\sum_{i=1}^{m}{o_{1},i}\right)}l_{d-1}^{\left(-1+\sum_{i=1}^{m}{o_{2,i}}\right)}dl_{d-1}\ldots dl_{2}dl_{1}\end{multlined}\left(d-1\right)!\binom{n_{j}}{\left(o_{1,j}+1\right)\left(o_{2,j}-1\right)\ldots o_{d,j}}\\\ \prod_{\begin{subarray}{c}k=1\\\ k\neq j\end{subarray}}^{m}\binom{n_{k}}{o_{1,k}o_{2,k}\ldots o_{d,k}}\int_{0}^{1}\left(1-l_{1}\right)^{\sum_{i=1}^{m}{o_{3},i}}\int_{0}^{l_{1}}\left(l_{1}-l_{2}\right)^{\sum_{i=1}^{m}{o_{4},i}}\ldots\\\ \ldots\int_{0}^{l_{d-2}}\left(l_{d-2}-l_{d-1}\right)^{\left(1+\sum_{i=1}^{m}{o_{1},i}\right)}l_{d-1}^{\left(-1+\sum_{i=1}^{m}{o_{2,i}}\right)}dl_{d-1}\ldots dl_{2}dl_{1}$ (4.4) Solving the innermost integral by parts with $u=\left(l_{d-2}-l_{d-1}\right)^{\left(1+\sum_{i=1}^{m}{o_{1},i}\right)}$ | $dv=l_{d-1}^{\left(-1+\sum_{i=1}^{m}{o_{2,i}}\right)}dl_{d-1}$
---|---
$du=-\left(1+\sum_{i=1}^{m}{o_{1},i}\right)\left(l_{d-2}-l_{d-1}\right)^{\sum_{i=1}^{m}{o_{1},i}}dl_{d-1}$ | $v=\frac{l_{d-1}^{\sum_{i=1}^{m}{o_{2,i}}}}{\sum_{i=1}^{m}{o_{2,i}}}$
$\displaystyle
P\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}+1&\cdots&o_{1,m}\\\
o_{2,1}&\cdots&o_{2,j}-1&\cdots&o_{2,m}\\\
\vdots&\ddots&\vdots&\ddots&\vdots\\\
o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)$
$\displaystyle=\begin{multlined}\left(d-1\right)!\frac{o_{2,j}}{o_{1,j}+1}\prod_{k=1}^{m}\binom{n_{k}}{o_{1,k}o_{2,k}\ldots
o_{d,k}}\\\
\frac{1+\sum_{i=1}^{m}{o_{1},i}}{\sum_{i=1}^{m}{o_{2,i}}}\int_{0}^{1}\left(1-l_{1}\right)^{\sum_{i=1}^{m}{o_{3},i}}\int_{0}^{l_{1}}\left(l_{1}-l_{2}\right)^{\sum_{i=1}^{m}{o_{4},i}}\ldots\\\
\ldots\int_{0}^{l_{d-2}}\left(l_{d-2}-l_{d-1}\right)^{\sum_{i=1}^{m}{o_{1},i}}l_{d-1}^{\sum_{i=1}^{m}{o_{2,i}}}dl_{d-1}\ldots
dl_{2}dl_{1}\end{multlined}\left(d-1\right)!\frac{o_{2,j}}{o_{1,j}+1}\prod_{k=1}^{m}\binom{n_{k}}{o_{1,k}o_{2,k}\ldots
o_{d,k}}\\\
\frac{1+\sum_{i=1}^{m}{o_{1},i}}{\sum_{i=1}^{m}{o_{2,i}}}\int_{0}^{1}\left(1-l_{1}\right)^{\sum_{i=1}^{m}{o_{3},i}}\int_{0}^{l_{1}}\left(l_{1}-l_{2}\right)^{\sum_{i=1}^{m}{o_{4},i}}\ldots\\\
\ldots\int_{0}^{l_{d-2}}\left(l_{d-2}-l_{d-1}\right)^{\sum_{i=1}^{m}{o_{1},i}}l_{d-1}^{\sum_{i=1}^{m}{o_{2,i}}}dl_{d-1}\ldots
dl_{2}dl_{1}$ (4.13)
$\displaystyle=\frac{o_{2,j}\left(1+\sum_{i=1}^{m}{o_{1},i}\right)}{\left(o_{1,j}+1\right)\sum_{i=1}^{m}{o_{2,i}}}P\left(\begin{smallmatrix}o_{1,1}&\cdots&o_{1,j}&\cdots&o_{1,m}\\\
o_{2,1}&\cdots&o_{2,j}&\cdots&o_{2,m}\\\ \vdots&\ddots&\vdots&\ddots&\vdots\\\
o_{d,1}&\cdots&o_{d,j}&\cdots&o_{d,m}\end{smallmatrix}\right)\qed$ (4.14)

###### Proof 5.

$P^{-}\begin{pmatrix}0&n_{2}\\\
n_{1}&0\end{pmatrix}=\frac{1}{\left(n_{1}+n_{2}+1\right)\left(n_{1}+n_{2}+2\right)\binom{n_{1}+n_{2}}{n_{1}}}$

$\displaystyle P^{-}\begin{pmatrix}0&n_{2}\\\ n_{1}&0\end{pmatrix}$
$\displaystyle=\binom{n_{1}}{0}\binom{n_{2}}{n_{2}}\int_{0}^{1}\left(1-\theta\right)^{n_{1}}\int_{0}^{\theta}q^{n_{2}}dqd\theta$
(5.1) $\displaystyle\int_{0}^{\theta}q^{n_{2}}dq$
$\displaystyle=\frac{1}{n_{2}+1}\left[q^{n_{2}+1}\right]_{q=0}^{\theta}=\frac{\theta^{n_{2}+1}}{n_{2}+1}$
(5.2) $\displaystyle P^{-}\begin{pmatrix}0&n_{2}\\\ n_{1}&0\end{pmatrix}$
$\displaystyle=\frac{1}{n_{2}+1}\int_{0}^{1}\theta^{n_{2}+1}\left(1-\theta\right)^{n_{1}}d\theta$
(5.3)
$\displaystyle=\frac{1}{\left(n_{2}+1\right)\left(n_{1}+n_{2}+2\right)\binom{n_{1}+n_{2}+1}{n_{1}}}=\frac{1}{\left(n_{1}+n_{2}+1\right)\left(n_{1}+n_{2}+2\right)\binom{n_{1}+n_{2}}{n_{1}}}\qed$
(5.4)

###### Proof 6.

$P^{-}\begin{pmatrix}s_{1}+1&s_{2}\\\
f_{1}-1&f_{2}\end{pmatrix}=P^{-}\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}+\frac{P\begin{pmatrix}s_{1}+1&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}}{n_{1}+1}$

$\displaystyle P^{-}\begin{pmatrix}s_{1}+1&s_{2}\\\ f_{1}-1&f_{2}\end{pmatrix}$ $\displaystyle=\binom{n_{1}}{s_{1}+1}\binom{n_{2}}{s_{2}}\int_{0}^{1}\theta^{s_{1}+1}\left(1-\theta\right)^{f_{1}-1}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta$ (6.1) By the fundamental theorem of calculus, $\displaystyle\frac{d\left(\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dq\right)}{d\theta}=\theta^{s_{2}}\left(1-\theta\right)^{f_{2}}$ (6.2) Integrating by parts with: $u=\theta^{s_{1}+1}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dq$ | $dv=\left(1-\theta\right)^{f_{1}-1}d\theta$
---|---
$du=\left(s_{1}+1\right)\theta^{s_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dq+\theta^{s_{1}+s_{2}+1}\left(1-\theta\right)^{f_{2}}dp$ | $v=-\frac{1}{f_{1}}\left(1-\theta\right)^{f_{1}}$
$\displaystyle P^{-}\begin{pmatrix}s_{1}+1&s_{2}\\\
f_{1}-1&f_{2}\end{pmatrix}$
$\displaystyle=\begin{multlined}-\binom{n_{1}}{s_{1}+1}\binom{n_{2}}{s_{2}}\cancelto{0}{\left[\theta^{s_{1}+1}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dq\frac{1}{f_{1}}\left(1-\theta\right)^{f_{1}}\right]_{\theta=0}^{1}}+\\\
+\binom{n_{1}}{s_{1}+1}\binom{n_{2}}{s_{2}}\frac{s_{1}+1}{f_{1}}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta+\\\
+\binom{n_{1}}{s_{1}+1}\binom{n_{2}}{s_{2}}\frac{1}{f_{1}}\int_{0}^{1}\theta^{s_{1}+s_{2}+1}\left(1-\theta\right)^{f_{1}+f_{2}}d\theta\end{multlined}-\binom{n_{1}}{s_{1}+1}\binom{n_{2}}{s_{2}}\cancelto{0}{\left[\theta^{s_{1}+1}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dq\frac{1}{f_{1}}\left(1-\theta\right)^{f_{1}}\right]_{\theta=0}^{1}}+\\\
+\binom{n_{1}}{s_{1}+1}\binom{n_{2}}{s_{2}}\frac{s_{1}+1}{f_{1}}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta+\\\
+\binom{n_{1}}{s_{1}+1}\binom{n_{2}}{s_{2}}\frac{1}{f_{1}}\int_{0}^{1}\theta^{s_{1}+s_{2}+1}\left(1-\theta\right)^{f_{1}+f_{2}}d\theta$
(6.8)
$\displaystyle=\begin{multlined}\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta+\\\
+\binom{n_{1}+1}{s_{1}+1}\binom{n_{2}}{s_{2}}\frac{1}{n_{1}+1}\int_{0}^{1}\theta^{s_{1}+s_{2}+1}\left(1-\theta\right)^{f_{1}+f_{2}}d\theta\end{multlined}\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta+\\\
+\binom{n_{1}+1}{s_{1}+1}\binom{n_{2}}{s_{2}}\frac{1}{n_{1}+1}\int_{0}^{1}\theta^{s_{1}+s_{2}+1}\left(1-\theta\right)^{f_{1}+f_{2}}d\theta$
(6.11) $\displaystyle=P^{-}\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}+\frac{P\begin{pmatrix}s_{1}+1&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}}{n_{1}+1}\qed$ (6.12)

###### Proof 7.

$P^{-}\begin{pmatrix}s_{1}&s_{2}-1\\\
f_{1}&f_{2}+1\end{pmatrix}=P^{-}\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}+\frac{P\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}+1\end{pmatrix}}{n_{2}+1}$

$\displaystyle P^{-}\begin{pmatrix}s_{1}&s_{2}-1\\\ f_{1}&f_{2}+1\end{pmatrix}$ $\displaystyle=\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}-1}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}-1}\left(1-q\right)^{f_{2}+1}dqd\theta$ (7.1) Solving the second integral by parts with:  $u=\left(1-q\right)^{f_{2}+1}$ | $dv=q^{s_{2}-1}dq$
---|---
$du=-\left(f_{2}+1\right)\left(1-q\right)^{f_{2}}dq$ | $v=\frac{1}{s_{2}}q^{s_{2}}$
$\displaystyle=\begin{multlined}\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}-1}\\\
\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\left[\left[\frac{1}{s_{2}}q^{s_{2}}\left(1-q\right)^{f_{2}+1}\right]_{q=0}^{\theta}+\frac{f_{2}+1}{s_{2}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dq\right]d\theta\end{multlined}\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}-1}\\\
\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\left[\left[\frac{1}{s_{2}}q^{s_{2}}\left(1-q\right)^{f_{2}+1}\right]_{q=0}^{\theta}+\frac{f_{2}+1}{s_{2}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dq\right]d\theta$
(7.7)
$\displaystyle=\begin{multlined}\frac{f_{2}+1}{s_{2}}\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}-1}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta+\\\
+\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}-1}\frac{1}{s_{2}}\int_{0}^{1}\theta^{s_{1}+s_{2}}\left(1-\theta\right)^{f_{1}+f_{2}+1}d\theta\end{multlined}\frac{f_{2}+1}{s_{2}}\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}-1}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta+\\\
+\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}-1}\frac{1}{s_{2}}\int_{0}^{1}\theta^{s_{1}+s_{2}}\left(1-\theta\right)^{f_{1}+f_{2}+1}d\theta$
(7.10)
$\displaystyle=\begin{multlined}\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta+\\\
+\binom{n_{1}}{s_{1}}\binom{n_{2}+1}{s_{2}}\frac{1}{n_{2}+1}\int_{0}^{1}\theta^{s_{1}+s_{2}}\left(1-\theta\right)^{f_{1}+f_{2}+1}d\theta\end{multlined}\binom{n_{1}}{s_{1}}\binom{n_{2}}{s_{2}}\int_{0}^{1}\theta^{s_{1}}\left(1-\theta\right)^{f_{1}}\int_{0}^{\theta}q^{s_{2}}\left(1-q\right)^{f_{2}}dqd\theta+\\\
+\binom{n_{1}}{s_{1}}\binom{n_{2}+1}{s_{2}}\frac{1}{n_{2}+1}\int_{0}^{1}\theta^{s_{1}+s_{2}}\left(1-\theta\right)^{f_{1}+f_{2}+1}d\theta$
(7.13) $\displaystyle=P^{-}\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}\end{pmatrix}+\frac{P\begin{pmatrix}s_{1}&s_{2}\\\
f_{1}&f_{2}+1\end{pmatrix}}{n_{2}+1}\qed$ (7.14)

### Notes

  * 2.1

$\displaystyle\binom{n_{j}}{s_{j}+1}=\frac{\left(n_{j}\right)!}{\left(s_{j}+1\right)!\left(f_{j}-1\right)!}=\frac{\left(n_{j}\right)!}{\left(s_{j}+1\right)s_{j}!\frac{f_{j}!}{f_{j}}}=\frac{f_{j}}{s_{j}+1}\binom{n_{j}}{s_{j}}$

  * 4.13

$\displaystyle\binom{n_{j}}{\left(o_{1,j}+1\right)\left(o_{2,j}-1\right)\ldots
o_{d,j}}$
$\displaystyle=\frac{n_{j}!}{\left(o_{1,j}+1\right)!\left(o_{2,j}-1\right)!\ldots
o_{d,j}!}=\frac{n_{j}!}{\left(o_{1,j}\right)!\left(o_{1,j}+1\right)\frac{\left(o_{2,j}\right)!}{o_{2,j}}\ldots
o_{d,j}!}$
$\displaystyle=\frac{o_{2,j}}{o_{1,j}+1}\binom{n_{j}}{o_{1,j}o_{2,j}\ldots
o_{d,j}}$

  * 5.3

Euler integral of the first kind

  * 6.8

$\displaystyle\binom{n_{1}}{s_{1}+1}\frac{s_{1}+1}{f_{1}}$
$\displaystyle=\frac{n_{1}!\left(s_{1}+1\right)}{\left(s_{1}+1\right)!\left(f_{1}-1\right)!f_{1}}=\frac{n_{1}!}{s_{1}!f_{1}!}=\binom{n_{1}}{s_{1}}$
$\displaystyle\binom{n_{1}}{s_{1}+1}\frac{1}{f_{1}}$
$\displaystyle=\frac{n_{1}!}{\left(s_{1}+1\right)!\left(f_{1}-1\right)!f_{1}}=\frac{1}{n_{1}+1}\frac{\left(n_{1}+1\right)!}{\left(s_{1}+1\right)!f_{1}!}=\frac{1}{n_{1}+1}\binom{n_{1}+1}{s_{1}+1}$

  * 7.10

$\displaystyle\binom{n_{2}}{s_{2}-1}\frac{f_{2}+1}{s_{2}}$
$\displaystyle=\frac{n_{2}!\left(f_{2}+1\right)}{\left(s_{2}-1\right)!\left(f_{2}+1\right)!s_{2}}=\frac{n_{2}!}{s_{2}!f_{2}!}=\binom{n_{2}}{s_{2}}$
$\displaystyle\binom{n_{2}}{s_{2}-1}\frac{1}{s_{2}}$
$\displaystyle=\frac{n_{2}!}{\left(s_{2}-1\right)!s_{2}\left(f_{2}+1\right)!}=\frac{1}{n_{2}+1}\frac{\left(n_{2}+1\right)!}{s_{2}!\left(f_{1}+1\right)!}=\frac{1}{n_{2}+1}\binom{n_{2}+1}{s_{2}}$

## References

  * [1] S. Lydersen, M. W. Fagerland, and P. Laake.  Recommended tests for association in 2 x 2 tables.  Stat Med, 28:1159–75, 2009.
  * [2] R. A. Fisher.  The logic of inductive inference.  Journal of the Royal Statistical Society, 98(1):39–54, 1935.
  * [3] R. A. Fisher.  The design of experiments.  Oliver & Boyd, 1935.
  * [4] G. A. Barnard.  A new test for 2 × 2 tables.  Nature, 156:177, 1945.
  * [5] Enrico Ripamonti, Chris Lloyd, and Piero Quatto.  Contemporary Frequentist Views of the $2\times 2$ Binomial Trial.  Statistical Science, 32(4):600 – 615, 2017.
  * [6] Dirk Eddelbuettel and James Joseph Balamuta.  Extending r with c++: A brief introduction to rcpp.  The American Statistician, 72(1):28–36, 2018.
  * [7] Hadley Wickham and Jennifer Bryan.  usethis: Automate Package and Project Setup, 2021.  R package version 2.0.1.
  * [8] Kamil Erguler.  Barnard: Barnard’s Unconditional Test, 2016.  R package version 1.8.