Questions tagged [gamma-distribution]

Anything related to the gamma probability distribution, i.e. a continuous probability distribution whose probability density function is connected to the "gamma function". DO NOT USE this tag for questions about the gamma function, use the [gamma-function] tag instead.

Anything related to the gamma probability distribution, i.e. a continuous probability distribution whose probability density function is connected to the gamma function.

If a variable X follows a gamma distribution with shape parameter k>0 and scale parameter θ, then it has probability density function:

enter image description here

It follows that E(X)=kθ and Var(X)=kθ². In some texts, the gamma distribution is parameterized instead by the rate parameter, which is the reciprocal of the scale parameter: β=1/θ.

DO NOT USE this tag for questions about the gamma function, use the tag instead.

See Wikipedia page on the gamma distribution.


Tag Usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

219 questions
1
vote
0 answers

fit gamma distribution in python with probability data

I have two data: x_data = [ 0.0, 50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 750.0, 800.0, 850.0, 900.0, 950.0, 1000.0, 1100.0, 1200.0, 1500.0, 2000.0] y_data =…
Wenjing Li
  • 105
  • 6
1
vote
1 answer

How can I obtain a probability at specific x value in a gamma probability density function in Python scipy?

I can obtain the probability for x in a gamma distribution via the following in python import numpy as np from scipy.stats import gamma # Gamma distribution print(gamma.pdf(x=2, a=2, scale=1, loc=0)) # 0.27067 However, this requires creating a…
KubiK888
  • 4,377
  • 14
  • 61
  • 115
1
vote
2 answers

better way to create a function that returns a gamma distribution?

So I have created a function that generates a data frame for gamma distribution. Currently, I have. sample_gamma <- function(alpha,beta,n,iter) { gamma.df <- as.data.frame(matrix(nrow = iter, ncol = 3)) colnames(gamma.df) <-…
1
vote
0 answers

Compound Poisson Keras custom loss function

I am trying to implement a custom loss function using Tensorflow as the negative loglikelihood of this expression (which is a compound Poisson-Gamma): The first term (represented by the Dirac delta) refers to the case when z == 0, while the sum…
Alberto
  • 467
  • 3
  • 16
1
vote
1 answer

How to generate Gamma random variables with known correlation coefficients

If I know the correlation coefficient between any two Gamma random variables Xi and Xj as rho_ij, I am wondering how I can generate the set of N Gamma distributed random numbers of X1...XN using MATLAB. For example, my correlation coefficient…
Frey
  • 315
  • 4
  • 11
1
vote
1 answer

Calculate KL Divergence between two gamma distribution list

I have two list. Both include normalized percent: actual_population_distribution = [0.2,0.3,0.3,0.2] sample_population_distribution = [0.1,0.4,0.2,0.3] I wish to fit these two list in to gamma distribution and then calculate the returned two list…
Jennifer
  • 19
  • 2
  • 6
1
vote
0 answers

How do I use the pgamma() function in R to compute the CDF of a gamma distribution?

I want to compute the cumulative distribution function in R for data that follows a gamma distribution. I understood how to do this with a lognormal distribution using the equation from Wikipedia; however, the gamma equation seems more complicated…
1
vote
0 answers

NetLogo: Find detailed information on "random-gamma" calculation error and its range in NetLogo

I want to look for detailed information such as random-gamma calculation error and its range. But at the moment I have not found yet. If anyone knows it and the risk with somewhat range caused by the random-gamma syntax in NetLogo, please let me…
goodgest
  • 418
  • 3
  • 10
1
vote
1 answer

Why code in r about generation of Gamma random variables does not return the expected output?

I have the following algorithm Generate U~(0,1) X=-beta*ln(u_1*u_2*...*u_alpha) repeat step 1 an step 2 N times I think in r is as follows Gam<-function(alpha,beta){ N<-1000 u<-runif(alpha) x<-rep(0,alpha) X<-rep(0,N) for(j in 1:N){ for(i in…
user9802913
  • 245
  • 4
  • 20
1
vote
1 answer

Fitting parameter b of the Gamma distribution from mean, 95% in Python

This Mathematica function finds parameter b of the Gamma distribution, given mean and 95% values and scaled by the mean [Mu]; The two values bracket [Beta] makes it fast and there is a restriction for max pg95= 5.8[Mu]* gb[[Mu], p95]. I need to…
1
vote
0 answers

Back-transforming gamma GLM to natural units to be able to predict values in unsampled locations

I'm working with ecological data, where I have used cameras to sample animal detections (converted to biomass) and run various models to identify the best fitting model, chosen through looking at diagnostic plots, AIC and parameter effect size. The…
1
vote
1 answer

'rethinking' package - making scale log-normal for gamma distribution

I am creating a model to predict the age of trees from their height using the rethinking package. In my data set, age is gamma distributed. To accommodate the gamma likelihood, I made this model using map(): fit2<- map( alist( age ~…
1
vote
1 answer

Python: Numpy Gamma Function Produces Wrong Mean Value For Scale Parameter

I'm trying to draw 1000 samples ( each of size 227 ) from numpy.random's gamma method, so each sample value should be i.i.d ( independent and identically distributed ). However, the mean value for the scale parameter is wrong. My shape parameter (…
E. Kaufman
  • 129
  • 2
  • 11
1
vote
1 answer

Calculating working residuals of a Gamma GLM model

I am trying to calculate the working residuals of a Gamma GLM model. I'm doing this manually because I want to calculate the partial residuals step-by-step. My model and its coefficients and predictions are described…
1
vote
2 answers

Why abline won't show line from glm with Gamma family?

I have the following data, which I'm trying to model via GLM, using Gamma function. It works, except that abline won't show any line. What am I doing wrong? y <-…
Rodrigo
  • 4,706
  • 6
  • 51
  • 94