# Definition of Gamma distribution

**URL:** <https://uqworld.org/t/definition-of-gamma-distribution/736>\
**Category:** Community Q&A and How To\
**Tags:** input\
**Created:** [July 9, 2020, 7:26am UTC](https://uqworld.org/t/definition-of-gamma-distribution/736 "2020-07-09T07:26:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsanderse](https://uqworld.org/user_avatar/uqworld.org/bsanderse/32/690_2.png) [@bsanderse](https://uqworld.org/u/bsanderse)\
**Post date:** [July 9, 2020, 7:26am UTC](https://uqworld.org/t/definition-of-gamma-distribution/736/1 "2020-07-09T07:26:10Z")

</div>

Hi all,

I’m using a Gamma distribution as pdf for one of my random variables.  
The definition for the Gamma distribution is often based on either Gamma(shape,scale) (the Matlab definition used in gampdf()) or Gamma(shape,rate). If I understand the UQLab manual well, UQLab is using Gamma(rate,shape) as definition. It took me quite some time before realizing this. I guess it would be good to make this more explicit in the user manual.

Here’s a MWE to highlight the confusion:

> uqlab;  
> InputOpts.Marginals(1).Name = ‘test’;  
> InputOpts.Marginals(1).Type = ‘Gamma’;  
> InputOpts.Marginals(1).Parameters = [1/0.4 2];
> 
> myInput = uq\_createInput(InputOpts);  
> uq\_display(myInput);
> 
> % compare with Matlab Gamma function  
> figure  
> x = linspace(0,10,100);  
> plot(x,gampdf(x,2,0.4))

So in summary, the message is that in UQLab one needs to reverse the arguments in the Gamma function (and use 1/0.4 instead of 0.4 because the rate is used instead of the scale). This seems a bit odd to me, but maybe there is a good reason for this?

Best,

Benjamin

---

<div class="post-metadata">

**Author:** ![xujia](https://uqworld.org/user_avatar/uqworld.org/xujia/32/214_2.png) [@xujia](https://uqworld.org/u/xujia)\
**Post date:** [July 9, 2020, 11:43am UTC](https://uqworld.org/t/definition-of-gamma-distribution/736/2 "2020-07-09T11:43:00Z")

</div>

Dear @bsanderse,

Thanks for the post. You are right, UQLab uses a different parameterization from the one in Matlab. I think both are reasonable because they correspond to the [two ways](https://en.wikipedia.org/wiki/Gamma_distribution) of defining a Gamma distribution.

I hope it helps.

---

<div class="post-metadata">

**Author:** ![bsanderse](https://uqworld.org/user_avatar/uqworld.org/bsanderse/32/690_2.png) [@bsanderse](https://uqworld.org/u/bsanderse)\
**Post date:** [July 9, 2020, 12:12pm UTC](https://uqworld.org/t/definition-of-gamma-distribution/736/3 "2020-07-09T12:12:41Z")

</div>

Dear Xujia,

Thanks for the quick reply.  
My point is not so much about the scale vs. rate parameter (I understand that this is a matter of choice/preference), but that **the order** of the arguments is reversed in UQLab - this is not only inconsistent with Matlab but also inconsistent with the Wikipedia page you are pointing to.

Best,

Benjamin
