# Binomial Distributed Data Confidence Interval Calculation: Formulas, Algorithms and Examples

^{1}

^{2}

## Abstract

**:**

## 1. Introduction

## 2. Background

## 3. Literature Review

## 4. Methodology

- Collect all possible drawings and their associated probabilities ($(u,{f}_{\mathrm{RB}}(u;x,m))$ from Equation (3);
- The values (u) are already sorted (and grouped) when u ranges increasingly from 0 to m and the probability mass function (PMF) is defined by the $\{{f}_{\mathrm{RB}}(0;x,m)$, ${f}_{\mathrm{RB}}(1;x,m)$, …, ${f}_{\mathrm{RB}}(u;x,m)$, …, ${f}_{\mathrm{RB}}(m;x,m)\}$ set;

#### Proposed CI Calculation Algorithms

Algorithm 1: Foundational confidence interval, CI_v0 |

Input: $\alpha $, x, m //imposed level, number of successes, number of trials**procedure**Found($\beta ,x,m,\&r,\&i,\&j,\&q$)- $i\leftarrow x$; $j\leftarrow x$; $q\leftarrow r\left[x\right]$
- For( ; ; )
- if($q\ge \beta $) Break; if($(i=0)$ AND $(j=m)$) Break
- If($i=0$) $j\leftarrow j+1$; $q\leftarrow q+r\left[j\right]$; Continue EndIf
- If($j=m$) $i\leftarrow i-1$; $q\leftarrow q+r\left[i\right]$; Continue EndIf
- If($r[i\phantom{\rule{-0.166667em}{0ex}}-\phantom{\rule{-0.166667em}{0ex}}1]=r[j\phantom{\rule{-0.166667em}{0ex}}+\phantom{\rule{-0.166667em}{0ex}}1]$) $i\phantom{\rule{-0.166667em}{0ex}}\leftarrow \phantom{\rule{-0.166667em}{0ex}}i\phantom{\rule{-0.166667em}{0ex}}-\phantom{\rule{-0.166667em}{0ex}}1$; $j\phantom{\rule{-0.166667em}{0ex}}\leftarrow \phantom{\rule{-0.166667em}{0ex}}j\phantom{\rule{-0.166667em}{0ex}}+\phantom{\rule{-0.166667em}{0ex}}1$; $q\phantom{\rule{-0.166667em}{0ex}}\leftarrow \phantom{\rule{-0.166667em}{0ex}}q\phantom{\rule{-0.166667em}{0ex}}+\phantom{\rule{-0.166667em}{0ex}}r\left[i\right]\phantom{\rule{-0.166667em}{0ex}}+\phantom{\rule{-0.166667em}{0ex}}r\left[j\right]$; Continue EndIf
- If($r[i-1]>r[j+1]$) $i\leftarrow i-1$; $q\leftarrow q+r\left[i\right]$; Continue EndIf
- If($r[i-1]<r[j+1]$) $j\leftarrow j+1$; $q\leftarrow q+r\left[j\right]$; Continue EndIf
- EndFor
**end procedure****procedure**CI_v0($\alpha ,x,m,\&i1,\&i2,\&q$)- PMF_B($x,m,r$); $\beta \leftarrow 1-\alpha $; Found($\beta ,x,m,r,i1,i2$)
**end procedure**
Output:$i1$, $i2$, q // $[i1,i2]$ is the CI; q is the actual CI’s coverage |

Algorithm 2: First improved confidence interval, CI_v1 |

Input: $\alpha $, x, m imposed level, number of successes, number of trials**procedure**Imp_1($\beta ,x,m,\&r,\&i,\&j,\&q$)- For( ; ; )
- if( $j\le i$ ) Break
- If( $r\left[i\right]=r\left[j\right]$ )
- If( Abs($\beta -q$) > Abs($\beta -q+r\left[i\right]+r\left[j\right]$) )
- $q\leftarrow q-r\left[i\right]-r\left[j\right]$; $i\leftarrow i+1$; $j\leftarrow j-1$
- EndIf
- Break
- EndIf
- If( $r\left[i\right]<r\left[j\right]$ )
- If( Abs($\beta -q$) > Abs($\beta -q+r\left[i\right]$) ) $q\leftarrow q-r\left[i\right]$; $i\leftarrow i+1$; EndIf
- Break
- EndIf
- If( $r\left[i\right]>r\left[j\right]$ )
- If( Abs($\beta -q$) > Abs($\beta -q+r\left[j\right]$) ) $q\leftarrow q-r\left[j\right]$; $j\leftarrow j-1$ EndIf
- Break
- EndIf
- EndFor
**end procedure****procedure**CI_v1($\alpha $, x, m, i1, i2, er)- PMF_B($x,m,r$); $\beta \leftarrow 1-\alpha $; Found($\beta ,x,m,r,i1,i2$); Imp_1($\beta ,x,m,r,i1,i2,q$)
**end procedure**
Output: $i1$, $i2$, q // $[i1,i2]$ is the CI; q is the actual CI’s coverage |

Algorithm 3: Second improved confidence interval, CI_v2 |

Input: $\alpha $, x, m imposed level, number of successes, number of trials**procedure**Imp_2($\beta ,x,m,\&r,\&i,\&j,\&q$)- For( ; ; )
- if($q\ge \beta $) Break; if($(i=0)$ AND $(j=m)$) Break
- If($i=0$) $j\leftarrow j+1$; $q\leftarrow q+r\left[j\right]$; Continue EndIf
- If($j=m$) $i\leftarrow i-1$; $q\leftarrow q+r\left[i\right]$; Continue EndIf
- If($r[i\phantom{\rule{-0.166667em}{0ex}}-\phantom{\rule{-0.166667em}{0ex}}1]=r[j\phantom{\rule{-0.166667em}{0ex}}+\phantom{\rule{-0.166667em}{0ex}}1]$) $i\phantom{\rule{-0.166667em}{0ex}}\leftarrow \phantom{\rule{-0.166667em}{0ex}}i\phantom{\rule{-0.166667em}{0ex}}-\phantom{\rule{-0.166667em}{0ex}}1$; $j\phantom{\rule{-0.166667em}{0ex}}\leftarrow \phantom{\rule{-0.166667em}{0ex}}j\phantom{\rule{-0.166667em}{0ex}}+\phantom{\rule{-0.166667em}{0ex}}1$; $q\phantom{\rule{-0.166667em}{0ex}}\leftarrow \phantom{\rule{-0.166667em}{0ex}}q\phantom{\rule{-0.166667em}{0ex}}+\phantom{\rule{-0.166667em}{0ex}}r\left[i\right]\phantom{\rule{-0.166667em}{0ex}}+\phantom{\rule{-0.166667em}{0ex}}r\left[j\right]$; Continue EndIf
- If($r[i-1]<r[j+1]$) $i\leftarrow i-1$; $q\leftarrow q+r\left[i\right]$; Continue EndIf
- If($r[i-1]>r[j+1]$) $j\leftarrow j+1$; $q\leftarrow q+r\left[j\right]$; Continue EndIf
- EndFor
**end procedure****procedure**CI_v2($\alpha $, x, m, i1, i2, er)- PMF_B($x,m,r$); $\beta \leftarrow 1-\alpha $; Found($\beta ,x,m,r,i1,i2$)
- Imp_1($\beta ,x,m,r,i1,i2,q$); Imp_2($\beta ,x,m,r,i1,i2,q$)
**end procedure**
Output:$i1$, $i2$, q // $[i1,i2]$ is the CI; q is the actual CI’s coverage |

## 5. Results and Discussion

#### 5.1. Properties of the Proposed Solutions

`If(r[i-1]=r[j+1])…EndIf`(Algorithms 1 and 3), and

`If(r[i]=r[j])…EndIf`(Algorithm 2) instructions blocks. Additionally, an important remark could be made about the Normal approximation interval (Equation (5)). This interval is actually (as defined by Equation (5)) even more symmetrical in relation to the observed number of successes (x), but if anyone considers the confidence intervals proposed by Equation (5) to be a very small (such as is x = 1, 2, …) or very large (such as is x = $m-1$, $m-2$, …) number of successes (see Table 5), it will be seen that a bound greater than m or smaller than 0 is not logical; therefore, it must be immediately patched (Equation 8).

#### 5.2. Smoothing of the Proposed Solutions

#### 5.3. General Discussion

## 6. Conclusions

## Funding

## Data Availability Statement

## Conflicts of Interest

## Appendix A

**Table A1.**Numbers providing the confidence intervals from Algorithm 1 at $\alpha $ = 0.05: $CI(\alpha ,x,m)=[{N}_{x},m-{N}_{m-x}]$.

m | + | + | + | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | x |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

1 | 0 | 1 | + | 20 | 17 | 16 | 14 | 13 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 2 | 1 | 0 | 0 | 0 | 0 | 20 |

2 | 0 | 0 | 2 | + | 19 | 16 | 15 | 13 | 12 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 3 | 2 | 1 | 0 | 0 | 0 | 0 | 19 |

3 | 0 | 0 | 1 | 3 | + | 18 | 15 | 14 | 12 | 11 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 3 | 2 | 1 | 0 | 0 | 0 | 0 | 18 |

4 | 0 | 0 | 0 | 1 | 4 | + | 17 | 14 | 13 | 11 | 10 | 8 | 7 | 6 | 5 | 4 | 3 | 3 | 2 | 1 | 0 | 0 | 0 | 0 | 17 |

5 | 0 | 0 | 0 | 1 | 2 | 5 | + | 16 | 13 | 12 | 10 | 9 | 7 | 6 | 5 | 4 | 4 | 3 | 2 | 1 | 0 | 0 | 0 | 0 | 16 |

6 | 0 | 0 | 0 | 1 | 2 | 3 | 6 | + | 15 | 12 | 11 | 9 | 8 | 6 | 5 | 4 | 4 | 3 | 2 | 1 | 0 | 0 | 0 | 0 | 15 |

7 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 7 | + | 14 | 11 | 10 | 8 | 7 | 6 | 4 | 3 | 3 | 2 | 1 | 0 | 0 | 0 | 0 | 14 |

8 | 0 | 0 | 0 | 1 | 1 | 2 | 4 | 5 | 8 | + | 13 | 10 | 9 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 13 |

9 | 0 | 0 | 0 | 1 | 2 | 2 | 3 | 5 | 6 | 9 | + | 12 | 9 | 8 | 6 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 12 |

10 | 0 | 0 | 0 | 1 | 1 | 2 | 3 | 4 | 6 | 7 | 10 | + | 11 | 8 | 7 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 11 |

x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | + | + | + | + | + | + | + | + | + | + | + | + | + | m |

**Table A2.**Numbers providing the confidence intervals from Algorithm 2 at $\alpha $ = 0.05: $CI(\alpha ,x,m)=[{N}_{x},m-{N}_{m-x}]$.

m | + | + | + | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | x |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

1 | 0 | 1 | + | 20 | 18 | 16 | 14 | 13 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 20 |

2 | 0 | 0 | 2 | + | 19 | 17 | 15 | 13 | 12 | 11 | 9 | 8 | 7 | 6 | 5 | 4 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 19 |

3 | 0 | 0 | 1 | 3 | + | 18 | 16 | 14 | 12 | 11 | 10 | 8 | 7 | 6 | 5 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 18 |

4 | 0 | 0 | 0 | 2 | 4 | + | 17 | 15 | 13 | 11 | 10 | 9 | 7 | 6 | 5 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 17 |

5 | 0 | 0 | 0 | 2 | 3 | 5 | + | 16 | 14 | 12 | 10 | 9 | 8 | 6 | 5 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 16 |

6 | 0 | 0 | 0 | 1 | 2 | 4 | 6 | + | 15 | 13 | 11 | 9 | 8 | 7 | 6 | 4 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 15 |

7 | 0 | 0 | 0 | 1 | 2 | 3 | 5 | 7 | + | 14 | 12 | 10 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 14 |

8 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 6 | 8 | + | 13 | 11 | 9 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 13 |

9 | 0 | 0 | 0 | 1 | 2 | 2 | 3 | 5 | 7 | 9 | + | 12 | 10 | 8 | 6 | 5 | 4 | 3 | 2 | 2 | 1 | 0 | 0 | 0 | 12 |

10 | 0 | 0 | 0 | 1 | 2 | 2 | 3 | 4 | 6 | 8 | 10 | + | 11 | 9 | 7 | 5 | 4 | 3 | 2 | 2 | 1 | 0 | 0 | 0 | 11 |

x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | + | + | + | + | + | + | + | + | + | + | + | + | + | m |

**Table A3.**Numbers providing the confidence intervals from Algorithm 3 at $\alpha $ = 0.05: $CI(\alpha ,x,m)=[{N}_{x},m-{N}_{m-x}]$.

m | + | + | + | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | x |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

1 | 0 | 1 | + | 20 | 17 | 16 | 13 | 13 | 11 | 9 | 7 | 8 | 7 | 6 | 5 | 4 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 20 |

2 | 0 | 0 | 2 | + | 19 | 16 | 15 | 12 | 12 | 11 | 9 | 7 | 7 | 6 | 5 | 4 | 4 | 3 | 1 | 1 | 1 | 0 | 0 | 0 | 19 |

3 | 0 | 0 | 1 | 3 | + | 18 | 15 | 14 | 11 | 11 | 10 | 8 | 6 | 5 | 5 | 5 | 4 | 3 | 1 | 1 | 1 | 0 | 0 | 0 | 18 |

4 | 0 | 0 | 0 | 1 | 4 | + | 17 | 14 | 13 | 10 | 10 | 9 | 7 | 5 | 4 | 5 | 4 | 3 | 1 | 1 | 1 | 0 | 0 | 0 | 17 |

5 | 0 | 0 | 0 | 1 | 2 | 5 | + | 16 | 13 | 12 | 9 | 9 | 8 | 6 | 5 | 4 | 4 | 3 | 1 | 1 | 1 | 0 | 0 | 0 | 16 |

6 | 0 | 0 | 0 | 1 | 2 | 3 | 6 | + | 15 | 12 | 11 | 8 | 8 | 7 | 6 | 4 | 4 | 2 | 1 | 1 | 1 | 0 | 0 | 0 | 15 |

7 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 7 | + | 14 | 11 | 10 | 7 | 7 | 6 | 5 | 3 | 2 | 2 | 1 | 1 | 0 | 0 | 0 | 14 |

8 | 0 | 0 | 0 | 0 | 1 | 3 | 4 | 5 | 8 | + | 13 | 10 | 9 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 13 |

9 | 0 | 0 | 0 | 1 | 2 | 2 | 3 | 5 | 6 | 9 | + | 12 | 9 | 8 | 6 | 0 | 4 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 12 |

10 | 0 | 0 | 0 | 1 | 2 | 2 | 2 | 4 | 6 | 7 | 10 | + | 11 | 8 | 7 | 5 | 0 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 11 |

x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | + | + | + | + | + | + | + | + | + | + | + | + | + | m |

**Table A4.**Numbers providing the confidence intervals with monotonic boundaries constrain at $\alpha $ = 0.05: $CI(\alpha ,x,m)=[{N}_{x},m-{N}_{m-x}]$.

m∖x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

2 | 0 | 0 | 2 | |||||||||||||||||||||||||||||

3 | 0 | 0 | 1 | 3 | ||||||||||||||||||||||||||||

4 | 0 | 0 | 0 | 2 | 4 | |||||||||||||||||||||||||||

5 | 0 | 0 | 0 | 2 | 3 | 5 | ||||||||||||||||||||||||||

6 | 0 | 0 | 0 | 1 | 2 | 4 | 6 | |||||||||||||||||||||||||

7 | 0 | 0 | 0 | 1 | 2 | 3 | 5 | 7 | ||||||||||||||||||||||||

8 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 6 | 8 | |||||||||||||||||||||||

9 | 0 | 0 | 0 | 0 | 2 | 2 | 4 | 5 | 7 | 9 | ||||||||||||||||||||||

10 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 5 | 6 | 8 | 10 | |||||||||||||||||||||

11 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 2 | 6 | 7 | 9 | 11 | ||||||||||||||||||||

12 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 2 | 2 | 7 | 8 | 10 | 12 | |||||||||||||||||||

13 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 2 | 2 | 2 | 8 | 9 | 11 | 13 | ||||||||||||||||||

14 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 9 | 10 | 12 | 14 | |||||||||||||||||

15 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 10 | 11 | 13 | 15 | ||||||||||||||||

16 | 0 | 0 | 0 | 0 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 9 | 11 | 12 | 14 | 16 | |||||||||||||||

17 | 0 | 0 | 0 | 0 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 9 | 10 | 12 | 13 | 15 | 17 | ||||||||||||||

18 | 0 | 0 | 0 | 0 | 1 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 9 | 10 | 11 | 13 | 14 | 16 | 18 | |||||||||||||

19 | 0 | 0 | 0 | 0 | 1 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 9 | 10 | 11 | 12 | 14 | 15 | 17 | 19 | ||||||||||||

20 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 2 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 18 | 20 | |||||||||||

21 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 19 | 21 | ||||||||||

22 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 20 | 22 | |||||||||

23 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 21 | 23 | ||||||||

24 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 22 | 24 | |||||||

25 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 7 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 23 | 25 | ||||||

26 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 24 | 26 | |||||

27 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 22 | 23 | 25 | 27 | ||||

28 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 6 | 7 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 23 | 24 | 26 | 28 | |||

29 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 6 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 24 | 25 | 27 | 29 | ||

30 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 5 | 6 | 6 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 25 | 26 | 28 | 30 | |

31 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 5 | 6 | 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 26 | 27 | 29 | 31 |

## References

- Ialongo, C. Confidence interval for quantiles and percentiles. Biochem. Med.
**2019**, 29, 010101. [Google Scholar] [CrossRef] - Jäntschi, L.; Bolboacă, S.-D. Performances of Shannon’s Entropy Statistic in Assessment of Distribution of Data. Ovidius Univ. Ann. Chem.
**2017**, 28, 30. [Google Scholar] [CrossRef] [Green Version] - Jäntschi, L. A test detecting the outliers for continuous distributions based on the cumulative distribution function of the data being tested. Symmetry
**2019**, 11, 835. [Google Scholar] [CrossRef] [Green Version] - Jäntschi, L. Detecting extreme values with order statistics in samples from continuous distributions. Mathematics
**2020**, 8, 216. [Google Scholar] [CrossRef] [Green Version] - Ruggles, R.; Brodie, H. An Empirical Approach to Economic Intelligence in World War II. J. Am. Stat. Assoc.
**1947**, 42, 72. [Google Scholar] [CrossRef] - Carter, E.-M.; Potts, H.-W.-W. Predicting length of stay from an electronic patient record system: A primary total knee replacement example. BMC Med. Inform. Decis. Mak.
**2014**, 14, 26. [Google Scholar] [CrossRef] [Green Version] - Jäntschi, L. Distribution fitting 16. How many colors are actually in the field? Buasvmcn. Hortic.
**2012**, 69, 184. [Google Scholar] - Fisher, R.A. The relation between the number of species and the number of individuals in a random sample of an animal population. Part 3. A Theoretical distribution for the apparent abundance of different species. J. Anim. Ecol.
**1943**, 12, 54. [Google Scholar] [CrossRef] - Devaurs, D.A.; Gras, R. Species abundance patterns in an ecosystem simulation studied through Fisher’s logseries. Simul. Model. Pract. Theor.
**2010**, 18, 100–123. [Google Scholar] [CrossRef] [Green Version] - Frigyik, B.A.; Kapila, A.; Gupta, M.R. Introduction to the Dirichlet Distribution and Related Processes: UWEE Technical Report UWEETR-2010-0006; University of Washington: Seattle, WA, USA, 2010; pp. 18–25. [Google Scholar]
- Dümbgen, L.; Samworth, R.J.; Wellner, J.A. Bounding distributional errors via density ratios. Bernoulli
**2021**, 27, 818–852. [Google Scholar] [CrossRef] - Bolboacă, S.-D.; Achimaş-Cadariu, B.-A. Binomial Distribution Sample Confidence Intervals Estimation 2. Proportion-like Medical Key Parameters. Leonardo Electron. J. Pract. Technol.
**2003**, 3, 75. [Google Scholar] - Newcombe, R.-G. Two–sided confidence intervals for the single proportion: Comparison of seven methods. Stat. Med.
**1998**, 17, 857. [Google Scholar] [CrossRef] - Pires, A.-M.; Amado, C. Interval estimators for a binomial proportion: Comparison of twenty methods. REVSTAT Stat. J.
**2008**, 6, 165. [Google Scholar] - Clopper, C.; Pearson, E.-S. The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika
**1934**, 26, 404. [Google Scholar] [CrossRef] - Sterne, T.E. Some Remarks on Confidence or Fiducial Limits. Biometrika
**1954**, 41, 275. [Google Scholar] - Blyth, C.R.; Still, H.A. Binomial confidence intervals. J. Am. Stat. Assoc.
**1983**, 78, 108. [Google Scholar] [CrossRef] - Casella, G. Refining Binomial Confidence Intervals. Can. J. Stat.
**1986**, 14, 113. [Google Scholar] [CrossRef] [Green Version] - Blaker, H. Confidence curves and improved exact confidence intervals for discrete distributions. Can. J. Stat.
**2000**, 28, 783. [Google Scholar] [CrossRef] [Green Version] - Bolboacă, S.-D.; Jäntschi, L. Optimized confidence intervals for binomial distributed samples. Int. J. Pure Appl. Math.
**2008**, 47, 1. [Google Scholar] - Jäntschi, L. Formulas, Algorithms and Examples for Binomial Distributed Data Confidence Interval Calculation: Excess Risk, Relative Risk and Odds Ratio. Mathematics
**2021**, 9, 2506. [Google Scholar] [CrossRef] - Sprott, D.A. What Is Optimality in Scientific Inference? Lect. Notes Monog. Ser.
**2004**, 44, 133–152. [Google Scholar] - Crow, E.L. Confidence Intervals for a Proportion. Biometrika
**1956**, 43, 423. [Google Scholar] [CrossRef] - Wang, W. Smallest confidence intervals for one binomial proportion. J. Stat. Plan. Inference
**2006**, 136, 4293. [Google Scholar] [CrossRef] - Eisenstein, J.; Chang, D.I. Case study: Improving population and individual health through health system transformation in Washington state. NAM Perspectives. Nat. Acad. Med.
**2017**, 4, 201704e. [Google Scholar] [CrossRef] - Brown, L.-D.; Cai, T.-T.; DasGupta, A. Interval Estimation for a Binomial Proportion. Stat. Sci.
**2001**, 16, 101. [Google Scholar] [CrossRef] - Agresti, A.; Coull, B.-A. Approximate is Better than “Exact” for Interval Estimation of Binomial Proportions. Am. Stat.
**1998**, 52, 119–126. [Google Scholar] - Bayes, T. An Essay Towards Solving a Problem in the Doctrine of Chances. Philos. Trans. R. Soc. Lond.
**1763**, 50, 370. [Google Scholar] [CrossRef] - Fienberg, S.-E. When Did Bayesian Inference Become “Bayesian”? Bayesian Anal.
**2006**, 1, 1. [Google Scholar] [CrossRef] - Vasil’ev, V.; Vasilyeva, M. An Accurate Approximation of the Two-Phase Stefan Problem with Coefficient Smoothing. Mathematics
**2020**, 8, 1924. [Google Scholar] [CrossRef] - Jäntschi, L.; Bálint, D.; Pruteanu, L.-L.; Bolboacă, S.-D. Elemental factorial study on one–cage pentagonal faces nanostructure congeners. Mater. Discov.
**2016**, 5, 14. [Google Scholar] [CrossRef]

**Figure 1.**Actual non-coverage probability ($\widehat{\alpha}$, in %) as function of the binomial random variable (x) for the asymptotic interval.

**Figure 2.**Actual non-coverage probability ($\widehat{\alpha}$, in %) as function of the binomial random variable (x) for the first “exact method” proposed (see below).

**Figure 3.**Actual non-coverage probability ($\widehat{\alpha}$, in %) as function of the binomial random variable (x) for the second “exact method” proposed (see below).

**Figure 4.**Actual non-coverage probability ($\widehat{\alpha}$, in %) as function of the binomial random variable (x) for the third “exact method” proposed (see below).

**Figure 5.**Lower and upper bound of four alternatives to construct the CI: Normal (Equation (5)) and the three proposed algorithms (Algorithms 1–3) when $m=10$, $x=0,1,\dots ,10$ and $\alpha =0.05$.

**Figure 6.**Optimum CIs when monotony rule is fully enacted for m = 31 and $\alpha $ = 0.05 (bounds in the left hand image and width in the right hand image).

**Figure 7.**Algorithm 1 CIs for m = 31 and $\alpha $ = 0.05 (bounds in the left hand image and width in the right hand image).

**Figure 8.**Algorithm 2 CIs for m = 31 and $\alpha $ = 0.05 (bounds in the left hand image and width in the right hand image).

**Figure 9.**Algorithm 3 CIs for m = 31 and $\alpha $ = 0.05 (bounds in the left hand image and width in the right hand image).

**Figure 10.**Optimum CIs when monotony rule is fully enacted: $\widehat{\alpha}$ (in %) when $\alpha $ = 5% is the imposed level (m = 31; x = 0, 1, …, m; CI in Figure 6; $\widehat{\alpha}$ is probably the smoothest one, SE($\u03f5$) = 0.301).

**Figure 11.**Algorithm 1 CIs: $\widehat{\alpha}$ (in %) when $\alpha $ = 5% is the imposed level (m = 31; x = 0, 1, …, m; $\widehat{\alpha}\le \alpha $ for all x = 0, 1, …, m; SE($\u03f5$) = 0.331).

**Figure 12.**Algorithm 2 CIs: $\widehat{\alpha}$ (in %) when $\alpha $ = 5% is the imposed level (m = 31; x = 0, 1, …, m; $\widehat{\alpha}$ better than the one from Figure 10, SE($\u03f5$) = 0.288).

**Figure 13.**Algorithm 3 CIs: $\widehat{\alpha}$ (in %) when $\alpha $ = 5% is the imposed level (m = 31; x = 0, 1, …, m; $\widehat{\alpha}\le \alpha $ for all x = 0, 1, …, m; $\widehat{\alpha}$ is better than the one from Figure 10, SE($\u03f5$) = 0.287).

**Figure 14.**Standard error of $\widehat{\alpha}$ (in %) for CIs from Algorithms 1–3, when $\alpha $ = 5% is the imposed level (m ranges from 10 to 100).

$\mathit{C}\mathit{I}({\mathit{i}}_{1},{\mathit{i}}_{2})$ | $\mathit{p}\mathit{C}\mathit{I}({\mathit{i}}_{1},{\mathit{i}}_{2})$ | Strategy |
---|---|---|

$[1,\phantom{\rule{3.33333pt}{0ex}}7]$ | 0.9817 | Descending probabilities (foundational strategy) |

$[2,\phantom{\rule{3.33333pt}{0ex}}7]$ | 0.9414 | 1st Improvement—decrease such that: $|\alpha -pCI|\to min.$ |

$[2,\phantom{\rule{3.33333pt}{0ex}}8]$ | 0.9520 | 2nd Improvement—increase such that: $|\alpha -pCI|\to min.$ |

_{RB}(u; 4, 10)) in a decreasing order. The 1st improvement proposes a shorter interval with a non-coverage probability (1 − 0.9414 = 0.0586) greater than the imposed level (0.0500), but with a much better proximity to it (1 − 0.9817 = 0.0183). The 2nd improvement expands the 1st improvement and provides an even better proximity (1 − 0.9520 = 0.0480).

**Table 2.**PMF example for a replica ($u,m$) of a ($x,m$) draw (${f}_{\mathrm{RB}}$ from Equation (3)).

u | ${\mathit{f}}_{\mathbf{RB}}\left(\mathit{u};4,10\right)$ | u | ${\mathit{f}}_{\mathbf{RB}}\left(\mathit{u};4,10\right)$ |
---|---|---|---|

0 | 0.0060 | 6 | 0.1115 |

1 | 0.0403 | 7 | 0.0425 |

2 | 0.1209 | 8 | 0.0106 |

3 | 0.2150 | 9 | 0.0016 |

4 | 0.2508 | 10 | 0.0001 |

5 | 0.2007 | Any | 1.0000 |

_{RB}(u; 4, 10)), 0 ≤ u ≤ 10}. It can be observed that u = x is the most probable event. The numeric values of the probabilities are given with four significant decimals. However, the calculations and the actual values are recommended to be done with machine-like precision (see Table 2 in [4] and Section 5.3 in [21] for an extended explanation).

**Table 3.**CDF example for a replica ($u,m$) of a ($x,m$) draw (${F}_{\mathrm{RB}}$ from Equation (6)).

u | ${\mathit{F}}_{\mathbf{RB}}\left(\mathit{u};4,10\right)$ | u | ${\mathit{F}}_{\mathbf{RB}}\left(\mathit{u};4,10\right)$ |
---|---|---|---|

0 | 0.0060 | 6 | 0.9452 |

1 | 0.0463 | 7 | 0.9877 |

2 | 0.1672 | 8 | 0.9983 |

3 | 0.3822 | 9 | 0.9999 |

4 | 0.6330 | 10 | 1.0000 |

5 | 0.8337 |

_{RB}(u; 4, 10)), 0 ≤ u ≤ 10}.

**Table 4.**CIs for any replica ($u,m$) of a ($x,m$) draw ($C{I}_{{i}_{1},{i}_{2}}$ from Equation (7)).

${\mathit{i}}_{1}$ | ${\mathit{i}}_{2}$ | $\mathit{C}\mathit{I}({\mathit{i}}_{1},{\mathit{i}}_{2})$ | $\mathit{p}\mathit{C}\mathit{I}({\mathit{i}}_{1},{\mathit{i}}_{2})$ | ${\mathit{i}}_{1}$ | ${\mathit{i}}_{2}$ | $\mathit{C}\mathit{I}({\mathit{i}}_{1},{\mathit{i}}_{2})$ | $\mathit{p}\mathit{C}\mathit{I}({\mathit{i}}_{1},{\mathit{i}}_{2})$ |
---|---|---|---|---|---|---|---|

4 | 4 | [4, 4] | 0.2508 | 1 | 7 | [1, 7] | 0.9817 |

3 | 4 | [3, 4] | 0.4658 | 1 | 8 | [1, 8] | 0.9923 |

3 | 5 | [3, 5] | 0.6665 | 0 | 8 | [0, 8] | 0.9983 |

2 | 5 | [2, 5] | 0.7874 | 0 | 9 | [0, 9] | 0.9999 |

2 | 6 | [2, 6] | 0.8989 | 0 | 10 | [0, 10] | 1 |

2 | 7 | [2, 7] | 0.9414 |

_{RB}(u; 4, 10)). The values of the probabilities are given with four significant decimals.

x | $1-\mathbf{pCI}\left(\mathit{x}\right)$ | ${\mathit{C}\mathit{I}}_{\mathit{N}}\left(\mathit{x}\right)$ | ${\mathit{C}\mathit{I}}_{\mathit{N}\mathit{P}}\left(\mathit{x}\right)$ | ${\mathit{C}\mathit{I}}_{\mathit{N}\mathit{N}}\left(\mathit{x}\right)$ |
---|---|---|---|---|

1 | 0.0702 | [−0.9$,+2.9]$ | $[0.0,2.9]$ | $[0,2]$ |

2 | 0.0328 | [−0.5$,+4.5]$ | $[0.0,4.5]$ | $[0,4]$ |

3 | 0.0756 | $[+0.2,+5.8]$ | $[0.2,5.8]$ | $[1,5]$ |

