# pnorm function in R

How does the pnorm function in R work? I mean how it computes $P(X<10)$ with only the mean and standard deviation given. Does it work same like $z$-score to compute percentages?

• Because a normal distribution is fully specified by its mean and standard deviation. – dsaxton Oct 11 '16 at 18:13

pnorm calculates cumulative distribution function of normal distribution, i.e.

$$\Pr(X \le x) = F(x) = \frac12\left[1 + \operatorname{erf}\left( \frac{x-\mu}{\sigma\sqrt{2}}\right)\right]$$

where $\mu$ is mean and $\sigma$ is standard deviation. As noted by dsaxton to calculate the probabilities for normally distributed random variable $X$ you need only to know $\mu$ and $\sigma$ parameters and apply the function.

If you are not familiar with those concepts you should read carefully the Wikipedia articles I linked above and you should check some introductory handbook on statistics, e.g. All of Statistics by Larry Wasserman. Harvard University provides online lecture introducing probability theory called Statistics 110: Probability by Joe Blitzstein, it's also a good starting point.

• Indeed the C code for pnorm has "The main computation evaluates near-minimax approximations derived from those in "Rational Chebyshev approximations for the error function" by W. J. Cody, Math. Comp., 1969, 631-637. This transportable program uses rational functions that theoretically approximate the normal distribution function to at least 18 significant decimal digits. The accuracy achieved depends on the arithmetic system, the compiler, the intrinsic functions, and proper selection of the machine-dependent constants." ... looks like it literally uses an implementation of $\text{erf}$ – Glen_b -Reinstate Monica Oct 12 '16 at 0:15

Function dnorm gives PDF and pnorm gives CDF.

For example, if you want to find $P(x<2)$ for standard normal distribution (mean=0 and sd=1), you can use pnorm(2), which is $0.977$.

If you want to find $P(1<x<2)$ for a normal distribution with mean=1 and sd=2 you can do pnorm(2,mean=1,sd=2)-pnorm(1,mean=1,sd=2), which is $0.191$