EVOLUTION-MANAGER
Edit File: Geometric.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: The Geometric Distribution</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for Geometric {stats}"><tr><td>Geometric {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>The Geometric Distribution</h2> <h3>Description</h3> <p>Density, distribution function, quantile function and random generation for the geometric distribution with parameter <code>prob</code>. </p> <h3>Usage</h3> <pre> 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) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, q</code></td> <td> <p>vector of quantiles representing the number of failures in a sequence of Bernoulli trials before success occurs.</p> </td></tr> <tr valign="top"><td><code>p</code></td> <td> <p>vector of probabilities.</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>number of observations. If <code>length(n) > 1</code>, the length is taken to be the number required.</p> </td></tr> <tr valign="top"><td><code>prob</code></td> <td> <p>probability of success in each trial. <code>0 < prob <= 1</code>.</p> </td></tr> <tr valign="top"><td><code>log, log.p</code></td> <td> <p>logical; if TRUE, probabilities p are given as log(p).</p> </td></tr> <tr valign="top"><td><code>lower.tail</code></td> <td> <p>logical; if TRUE (default), probabilities are <i>P[X ≤ x]</i>, otherwise, <i>P[X > x]</i>.</p> </td></tr> </table> <h3>Details</h3> <p>The geometric distribution with <code>prob</code> <i>= p</i> has density </p> <p style="text-align: center;"><i>p(x) = p (1-p)^x</i></p> <p>for <i>x = 0, 1, 2, …</i>, <i>0 < p ≤ 1</i>. </p> <p>If an element of <code>x</code> is not integer, the result of <code>dgeom</code> is zero, with a warning. </p> <p>The quantile is defined as the smallest value <i>x</i> such that <i>F(x) ≥ p</i>, where <i>F</i> is the distribution function. </p> <h3>Value</h3> <p><code>dgeom</code> gives the density, <code>pgeom</code> gives the distribution function, <code>qgeom</code> gives the quantile function, and <code>rgeom</code> generates random deviates. </p> <p>Invalid <code>prob</code> will result in return value <code>NaN</code>, with a warning. </p> <p>The length of the result is determined by <code>n</code> for <code>rgeom</code>, and is the maximum of the lengths of the numerical arguments for the other functions. </p> <p>The numerical arguments other than <code>n</code> are recycled to the length of the result. Only the first elements of the logical arguments are used. </p> <h3>Source</h3> <p><code>dgeom</code> computes via <code>dbinom</code>, using code contributed by Catherine Loader (see <code><a href="Binomial.html">dbinom</a></code>). </p> <p><code>pgeom</code> and <code>qgeom</code> are based on the closed-form formulae. </p> <p><code>rgeom</code> uses the derivation as an exponential mixture of Poissons, see </p> <p>Devroye, L. (1986) <em>Non-Uniform Random Variate Generation.</em> Springer-Verlag, New York. Page 480. </p> <h3>See Also</h3> <p><a href="Distributions.html">Distributions</a> for other standard distributions, including <code><a href="NegBinomial.html">dnbinom</a></code> for the negative binomial which generalizes the geometric distribution. </p> <h3>Examples</h3> <pre> qgeom((1:9)/10, prob = .2) Ni <- rgeom(20, prob = 1/4); table(factor(Ni, 0:max(Ni))) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>