EVOLUTION-MANAGER
Edit File: Normal.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 Normal 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 Normal {stats}"><tr><td>Normal {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>The Normal Distribution</h2> <h3>Description</h3> <p>Density, distribution function, quantile function and random generation for the normal distribution with mean equal to <code>mean</code> and standard deviation equal to <code>sd</code>. </p> <h3>Usage</h3> <pre> dnorm(x, mean = 0, sd = 1, log = FALSE) pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) rnorm(n, mean = 0, sd = 1) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, q</code></td> <td> <p>vector of quantiles.</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>mean</code></td> <td> <p>vector of means.</p> </td></tr> <tr valign="top"><td><code>sd</code></td> <td> <p>vector of standard deviations.</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>If <code>mean</code> or <code>sd</code> are not specified they assume the default values of <code>0</code> and <code>1</code>, respectively. </p> <p>The normal distribution has density </p> <p style="text-align: center;"><i> f(x) = 1/(√(2 π) σ) e^-((x - μ)^2/(2 σ^2)) </i></p> <p>where <i>μ</i> is the mean of the distribution and <i>σ</i> the standard deviation. </p> <h3>Value</h3> <p><code>dnorm</code> gives the density, <code>pnorm</code> gives the distribution function, <code>qnorm</code> gives the quantile function, and <code>rnorm</code> generates random deviates. </p> <p>The length of the result is determined by <code>n</code> for <code>rnorm</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> <p>For <code>sd = 0</code> this gives the limit as <code>sd</code> decreases to 0, a point mass at <code>mu</code>. <code>sd < 0</code> is an error and returns <code>NaN</code>. </p> <h3>Source</h3> <p>For <code>pnorm</code>, based on </p> <p>Cody, W. D. (1993) Algorithm 715: SPECFUN – A portable FORTRAN package of special function routines and test drivers. <em>ACM Transactions on Mathematical Software</em> <b>19</b>, 22–32. </p> <p>For <code>qnorm</code>, the code is a C translation of </p> <p>Wichura, M. J. (1988) Algorithm AS 241: The percentage points of the normal distribution. <em>Applied Statistics</em>, <b>37</b>, 477–484. </p> <p>which provides precise results up to about 16 digits. </p> <p>For <code>rnorm</code>, see <a href="../../base/html/Random.html">RNG</a> for how to select the algorithm and for references to the supplied methods. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <p>Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) <em>Continuous Univariate Distributions</em>, volume 1, chapter 13. Wiley, New York. </p> <h3>See Also</h3> <p><a href="Distributions.html">Distributions</a> for other standard distributions, including <code><a href="Lognormal.html">dlnorm</a></code> for the <em>Log</em>normal distribution. </p> <h3>Examples</h3> <pre> require(graphics) dnorm(0) == 1/sqrt(2*pi) dnorm(1) == exp(-1/2)/sqrt(2*pi) dnorm(1) == 1/sqrt(2*pi*exp(1)) ## Using "log = TRUE" for an extended range : par(mfrow = c(2,1)) plot(function(x) dnorm(x, log = TRUE), -60, 50, main = "log { Normal density }") curve(log(dnorm(x)), add = TRUE, col = "red", lwd = 2) mtext("dnorm(x, log=TRUE)", adj = 0) mtext("log(dnorm(x))", col = "red", adj = 1) plot(function(x) pnorm(x, log.p = TRUE), -50, 10, main = "log { Normal Cumulative }") curve(log(pnorm(x)), add = TRUE, col = "red", lwd = 2) mtext("pnorm(x, log=TRUE)", adj = 0) mtext("log(pnorm(x))", col = "red", adj = 1) ## if you want the so-called 'error function' erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1 ## (see Abramowitz and Stegun 29.2.29) ## and the so-called 'complementary error function' erfc <- function(x) 2 * pnorm(x * sqrt(2), lower = FALSE) ## and the inverses erfinv <- function (x) qnorm((1 + x)/2)/sqrt(2) erfcinv <- function (x) qnorm(x/2, lower = FALSE)/sqrt(2) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>