0
$\begingroup$

To Clarify i am trying to generate a random variable from a gamma pdf

If $\Delta X$ indicates a random increment and it is said that $\Delta X$ follows a Gamma distribution.

What would that mean exactly? How would you be able to get random variables from the Gamma distribution?

So far I understood the following, but am guessing this might be wrong:

$$ X\sim \Gamma(\alpha,\beta)\equiv\operatorname{\Gamma}(\alpha,\beta)$$

This means $X$ follows a Gamma distribution so $\Delta X$ is a kind of sum of the different values $X$ takes at every iteration

$$g(x;\alpha, \beta) = \frac{\beta^\alpha x^{\alpha-1}e^{-x\beta}}{\Gamma(\alpha)}, \text{ for } x\geqslant 0\text{ and } \alpha,\beta>0 $$

so $X$ is represented by $x$ in the Gamma pdf, meaning I should put the value of $X$ for $x$ when computing the value of $X$ from the Gamma pdf?

https://en.wikipedia.org/wiki/Gamma_distribution

$\endgroup$
11
  • $\begingroup$ What do you call "computing the value of X from the Gamma pdf"? One does not "compute the value" of a random variable... $\endgroup$
    – Did
    Jul 24, 2015 at 15:04
  • $\begingroup$ @Did Sure you can! Given $\omega\in\Omega$, one can compute the value of e.g. $X(\omega)$ (granted this is only possible if the function $X:\Omega\to\mathbb R$ is defined explicitly instead of in terms of its distribution). $\endgroup$
    – Math1000
    Jul 24, 2015 at 15:52
  • $\begingroup$ @Math1000 Thanks for your comment. Is it related to the present page? $\endgroup$
    – Did
    Jul 24, 2015 at 15:53
  • $\begingroup$ I was being facetious re: "One does not "compute the value" of a random variable" :) $\endgroup$
    – Math1000
    Jul 24, 2015 at 15:57
  • 1
    $\begingroup$ @Math1000 No problem, I might be too slow... $\endgroup$
    – Did
    Jul 24, 2015 at 17:35

2 Answers 2

3
$\begingroup$

It sounds like you want to generate gamma-distributed random variables. If you want to write the code yourself, the way I know how is using the acceptance-rejection method by first generating an exponentially-distributed RV. An exponential random variable $G$ with pdf $\lambda \mathrm e^{-\lambda g}$ may be generated by first generating a uniform(0,1) random variable $U$ and applying the inverse transformation $$ G = -\frac{1}{\lambda}\log(1-U). $$ To generate a $gamma(\alpha,\beta)$-ditributed random variable, choose $\lambda = \frac{\alpha}{\beta}$ above and then use the acceptance-rejection method.

OTOH most scientific software includes these methods. E.g. MATLAB's gaminv(p,a,b) could be used where $p$ is a uniform(0,1), $a = \alpha$ and $b = \frac{1}{\beta}$ (MATLAB uses the "other" version of the pdf you've given). For example if you want to generate $1000$ gamma(2,3) random variables:

a=2;
b=1/3;
n=1000;
u=rand(n,1);
g=gaminv(u,a,b);
$\endgroup$
1
  • $\begingroup$ Perhaps see http://math.stackexchange.com/questions/1635250/ for more on acc-rej method. $\endgroup$
    – BruceET
    Feb 1, 2016 at 17:38
0
$\begingroup$

If $F$ is the pdf of the Gamma distribution with the correct parameters then for all real $x$, $$\Pr[\Delta X < x] = F(x).$$ This defines the distribution of $\Delta X$ completely.

$\endgroup$
2
  • $\begingroup$ Thank you for the answer but I dont know if i understood the answer, how do you define x ? ∆X should be random so should there be a random process for defining x, i am sorry if i dont get it, could you explain in more depth ? $\endgroup$
    – AnarKi
    Jul 24, 2015 at 14:55
  • $\begingroup$ I'm not defining $x$. The equation is true for all $x$. For example, the probability that $\Delta X$ is at most $10$ is $F(10)$. $\endgroup$ Jul 24, 2015 at 14:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .