Questions tagged [gamma-function]

Anything related to the mathematical gamma function, also known as generalized factorial function.

Anything related to the mathematical gamma function, also known as generalized factorial function.

See Wikipedia page on gamma function.

72 questions
0
votes
1 answer

Is there a way to see Scipy.Special.Gamma() function implementation in the source?

I've tried to write functions to calculate special functions (e.g. exponential, gamma, erf, etc), but to do the sum or product operations, I used while-loop with 10k turns. This is very time-consuming. Then, I realized that scipy.special.gamma()…
Eren Irmak
  • 17
  • 6
0
votes
1 answer

Multiple precision Gamma function in R

I need to compute a sum in R that involves the gamma function for each element. When the arguments of the gamma increase I get NaN as a result, and I suspect that the problem is numerical with the evaluation of the gamma. I already read the…
MCMP
  • 3
  • 2
0
votes
1 answer

Fit gamma distribution parameters to expectation and probabilty

My problem is the following. I measured a bunch of different physical properties and propagated the methodic and measurement uncertainties all the way to some kind of efficiency ratio. For all my physical properties, a normal distribution seemed to…
SvA
  • 3
  • 2
0
votes
2 answers

Entropy of t-distribution in scipy: How to input degrees of freedom to digamma and beta functions?

The closed-form analytical solution for the entropy of a variable X that follows the t-distribution, derived here, is Seeing that python has functions scipy.special.digamma and scipy.special.beta, how can the above formula be implemented in…
develarist
  • 1,224
  • 1
  • 13
  • 34
0
votes
1 answer

Bachelier Normal Implied Vol Python Calculation (Help) Jekel

Writing a python script to calc Implied Normal Vol ; in line with Jekel article (Industry Standard). https://jaeckel.000webhostapp.com/ImpliedNormalVolatility.pdf They say they are using a Generalized Incomplete Gamma Function Inverse. For a…
0
votes
1 answer

Summing Gamma functions for a non-central chi square distribution leads to 'mpf' object cannot be interpreted as an integer in python

In order to sample a non-central chi-square distribution to price a European call option, it seems most optimal to use mp.sum; however, the program I have put together gives the TypeError: 'mpf' object cannot be interpreted as an integer when run. I…
0
votes
0 answers

Gamma function with complex input in Tensorflow

I am trying to compute the gamma function in Tensorflow. The argument in the function is a sum of a float that comes from the tensor and an imaginary part. Normally, I could just exponentiate the tf.math.lgamma function, however, it does not accept…
marco11
  • 235
  • 2
  • 8
0
votes
1 answer

Is there a function calculating derivative of digamma function?

I want to calculate the derivative of digamma function in R. R has an existing function called digamma, but I cannot find a function for the derivative of digamma function. Is it possible to write code for differentiated digamma function in…
Dianafreedom
  • 391
  • 1
  • 13
0
votes
0 answers

Incomplete Gamma function for negative values

I was deriving an expression for truncated gamma distribution. I derived an expression for the same which include incomplete gamma function. When I was implementing the same in matlab using the 'gammainc(x,alpha)' function, I was getting complex…
0
votes
1 answer

rcpp: how to apply gamma function to a scalar?

I guess the function gamma only works for a vector as the input. Is there a way to apply it to a scalar, say,gamma(3)`? Actually, I would get the correct output if I include gamma(3) as part of my code, but there's a warning message.... #include…
0
votes
2 answers

Time complexicity of recursive function

I have a recursive function f(n) with time complexicity O(f(n)) = O(combination(n, n/2) * f(n/2)^2) where combination(a, b) means combination nuber a above b. I tried to simplify it, but don't have enough mathematical skills. The only thing that I…
0
votes
2 answers

Incomplete gamma function algorithm

There is a very concise algorithm for computing lower incomplete gamma function: https://people.sc.fsu.edu/~jburkardt/f_src/asa147/asa147.html We coded this in C++. There is one thing I don't understand in this algorithm. In one place to compute the…
rk85
  • 57
  • 2
  • 6
0
votes
0 answers

How do I speed up digamma calculation in big sparse matrices?

I have two large numpy matrices, X and r (appr. 5500x3500). I need to calculate digamma(X+r) and digamma(r), which I do with scipy.special.psi. The calculation happens in the gradient function that I am using for a fit by gradient descent. During…
galicae
  • 101
  • 1
0
votes
1 answer

Rcpp gamma integral

I am trying to rewrite into (R)cpp an original R function that makes use of the gamma function (from double input). Below the original source. When comping with sourceCpp the following error is raised "no matching function for call to…
Giorgio Spedicato
  • 2,413
  • 3
  • 31
  • 45
0
votes
3 answers

How to efficiently cache and apply scipy gammaln to a numpy array?

I am looking for a way to cache the results of the gammaln function, apply it to a numpy array and then sum the results. Currently I am able to cache the gammln results using a simple dictionary approach, but it seems that I cannot iterate the array…
pjdrm
  • 25
  • 5