3
$\begingroup$

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?

| cite | improve this question | | | | |
$\endgroup$
  • 2
    $\begingroup$ Because a normal distribution is fully specified by its mean and standard deviation. $\endgroup$ – dsaxton Oct 11 '16 at 18:13
5
$\begingroup$

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.

| cite | improve this answer | | | | |
$\endgroup$
  • 2
    $\begingroup$ 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}$ $\endgroup$ – Glen_b -Reinstate Monica Oct 12 '16 at 0:15
1
$\begingroup$

Function dnorm gives PDF and pnorm gives CDF.

enter image description here

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$

| cite | improve this answer | | | | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.