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
0
votes
1 answer

Generating gamma random samples in python

can someone help me to generate random numbers from the gamma distribution in python, i have tried these two possibilities but i'm still wondering about the main difference between them : The first one is : shape, scale=…
Wejdene
  • 17
  • 1
  • 2
0
votes
1 answer

how do I plot this histogram in R

So looking at this question here "Let A = {0.1, 0.5, 1, 2, 5, 10, 100} L = {0.1, 0.5, 1, 2, 5, 10, 100} For each pair (α, λ) ∈ A × L above, use the built-in R function rgamma() to generate samples of size 10, 000 each from the Gamma(α, λ)…
0
votes
1 answer

Problems fitting a log pearson III with negative scale

I'd like to perform a log Pearson III fit to some data points I have in R. I followed this guidelines link. But i encounter a problem when my skewness (g) is negative (and of course the parameter "scale" is negative too, because the "sign(g)" in the…
0
votes
1 answer

Interpreting the Kolmogorov-Smirnov test results to test if our data follows a Gamma distribution

Getting the result from the KS test: from scipy import stats stats.kstest(myarray, 'gamma', (a, b)) we conclude that myarray does not follow a gamma distribution in case p<0.01 (when rejecting the null hypothesis)? In addition, when we calculate…
Geo
  • 1
  • 1
0
votes
1 answer

Function that will generate iter samples of size n from a gamma distribution with shape parameter alpha and rate parameter beta

The function needs to return the mean and standard deviation of each sample. This is what I have: sample_gamma <- function(alpha, beta, n, iter) { mean = alpha/beta var = alpha/(beta)^2 sd = sqrt(var) gamma = rgamma(n,shape = alpha, scale =…
0
votes
1 answer

Trying to iterate my function many times using i

I'm trying to iterate a for loop many times but it's only printing out once. sample_gamma <- function(alpha, beta, n, iter) { mean_s = c() mean_sd = c() for(i in 1:iter){ a = rgamma(n, shape = alpha, scale = 1/beta) return(c(mean(a),…
0
votes
0 answers

Why does my data not fit my Python function? (it does the fit in Mathematica perfectly)

I have a data set that I want to fit to a gamma distribution. I'm trying out the method that I found here: http://scipy-lectures.org/intro/scipy/auto_examples/plot_curve_fit.html but it does not seem to work with my data. I've tried other methods…
0
votes
1 answer

How to change the Function value to the one from the table (Gamma Distribution) in C++?

I have task to make a program using C++ to calculate a probability using a Gamma distribution. If i already found the Function value, how to change it to become the one from the Gamma Distribution table? I don't know the formulas. For example…
Satria Adi
  • 21
  • 1
  • 1
  • 3
0
votes
1 answer

How to take a more balanced sample data Python

I have a dataframe with nomalized percentage info. Eg. wordCount number Percent 2.0 1282 0.267345 1.0 888 0.185213 3.0 1124 0.170791 4.0 1250 0.152877 5.0 554 0.084864 6.0 333 0.058904 7.0 …
Jennifer
  • 19
  • 2
  • 6
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

How to find the first derivative of the Moment generating function (MGF) in R for Gamma distribution?

The moment generating function (MGF) for Gamma(2,1) for given t = 0.2 can be obtained using following r function. library(rmutil) gam_shape = 2 gam_scale = 1 t = 0.20 Mgf = function(x) exp(t * x) * dgamma(x, gam_shape, gam_scale) int =…
0
votes
0 answers

How can i find a suitable distribution that fits my data using fitdistrplus by identifying good starting values in R?

I have some data on prevalence of a given infection, provided for each country for 6 different age groups. I am trying to find a suitable distribution that may be suitable to model capture the prev using fitdistrplus. A histogram of the prevalence…
0
votes
0 answers

How to plot gamma distribution for a dataframe in python

I have a population dataframe. How to plot a gamma distribution diagram? I am using python and I can plot a diagram using seaborn or plot bar. But I need a gamma distribution diagram. I dont know how to fit my parameters into gamma functions. plot =…
Jennifer
  • 19
  • 2
  • 6
0
votes
0 answers

Why does Scipy's fit() function for gamma distribution producing a totally dissimilar distribution?

I'm trying to use scipy's fit function to fit a gamma distribution to observed data. The histogram for the observed data is below: The mean and variance are print("mean",np.mean(observed_data)) # mean…
Yu Chen
  • 6,540
  • 6
  • 51
  • 86
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…