How to Use pnorm in R (Examples)

This tutorial shows the definition of pnorm() in R and how to use it with examples. pnorm() is used to return probability (p) for the given quantile (q).

pnorm(q, mean, sd, lower.tail = TRUE, log.p = FALSE)

  • q: the quantile (value on the x-axis)
  • mean: The mean of the sample data. The default value is 0.
  • sd: The standard deviation. The default value is 1.
  • lower.tail: By default, lower.tail = TRUE. If lower.tail = TRUE, CDF is calculated from left (lower tail) to right (higher tail).
  • log.p: The default value is FALSE. If log.p=TRUE, p generated by the function is a log-value.

Examples of how to use pnorm in R

Example 1

The following is the R code example of pnorm(). In particular, it returns the probability value for the CDF in the range of (-, 0) for the standard normal distribution (i.e., mean = 0 and sd =1).

> pnorm(0, 0, 1)
[1] 0.5

The following is the plot for pnorm(0, 0, 1). The area of the blue shade is 0.5.

Plot shaded area for pnorm(0, 0, 1)
Plot shaded area for pnorm(0, 0, 1)

Example 2

The following returns the CDF value for (-, 2). The value is 0.977, which is a probability value.

> pnorm(2, 0, 1)
[1] 0.9772499

The following is the plot for pnorm(2, 0, 1). The area of red shade is 0.977.

Plot shaded area for pnorm(2, 0, 1)

Example 3: lower.tail = TRUE in pnorm()

By default, lower.tail = TRUE. It means that probability CDF is calculated from left (lower tail) to right (higher tail). Thus, without and with lower.tail = TRUE will generate the same result.

> pnorm(2, 0, 1)
[1] 0.9772499

> pnorm(2, 0, 1,lower.tail = TRUE)
[1] 0.9772499

Example 4: lower.tail = FALSE in pnorm()

If lower.tail = FALSE, probability CDF is calculated from right (higher tail) to left (lower tail). Thus, lower.tail = FALSE and lower.tail = TRUE will generate opposite results.

> pnorm(2, 0, 1,lower.tail = TRUE)
[1] 0.9772499

> pnorm(2, 0, 1,lower.tail = FALSE)
[1] 0.02275013

Example 5: log.p = FALSE in pnorm()

If log.p = FALSE, it will return log(p). The following is the R code example.

> pnorm(2, 0, 1,log.p = FALSE)
[1] 0.9772499

> pnorm(2, 0, 1,log.p = TRUE)
[1] -0.02301291

Note that, log(0.9772499) = -0.02301288, which is very close to -0.02301291.


Further Reading