Plot exponential PDF in R

How to Plot an Exponential Distribution in R?


The is a probability distribution that is used to model the time we must wait until a certain event occurs.

If a X follows an exponential distribution, then the probability density function of X can be written as:

f(x; λ) = λe-λx

where:

  • λ: the rate parameter
  • e: A constant roughly equal to 2.718

The cumulative distribution function of X can be written as:

F(x; λ) = 1 – e-λx

This tutorial explains how to plot a PDF and CDF for the exponential distribution in R.

Plotting a Probability Density Function

The following code shows how to plot a PDF of an exponential distribution with rate parameter λ = 0.5:

curve(dexp(x, rate = .5), from=0, to=10, col='blue')

Plot exponential PDF in R

The following code shows how to plot multiple PDF’s of an exponential distribution with various rate parameters:

#plot PDF curves
curve(dexp(x, rate = .5), from=0, to=10, col='blue')
curve(dexp(x, rate = 1), from=0, to=10, col='red', add=TRUE)
curve(dexp(x, rate = 1.5), from=0, to=10, col='purple', add=TRUE)

#add legend
legend(7, .5, legend=c("rate=.5", "rate=1", "rate=1.5"),
       col=c("blue", "red", "purple"), lty=1, cex=1.2)

Plot of multiple exponential PDF functions in R

Plotting a Cumulative Distribution Function

The following code shows how to plot a CDF of an exponential distribution with rate parameter λ = 0.5:

curve(pexp(x, rate = .5), from=0, to=10, col='blue')

Exponential CDF plot in R

The following code shows how to plot multiple CDF’s of an exponential distribution with various rate parameters:

#plot CDF curves
curve(pexp(x, rate = .5), from=0, to=10, col='blue')
curve(pexp(x, rate = 1), from=0, to=10, col='red', add=TRUE)
curve(pexp(x, rate = 1.5), from=0, to=10, col='purple', add=TRUE)

#add legend
legend(7, .9, legend=c("rate=.5", "rate=1", "rate=1.5"),
       col=c("blue", "red", "purple"), lty=1, cex=1.2)

Multiple exponential distributions in one plot in R

The following tutorials explain how to plot other probability distributions in R:

Cite this article

stats writer (2025). How to Plot an Exponential Distribution in R?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-to-plot-an-exponential-distribution-in-r/

stats writer. "How to Plot an Exponential Distribution in R?." PSYCHOLOGICAL SCALES, 7 Dec. 2025, https://scales.arabpsychology.com/stats/how-to-plot-an-exponential-distribution-in-r/.

stats writer. "How to Plot an Exponential Distribution in R?." PSYCHOLOGICAL SCALES, 2025. https://scales.arabpsychology.com/stats/how-to-plot-an-exponential-distribution-in-r/.

stats writer (2025) 'How to Plot an Exponential Distribution in R?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-to-plot-an-exponential-distribution-in-r/.

[1] stats writer, "How to Plot an Exponential Distribution in R?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, December, 2025.

stats writer. How to Plot an Exponential Distribution in R?. PSYCHOLOGICAL SCALES. 2025;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top