← Back to R Course | Chapter 9: Statistics | Lesson 7 of 7

Probability Distributions

Probability Distributions

R has built-in functions for common probability distributions, following a d/p/q/r naming convention -- rnorm() generates random normal values, dnorm() gives the density, pnorm() gives the cumulative probability, and qnorm() gives the quantile. This same pattern applies to other distributions like runif(), rbinom(), and rpois(). This built-in statistical machinery is a major reason R is popular for data analysis.

Note: The prefix tells you what the function does: r=random draw, d=density, p=cumulative probability, q=quantile.

Example: Probability Distributions

markup
set.seed(1)
samples <- rnorm(5, mean = 0, sd = 1)
print(samples)

cat("P(X <= 0) for standard normal:", pnorm(0), "\n")
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.