Exponential Distribution in R Programming – dexp(), pexp(), qexp(), and rexp() Functions
The exponential distribution in R Language is the probability distribution of the time between events in a Poisson point process, i.e., a process in which events occur continuously and independently at a constant average rate. It is a particular case of the gamma distribution. In R Programming Language, there are 4 built-in functions to generate exponential distribution:
Function | Description |
dexp | Probability Density Function |
pexp | Cumulative Distribution Function |
qexp | Quantile Function of Exponential Distribution |
rexp | Generating random numbers which are Exponentially Distributed |
What is Exponential Distribution?
A random variable X is said to be exponentially distributed if it has a mean equal to 1 / λ and variance is equal to 1 / λ2 then that variable is known as Exponential Distribution.
dexp() Function
The dexp() function returns the corresponding values of the exponential density for an input vector of quantiles.
Syntax: dexp(x_dexp, rate)
Example:
R
# R program to illustrate # exponential distribution # Specify x-values x_dexp <- seq (1, 10, by = 0.1) # Apply dexp() function y_dexp <- dexp (x_dexp, rate = 5) # Plot dexp values plot (y_dexp) |
Output:

Exponential Distribution in R
pexp() Function
The pexp() function returns the corresponding values of the exponential cumulative distribution function for an input vector of quantiles.
Syntax: pexp(x_pexp, rate )
R
# R program to illustrate # exponential distribution # Specify x-values x_pexp <- seq (1, 10, by = 0.2) # Apply pexp() function y_pexp <- pexp (x_pexp, rate = 1) # Plot values plot (y_pexp) |
Output :

Cumulative Exponential Distribution Function
qexp() Function
The qexp() function gives the possibility, we can use the qexp function to return the corresponding values of the quantile function.
Syntax: qexp(x_qexp, rate)
R
# R program to illustrate # exponential distribution # Specify x-values x_qexp <- seq (0, 1, by = 0.2) # Apply qexp() function y_qexp <- qexp (x_qexp, rate = 1) # Plot values plot (y_qexp) |
Output:

Quantile Function of Exponential Distribution
rexp() Function
The rexp() function is used to simulate a set of random numbers drawn from the exponential distribution.
Syntax: rexp(N, rate )
R
# R program to illustrate # exponential distribution # Set seed for reproducibility set.seed (500) # Specify size N <- 100 # Draw exp distributed values y_rexp <- rexp (N, rate = 1) # Plot exp density hist (y_rexp, breaks = 50, main = "" ) |
Output:

Histogram of 100 Exponentially Distributed Numbers