The Wayback Machine - https://web.archive.org/web/20240623073006/https://www.geeksforgeeks.org/exponential-distribution-in-r-programming-dexp-pexp-qexp-and-rexp-functions/
Open In App

Exponential Distribution in R Programming – dexp(), pexp(), qexp(), and rexp() Functions

Last Updated : 11 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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.

[Tex]f\left(x \right ) = \lambda\; e^{-\lambda x}[/Tex]

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

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

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

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

Histogram of 100 Exponentially Distributed Numbers



Previous Article
Next Article

Similar Reads

Compute Beta Distribution in R Programming - dbeta(), pbeta(), qbeta(), and rbeta() Functions
Beta Distribution in R Language is defined as property which represents the possible values of probability. This article is an illustration of dbeta, pbeta, qbeta, and rbeta functions of Beta Distribution. dbeta() Function It is defined as Beta Density function and is used to create beta density value corresponding to the vector of quantiles. Synta
2 min read
Gamma Distribution in R Programming - dgamma(), pgamma(), qgamma(), and rgamma() Functions
The Gamma distribution in R Programming Language is defined as a two-parameter family of continuous probability distributions which is used in exponential distribution, Erlang distribution, and chi-squared distribution. This article is about the implementation of functions of the gamma distribution. dgamma() Function The dgamma() function is used t
2 min read
Calculate exponential of a number in R Programming - exp() Function
exp() function in R Language is used to calculate the power of e i.e. e^y or we can say exponential of y. The value of e is approximately equal to 2.71828….. Syntax: exp(y) Parameters: y: It is any valid R number either positive or negative. Returns: Floating point number by calculating e^y. Example 1: # R program to calculate exp value # Using exp
1 min read
Compute the Exponential minus 1 of a Number in R Programming - expm1() Function
expm1() function in R Language is used to compute exponential minus 1 i.e, exp()-1. Syntax: expm1(x) Parameters: a, b: number or number vector Example 1: # R program to illustrate # expm1 function # Calling the expm1() function expm1(4) # e5 -1 expm1(10) expm1(15) Output: [1] 53.59815 [1] 22025.47 [1] 3269016 Example 2: # R program to illustrate #
1 min read
Exponential Smoothing in R Programming
The Exponential Smoothing is a technique for smoothing data of time series using an exponential window function. It is a rule of the thumb method. Unlike simple moving average, over time the exponential functions assign exponentially decreasing weights. Here the greater weights are placed on the recent values or observations while the lesser weight
15+ min read
How to Calculate an Exponential Moving Average in R?
In this article, we will look the how to Calculate an Exponential Moving Average in R Programming Language. Exponential moving average (EMA) tells us the weighted mean of the previous K data points. EMA places a greater weight and significance on the most recent data points. To get the EMA we will use pracma package in the R programming language. T
2 min read
Compute Density of the Distribution Function in R Programming - dunif() Function
dunif() function in R Language is used to provide the density of the distribution function. Syntax: dunif(x, min = 0, max = 1, log = FALSE) Parameters: x: represents vector min, max: represents lower and upper limits of the distribution log: represents logical value for probabilities Example 1: # Create vector of random deviation u &lt;- runif(20)
1 min read
Binomial Distribution in R Programming
Binomial distribution in R is a probability distribution used in statistics. The binomial distribution is a discrete distribution and has only two outcomes i.e. success or failure. All its trials are independent, the probability of success remains the same and the previous outcome does not affect the next outcome. The outcomes from different trials
3 min read
Create a Random Sequence of Numbers within t-Distribution in R Programming - rt() Function
rt() function in R Language is used to create a random sequence of values from Student t-distribution. Syntax: rt(n, df, ncp) Parameters: n: Number of observations df: Degree of Freedom ncp: Numeric vector of non-centrality parameters. Example 1: # R Program to create random sequence # from t distribution # Calling rt() Function rt(15, 2) rt(15, 1)
1 min read
Perform Probability Density Analysis on t-Distribution in R Programming - dt() Function
dt() function in R Language is used to return the probability density analysis on the Student t-distribution with random variable x and degree of freedom df. Syntax: dt(x, df) Parameters: x: Random Variable df: Degree of Freedom Example 1: # R Program to perform # Probability Density Analysis # Calling dt() Function dt(0, 10) dt(1, 15) dt(3, 40) Ou
1 min read
Article Tags :
three90RightbarBannerImg