| ZeroTruncatedGeometric {actuar} | R Documentation |
The Zero-Truncated Geometric Distribution
Description
Density function, distribution function, quantile function and random
generation for the Zero-Truncated Geometric distribution with
parameter prob.
Usage
dztgeom(x, prob, log = FALSE)
pztgeom(q, prob, lower.tail = TRUE, log.p = FALSE)
qztgeom(p, prob, lower.tail = TRUE, log.p = FALSE)
rztgeom(n, prob)
Arguments
x |
vector of (strictly positive integer) quantiles. |
q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. If |
prob |
parameter. |
log, log.p |
logical; if |
lower.tail |
logical; if |
Details
The zero-truncated geometric distribution with prob = p
has probability mass function
%
p(x) = p (1-p)^{x - 1}
for x = 1, 2, \ldots and 0 < p < 1, and
p(1) = 1 when p = 1.
The cumulative distribution function is
P(x) = \frac{F(x) - F(0)}{1 - F(0)},
where F(x) is the distribution function of the standard geometric.
The mean is 1/p and the variance is (1-p)/p^2.
In the terminology of Klugman et al. (2012), the zero-truncated
geometric is a member of the (a, b, 1) class of
distributions with a = 1-p and b = 0.
If an element of x is not integer, the result of
dztgeom is zero, with a warning.
The quantile is defined as the smallest value x such that
P(x) \ge p, where P is the distribution function.
Value
dztgeom gives the (log) probability mass function,
pztgeom gives the (log) distribution function,
qztgeom gives the quantile function, and
rztgeom generates random deviates.
Invalid prob will result in return value NaN, with a
warning.
The length of the result is determined by n for
rztgeom, and is the maximum of the lengths of the
numerical arguments for the other functions.
Note
Functions {d,p,q}ztgeom use {d,p,q}geom for all but
the trivial input values and p(0).
rztgeom uses the simple inversion algorithm suggested by
Peter Dalgaard on the r-help mailing list on 1 May 2005
(https://stat.ethz.ch/pipermail/r-help/2005-May/070680.html).
Author(s)
Vincent Goulet vincent.goulet@act.ulaval.ca
References
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (2012), Loss Models, From Data to Decisions, Fourth Edition, Wiley.
See Also
dgeom for the geometric distribution.
dztnbinom for the zero-truncated negative binomial, of
which the zero-truncated geometric is a special case.
Examples
p <- 1/(1 + 0.5)
dztgeom(c(1, 2, 3), prob = p)
dgeom(c(1, 2, 3), p)/pgeom(0, p, lower = FALSE) # same
dgeom(c(1, 2, 3) - 1, p) # same
pztgeom(1, prob = 1) # point mass at 1
qztgeom(pztgeom(1:10, 0.3), 0.3)