The Gamma distribution in R 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 the implementation of functions of gamma distribution.
dgamma() Function
dgamma() function is used to create gamma density plot which is basically used due to exponential and normal distributions factors.
Syntax:
dgamma(x_dgamma, shape)Parameters:
x_dgamma: defines gamma function
shape: gamma density of input valuesReturns: Plot dgamma values
Example :
# R program to plot gamma distribution # Specify x-values for gamma function x_dgamma <- seq(0, 2, by = 0.04) # Apply dgamma function y_dgamma <- dgamma(x_dgamma, shape = 6) # Plot dgamma values plot(y_dgamma) |
Output :

pgamma() Function
pgamma() function is used in cumulative distribution function (CDF) of the gamma distribution.
Syntax:
pgamma(x_pgamma, shape)Parameters:
x_pgamma: defines gamma function
shape: gamma density of input valuesReturns: Plot pgamma values
Example:
# R program to plot gamma distribution # Specify x-values for gamma function x_pgamma <- seq(0, 2, by = 0.04) # Apply pgamma function y_pgamma <- pgamma(x_pgamma, shape = 6) # Plot pgamma values plot(y_pgamma) |
Output:

qgamma() Function
It is known as gamma quantile function of the gamma distribution and used to plot qgamma distribution.
Syntax:
qgamma(x_qgamma, shape)Parameters:
x_qgamma: defines gamma function
shape: gamma density of input valuesReturns: Plot qgamma values with gamma density
Example :
# R program to plot gamma distribution # Specify x-values for gamma function x_qgamma <- seq(0, 1, by = 0.03) # Apply qgamma function y_qgamma <- qgamma(x_qgamma, shape = 6) # Plot qgamma values plot(y_qgamma) |
Output:

rgamma() Function
This function is basically used for generating random number in gamma distribution.
Syntax:
rgamma(N, shape)Parameters:
N: gamma distributed values
shape: gamma density of input valuesReturns: Plot rgamma values with gamma density
Example :
# R program to plot gamma distribution # Set seed for reproducibility set.seed(1200) # Specify sample size N <- 800 # Draw N gamma distributed values y_rgamma <- rgamma(N, shape = 5) # Print values to RStudio console y_rgamma # Plot of randomly drawn gamma density hist(y_rgamma, breaks = 500, main = "") |
Output:

Recommended Posts:
- Compute the gamma value of a Non-negative Numeric Vector in R Programming - gamma() Function
- Compute the Natural Logarithm of the Absolute Value of Gamma Function in R Programming - lgamma() Function
- Compute the Logarithmic Derivative of the gamma Function in R Programming - digamma() Function
- Compute the Second Derivative of the Logarithmic value of the gamma Function in R Programming - trigamma() Function
- Compute Beta Distribution in R Programming - dbeta(), pbeta(), qbeta(), and rbeta() Functions
- Exponential Distribution in R Programming - dexp(), pexp(), qexp(), and rexp() Functions
- Compute Density of the Distribution Function in R Programming - dunif() Function
- Binomial Distribution in R Programming
- Create a Random Sequence of Numbers within t-Distribution in R Programming - rt() Function
- Perform Probability Density Analysis on t-Distribution in R Programming - dt() Function
- Perform the Probability Cumulative Density Analysis on t-Distribution in R Programming - pt() Function
- Perform the Inverse Probability Cumulative Density Analysis on t-Distribution in R Programming - qt() Function
- Create Random Deviates of Uniform Distribution in R Programming - runif() Function
- Compute the Value of Empirical Cumulative Distribution Function in R Programming - ecdf() Function
- Compute the value of F Cumulative Distribution Function in R Programming - pf() Function
- Compute the value of Quantile Function over F Distribution in R Programming - qf() Function
- Compute the Value of Quantile Function over Weibull Distribution in R Programming - qweibull() Function
- Compute the value of CDF over Studentized Range Distribution in R Programming - ptukey() Function
- Compute the value of Quantile Function over Studentized Distribution in R Programming - qtukey() Function
- Compute the value of PDF over Wilcoxon Signedrank Distribution in R Programming - dsignrank() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

