\Header{Geometric}{The Geometric Distribution}
\alias{dgeom}{Geometric}
\alias{pgeom}{Geometric}
\alias{qgeom}{Geometric}
\alias{rgeom}{Geometric}
\keyword{distribution}{Geometric}
\begin{Description}\relax
Density, distribution function, quantile function and random
generation for the geometric distribution with parameter \code{prob}.\end{Description}
\begin{Usage}
\begin{verbatim}
dgeom(x, prob, log = FALSE)
pgeom(q, prob, lower.tail = TRUE, log.p = FALSE)
qgeom(p, prob, lower.tail = TRUE, log.p = FALSE)
rgeom(n, prob)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x, q}] vector of quantiles representing the number of failures in
a sequence of Bernoulli trials before success occurs.
\item[\code{p}] vector of probabilities.
\item[\code{n}] number of observations. If \code{length(n) > 1}, the length
is taken to be the number required.
\item[\code{prob}] probability of success in each trial.
\item[\code{log, log.p}] logical; if TRUE, probabilities p are given as log(p).
\item[\code{lower.tail}] logical; if TRUE (default), probabilities are
\eqn{P[X \le x]}{P[X <= x]}, otherwise, \eqn{P[X > x]}{P[X > x]}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The geometric distribution with \code{prob} \eqn{= p}{} has density
\deqn{p(x) = p {(1-p)}^{x}}{p(x) = p (1-p)^x}
for \eqn{x = 0, 1, 2, \ldots}{x = 0, 1, 2, ...}

If an element of \code{x} is not integer, the result of \code{pgeom}
is zero, with a warning.

The quantile is defined as the smallest value \eqn{x}{} such that
\eqn{F(x) \ge p}{}, where \eqn{F}{} is the distribution function.\end{Details}
\begin{Value}
\code{dgeom} gives the density,
\code{pgeom} gives the distribution function,
\code{qgeom} gives the quantile function, and
\code{rgeom} generates random deviates.\end{Value}
\begin{SeeAlso}\relax
\code{\Link{dnbinom}} for the negative binomial which generalizes
the geometric distribution.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
pp <- sort(c((1:9)/10, 1 - .2^(2:8)))
print(qg <- qgeom(pp, prob = .2))
## test that qgeom is an inverse of pgeom
print(qg1 <- qgeom(pgeom(qg, prob=.2), prob =.2))
all(qg == qg1)
Ni <- rgeom(20, prob = 1/4); table(factor(Ni, 0:max(Ni)))
\end{ExampleCode}
\end{Examples}

