Description Usage Arguments Details Value References Examples

Density, distribution function, quantile function and random generation for
the generalized Poisson binomial distribution with probability vector
`probs`

.

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 32 33 | ```
dgpbinom(x, probs, val_p, val_q, wts = NULL, method = "DivideFFT", log = FALSE)
pgpbinom(
x,
probs,
val_p,
val_q,
wts = NULL,
method = "DivideFFT",
lower.tail = TRUE,
log.p = FALSE
)
qgpbinom(
p,
probs,
val_p,
val_q,
wts = NULL,
method = "DivideFFT",
lower.tail = TRUE,
log.p = FALSE
)
rgpbinom(
n,
probs,
val_p,
val_q,
wts = NULL,
method = "DivideFFT",
generator = "Sample"
)
``` |

`x` |
Either a vector of observed sums or NULL. If NULL, probabilities of all possible observations are returned. |

`probs` |
Vector of probabilities of success of each Bernoulli trial. |

`val_p` |
Vector of values that each trial produces with probability
in |

`val_q` |
Vector of values that each trial produces with probability
in |

`wts` |
Vector of non-negative integer weights for the input probabilities. |

`method` |
Character string that specifies the method of computation
and must be one of |

`log, log.p` |
Logical value indicating if results are given as logarithms. |

`lower.tail` |
Logical value indicating if results are |

`p` |
Vector of probabilities for computation of quantiles. |

`n` |
Number of observations. If |

`generator` |
Character string that specifies the random number
generator and must either be |

See the references for computational details. The *Divide and Conquer*
(`"DivideFFT"`

) and *Direct Convolution* (`"Convolve"`

)
algorithms are derived and described in Biscarri, Zhao & Brunner (2018). They
have been modified for use with the generalized Poisson binomial
distribution. The
*Discrete Fourier Transformation of the Characteristic Function*
(`"Characteristic"`

) is derived in Zhang, Hong & Balakrishnan (2018),
the *Normal Approach* (`"Normal"`

) and the
*Refined Normal Approach* (`"RefinedNormal"`

) are described in Hong
(2013). They were slightly adapted for the generalized Poisson binomial
distribution.

In some special cases regarding the values of `probs`

, the `method`

parameter is ignored (see Introduction vignette).

Random numbers can be generated in two ways. The `"Sample"`

method
uses `R`

's `sample`

function to draw random values according to
their probabilities that are calculated by `dgpbinom`

. The
`"Bernoulli"`

procedure ignores the `method`

parameter and
simulates Bernoulli-distributed random numbers according to the probabilities
in `probs`

and sums them up. It is a bit slower than the `"Sample"`

generator, but may yield better results, as it allows to obtain observations
that cannot be generated by the `"Sample"`

procedure, because
`dgpbinom`

may compute 0-probabilities, due to rounding, if the length
of `probs`

is large and/or its values contain a lot of very small
values.

`dgpbinom`

gives the density, `pgpbinom`

computes the distribution
function, `qgpbinom`

gives the quantile function and `rgpbinom`

generates random deviates.

For `rgpbinom`

, the length of the result is determined by `n`

, and
is the lengths of the numerical arguments for the other functions.

Hong, Y. (2018). On computing the distribution function for the Poisson
binomial distribution. *Computational Statistics & Data Analysis*,
**59**, pp. 41-51. doi: 10.1016/j.csda.2012.10.006

Biscarri, W., Zhao, S. D. and Brunner, R. J. (2018) A simple and fast method
for computing the Poisson binomial distribution.
*Computational Statistics and Data Analysis*, **31**, pp.
216–222. doi: 10.1016/j.csda.2018.01.007

Zhang, M., Hong, Y. and Balakrishnan, N. (2018). The generalized
Poisson-binomial distribution and the computation of its distribution
function. *Journal of Statistical Computational and Simulation*,
**88**(8), pp. 1515-1527. doi: 10.1080/00949655.2018.1440294

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 | ```
set.seed(1)
pp <- c(1, 0, runif(10), 1, 0, 1)
qq <- seq(0, 1, 0.01)
va <- rep(5, length(pp))
vb <- 1:length(pp)
dgpbinom(NULL, pp, va, vb, method = "DivideFFT")
pgpbinom(75:100, pp, va, vb, method = "DivideFFT")
qgpbinom(qq, pp, va, vb, method = "DivideFFT")
rgpbinom(100, pp, va, vb, method = "DivideFFT")
dgpbinom(NULL, pp, va, vb, method = "Convolve")
pgpbinom(75:100, pp, va, vb, method = "Convolve")
qgpbinom(qq, pp, va, vb, method = "Convolve")
rgpbinom(100, pp, va, vb, method = "Convolve")
dgpbinom(NULL, pp, va, vb, method = "Characteristic")
pgpbinom(75:100, pp, va, vb, method = "Characteristic")
qgpbinom(qq, pp, va, vb, method = "Characteristic")
rgpbinom(100, pp, va, vb, method = "Characteristic")
dgpbinom(NULL, pp, va, vb, method = "Normal")
pgpbinom(75:100, pp, va, vb, method = "Normal")
qgpbinom(qq, pp, va, vb, method = "Normal")
rgpbinom(100, pp, va, vb, method = "Normal")
dgpbinom(NULL, pp, va, vb, method = "RefinedNormal")
pgpbinom(75:100, pp, va, vb, method = "RefinedNormal")
qgpbinom(qq, pp, va, vb, method = "RefinedNormal")
rgpbinom(100, pp, va, vb, method = "RefinedNormal")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.