## Maths in a minute: The gamma distribution

Suppose that during a given time period an event happens on average 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 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 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 you have to wait at most minutes to see events is given by

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

So for the probability you have to wait at most a minute to see posts is

rounded to 3 decimal places. The plot below shows the distribution for , and . The dashed lines correspond to our example of and .

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

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

The plot below shows the density function for the gamma distribution for and and The purple curve corresponds to the example 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 *a*=3 and *k*=1, *k*=2, and *k*=3.

The *mean* of the exponential distribution, also known as the *expectation* is 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 post, the average of wait times would be a minutes.

The *variance * of the exponential distribution, which measures how the individual probabilities are spread around the mean is