Add new comment

Maths in a minute: The gamma distribution

Suppose that during a given time period an event happens on average $a$ times. For example, you might know that on average you'll see three new posts on your social media feed per minute. This doesn't mean that the event will occur at regular intervals: seeing three posts a minute on average doesn't mean you'll see one exactly every twenty seconds (which is a third of a minute).

One question you might ask yourself is, "when I switch on my feed, what's the chance I have to wait no more than $t$ minutes until I see the first new post?" As we explain in this article, the answer is given by the exponential distribution.

Here we go one step further and ask, "what's the chance I have to wait no more than $t$ minutes until I have seen two new posts, or three new posts, or any number of new posts?"

In this case the answer is given by a probability distribution called the gamma distribution. The probability $F(t,k)$ you have to wait at most $t$ minutes to see $k$ events is given by

  \[ F(t,k) =1-\left(\frac{(at)^0e^{-at}}{0!}+\frac{(at)^1e^{-at}}{1!}+\frac{(at)^2e^{-at}}{2!}+...+\frac{(at)^{k-1}e^{-at}}{(k-1)!}\right). \]    

Here $k$ could be any positive integer and $t$ any amount of time measured in minutes.

So for $a=3$ the probability you have to wait at most a minute to see $k=3$ posts is

  \[ F(1,3) = 1-\left(\frac{(3)^0e^{-3}}{0!}+\frac{(3)^1e^{-3}}{1!}+\frac{(3)^2e^{-3}}{2!}\right)=0.577, \]    

rounded to 3 decimal places. The plot below shows the distribution for $k=1,$ $k=2$, and $k=3$. The dashed lines correspond to our example of $t=1$ and $k=3$.

The cumulative function for the gamma distribution with <em>a</em>=3 and <em>k</em>=1, <em>k</em>=2, and <em>k</em>=3

The cumulative function for the gamma distribution with a=3 and k=1, k=2, and k=3.

Time is of course a continuous quantity, that is, it doesn't vary in discrete steps but instead flows along. As we explained in our brief introduction to probability distributions, when a continuous random variable is involved, a probability distribution comes with a probability density function. The density function in this case is

  \[ f(t,k)=\frac{a^ k t^{k-1}e^{-at}}{(k-1)\times (k-2) \times ... \times 2 \times 1)}, \]    

where $t$ is a positive real number and $k$ a positive integer. The function $F(t,k)$ above is the corresponding cumulative function. (To be absolutely precise, because we are assuming $k$ is an integer, this is actually a special case of the gamma distribution, called the Erlang distribution. For a general gamma distribution $k$ can be a continuous quantity.)

The plot below shows the density function for the gamma distribution for $a=3$ and $k=1,$ $k=2,$ and $k=3.$ The purple curve corresponds to the example $a=3$ and the shaded area gives the probability that you have to wait no more than one minute to see three posts.

The density function for the gamma distribution with <em>a</em>=3 and <em>k</em>=1, <em>k</em>=2, and <em>k</em>=3

The density function for the gamma distribution with a=3 and k=1, k=2, and k=3.

The mean of the exponential distribution, also known as the expectation is $k/a.$ Loosely speaking, this means that if we switched our feed on lots and lots of time and each time counted how long we waited to see the first $k$ post, the average of wait times would be a $k/a$ minutes.

The variance of the exponential distribution, which measures how the individual probabilities are spread around the mean is $k/a^2.$

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Want facts and want them fast? Our Maths in a minute series explores key mathematical concepts in just a few words.