7 | 0.0756 | $[+4.2,+9.8]$ | $[4.2,9.8]$ | $[4,9]$ |

8 | 0.0328 | $[+5.5,10.5]$ | $[5.5,10.0]$ | $[5,10]$ |

9 | 0.0702 | $[+7.1,10.9]$ | $[7.1,10.0]$ | $[7,10]$ |

_{N}(x) is the CI calculated with Equation (5); one decimal digit is given. Since only an integer between 0 and m = 10 can be recorded as number of successes, CI

_{NP}(x) is the adjustment of the CI calculated with Equation (5) and adjusted to make sense at limits (0 and m = 10); one decimal digit is given. Furthermore, since only a natural number of successes can be recorded, a decimal number as boundary may be implausible, so CI

_{NP}(x) is the adjustment of the CI

_{NP}(x) to have integer boundaries.

Bin | ${\mathit{N}}_{\mathit{i}}$ | CI | $\widehat{\mathit{\alpha}}$, in % | ||||||
---|---|---|---|---|---|---|---|---|---|

0 | 0 | 0 | 0 | [0, 0] | [0, 0] | [0, 0] | 0.00 | 0.00 | 0.00 |

1 | 0 | 0 | 0 | [0, 3] | [0, 2] | [0, 3] | 1.12 | 6.73 | 1.12 |

2 | 0 | 0 | 0 | [0, 4] | [0, 4] | [0, 4] | 2.73 | 2.73 | 2.73 |

3 | 1 | 1 | 0 | [1, 6] | [1, 5] | [0, 5] | 2.89 | 5.93 | 3.60 |

4 | 1 | 2 | 1 | [1, 7] | [2, 6] | [1, 7] | 0.78 | 7.03 | 0.78 |

5 | 2 | 3 | 3 | [2, 7] | [3, 7] | [3, 8] | 2.89 | 5.93 | 3.60 |

6 | 4 | 4 | 4 | [4, 8] | [4, 8] | [4, 8] | 2.73 | 2.73 | 2.73 |

7 | 5 | 6 | 5 | [5, 8] | [6, 8] | [5, 8] | 1.12 | 6.73 | 1.12 |

8 | 8 | 8 | 8 | [8, 8] | [8, 8] | [8, 8] | 0.00 | 0.00 | 0.00 |

x | A1 | A2 | A3 | A1 | A2 | A3 | A1 | A2 | A3 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2022 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Jäntschi, L.
Binomial Distributed Data Confidence Interval Calculation: Formulas, Algorithms and Examples. *Symmetry* **2022**, *14*, 1104.
https://doi.org/10.3390/sym14061104

**AMA Style**

Jäntschi L.
Binomial Distributed Data Confidence Interval Calculation: Formulas, Algorithms and Examples. *Symmetry*. 2022; 14(6):1104.
https://doi.org/10.3390/sym14061104

**Chicago/Turabian Style**

Jäntschi, Lorentz.
2022. "Binomial Distributed Data Confidence Interval Calculation: Formulas, Algorithms and Examples" *Symmetry* 14, no. 6: 1104.
https://doi.org/10.3390/sym14061104