Compute moments for truncated binomial distribution
Source:R/truncbinom.R
calc_moments_truncbinom.Rd
For random variable \(X \sim TBinom(n,p)\), which follows the
(zero)-truncated binomial distribution as defined
by dtruncbinom()
(i.e., binomial
distribution with support for zero removed),
calc_moments_truncbinom()
computes \(\textrm{E}(X)\), \(\textrm{E}(X^2)\),
\(\textrm{Var}(X)\), and \(\textrm{E}(1/X)\).
Arguments
- size
scalar number of trials (
n
); must be 1 or more- prob
scalar probability of success on each trial (
p
); must be nonzero
Value
vector containing \(\textrm{E}(X)\), \(\textrm{E}(X^2)\), \(\textrm{Var}(X)\), and \(\textrm{E}(1/x)\)
Details
Note that moments are computed directly using the probability mass function since there is not a simple closed form for \(\textrm{E}(1/x)\). This may lead to slow computation for extremely large numbers of trials.
See also
dtruncbinom()
for computing TBinom densities