Open In App

Compute the Logarithmic Derivative of the gamma Function in R Programming – digamma() Function

Last Updated : 12 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

digamma() function in R Language is used to calculate the logarithmic derivative of the gamma value calculated using the gamma function.
digamma Function is basically,

digamma(x) = d(ln(factorial(n-1)))/dx

Syntax: digamma(x)

Parameters:
x: Numeric vector

Example 1:




# R program to find logarithmic derivative 
# of the gamma value
  
# Calling the digamma() Function
digamma(2)
digamma(4)
digamma(5.2)


Output:

[1] 0.4227843
[1] 1.256118
[1] 1.549434

Example 2:




# R program to find logarithmic derivative 
# of the gamma value
  
# Creating a vector
x <- c(2.3, 3, 1.2)
  
# Calling the digamma() Function
digamma(x)
  
# Calling digamma() function
# on negative values
digamma(-2.3)
digamma(-2)


Output:

[1]  0.6000399  0.9227843 -0.2890399
[1] 3.317323
[1] NaN
Warning message:
In digamma(-2) : NaNs produced

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads