Probability theory: Geometric distribution

This is part of the course “Probability Theory and Statistics for Programmers”.

Probability Theory For Programmers

This is the first part of a series of articles about different types of distributions. There is a lot of different distributions out there, but we will cover the most popular ones, those more often used to be approximate versions of real data.

The geometric distribution is the distribution of the number of trials needed to get the first success in repeated Bernoulli trials. Repeated Bernoulli trials mean that all trials are independent and each result have two possible outcomes. Random variable X represents the number of trials needed to get the first success. In order to the first success occur on the xth trial the first x-1 trials must be failures and the xth trial must be a success. The value x can be any integer from 0, it doesn’t have an upper bound.

probability of getting the first success in the x-th trial

Let’s take a look at the example. Imagine that we have the event with probability to occur equal to 0.2. What is the probability that this event occurs on the third attempt?

As you can see from the bar chart the minimum value of the attempt is 1 and there is no maximum value.

Let’s take a look at the characteristics of the geometric distribution. The mean and the variance:

the mean and the variance

There is also some interesting properties of the geometric distribution. Let’s find the probability that event occurs before the fourth attempt:

Next part ->

Reach the next level of focus and productivity with





Indie hacker behind More at

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Make Money Online Answering Math Questions

Complexity Analysis — an overview

Complexity anlasis for choosing the optimal solution

Probability theory: Chi-Squared distribution

Statistics: Empirical distribution function

Probability theory: Poisson distribution

Statistics: Maximum likelihood estimation

Probability theory: Random variable, Distribution of the discrete random variable

Probability theory: Expected value, Mode, Median

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Radzion Chachura

Radzion Chachura

Indie hacker behind More at

More from Medium

Hidden Markov Models with Python

Understanding Linear Regression

Implementing Gradient Descent For Univariate Linear Regression Using Python and NumPy

Monte Carlo Simulation for Engineering Transfer Functions