dbinom_raw {DPQ} | R Documentation |

## R's C Mathlib (Rmath) dbinom_raw() Binomial Probability pure R Function

### Description

A pure **R** implementation of R's C API (‘Mathlib’ specifically)
`dbinom_raw()`

function which computes binomial probabilities
*and* is continuous in `x`

, i.e., also “works” for
non-integer `x`

.

### Usage

```
dbinom_raw (x, n, p, q = 1-p, log = FALSE, verbose = getOption("verbose"))
```

### Arguments

`x` |
vector with values typically in |

`n` |
called |

`p` |
called |

`q` |
mathemtically the same as |

`log` |
logical indicating if the |

`verbose` |
integer indicating the amount of verbosity of
diagnostic output, |

### Value

numeric vector of the same length as `x`

which may have to be
thought of recycled along `n`

, `p`

and/or `q`

.

### Author(s)

R Core and Martin Maechler

### See Also

Note that our CRAN package Rmpfr provides
`dbinom`

, an mpfr-accurate function to be used
used instead of **R**'s or this pure **R** version relying `bd0()`

and
`stirlerr()`

where the latter currently only provides
accurate double precision accuracy.

### Examples

```
for(n in c(3, 10, 27, 100, 500, 2000, 5000, 1e4, 1e7, 1e10)) {
x <- if(n <= 2000) 0:n else round(seq(0, n, length.out=2000))
p <- 3/4
stopifnot(all.equal(dbinom_raw(x, n, p, q=1-p),
dbinom (x, n, p), tol = 1e-13))# 1.636e-14 (Apple clang 14.0.3)
}
n <- 1024 ; x <- 0:n
plot(x, dbinom_raw(x, n, p, q=1-p) - dbinom(x, n, p), type="l", main = "|db_r(x) - db(x)|")
plot(x, dbinom_raw(x, n, p, q=1-p) / dbinom(x, n, p) - 1, type="b", log="y",
main = "rel.err. |db_r(x / db(x) - 1)|")
```

*DPQ*version 0.5-8 Index]