← Statistics

Probability

Random Variables & Probability Distributions

Data is full of uncertainty: how many customers will click a campaign email, or how long they will stay on the page afterwards. A random variable gives that uncertainty a number, and a probability distribution describes how likely each value is. This post builds the idea step by step, from random variables to PMF, PDF and CDF, with one running example: a marketing email campaign. It builds on Probability Basics and Conditional Probability & Independence. All numbers are illustrative.

Random variables

A random experiment is a process whose result we cannot predict with certainty, although we know which results are possible. Each possible result is an outcome. A random variable is a rule that turns each outcome into a number, so that we can calculate with it. By convention, a capital X is the variable itself, and a lowercase x is one specific value it can take.

A random experiment, sending an email campaign and watching the first hour, gives an outcome of 3 customers clicking, which the random variable X turns into X = 3
Chart 1 From experiment to outcome to a number.

Imagine you send an email campaign and watch the first hour. One possible outcome is "3 customers click the link". The random variable X = number of clicks in the first hour turns this outcome into X = 3. Before you send the email, you do not know what X will be, but you can know which values are possible (0, 1, 2 and so on) and how likely each one is. That description is exactly what a distribution gives you.

Random does not mean patternless

The value of a random variable is uncertain in any single run, but the pattern of how likely the values are can be studied. That pattern is what analysts work with.

Discrete vs continuous

The first question to ask about any random variable is whether you count it or measure it.

Discrete

A count

Separate values that you can list, with gaps in between. It is usually a whole number.

Example: clicks in the first hour

Continuous

A measurement

Any value in a range, limited only by how precisely you can measure.

Example: time on the landing page

Discrete variables take separate values such as 0, 1, 2, while continuous variables can take any value in a range such as 3.27 minutes
Chart 2 Discrete values have gaps between them, continuous values do not.

Some examples from data analytics:

VariableTypeWhy
Orders per dayDiscreteYou count them
Clicks on a campaign emailDiscreteYou count them
Support tickets per weekDiscreteYou count them
Time on the landing pageContinuousYou measure it
Delivery timeContinuousYou measure it
Order valueContinuous (in practice)Money is counted in cents, but with so many possible values it is treated as continuous

Three ways to describe a distribution

Knowing that X is the number of clicks does not yet tell us how likely each value is. Are 0 clicks common? Is 10 clicks realistic? To answer that, we need to describe how probability is spread across the possible values. This description is the probability distribution, and we write it down with three functions:

Why do we need them? Because business questions are really probability questions: How likely is it that the campaign gets at least 4 clicks in the first hour? What share of visitors stay longer than 4 minutes? Each function is the right tool for a different kind of question, and which one you use depends on the type of variable and on what you want to know. The next sections go through them one by one.

PMF: probability mass function

For a discrete variable, the probability mass function (PMF) gives the probability of each exact value:

P(X = x)

It is read as "the probability that X equals x". Two rules always hold: every probability is between 0 and 1, and all probabilities add up to 1.

Say that, for your campaign, the number of clicks in the first hour has this PMF:

Clicks (x)012345
P(X = x)0.100.250.300.200.100.05
Bar chart of the PMF: probabilities 0.10, 0.25, 0.30, 0.20, 0.10 and 0.05 for 0 to 5 clicks, with the bar for 3 clicks highlighted
Chart 3 Each bar is the probability of exactly that value.

How to read it: find the value on the horizontal axis and read the height of its bar. P(X = 3) = 0.20, so in about 20% of hours you would expect exactly 3 clicks. The tallest bar, 2 clicks at 0.30, is the most likely value. To get the probability of several values, add their bars: P(X ≥ 4) = 0.10 + 0.05 = 0.15.

PDF: probability density function

A continuous variable works differently. Time on the page could be 3 minutes, 3.1 minutes, 3.14159 minutes, and so on, with infinitely many possible values. If each exact value had a positive probability, the total would be far above 1. So for a continuous variable, the probability of one exact value is zero: P(X = exactly 3.000) = 0. Instead, we ask about ranges.

The probability density function (PDF) describes this. Two ideas are important:

Suppose time on the page is roughly bell-shaped, centred around 3 minutes with a spread of about 1 minute. The probability that a visitor stays between 2 and 4 minutes is the shaded area:

Bell curve of time on the landing page in minutes, with the area between 2 and 4 minutes shaded, which is about 68 percent
Chart 4 The shaded area is the probability of a value between 2 and 4.

How to interpret it: where the curve is high, values are concentrated, and where it is low, they are rare. A wide, flat curve means more spread. To answer a question, choose a range and look at the area above it, never at the height at a single point.

CDF: cumulative distribution function

The cumulative distribution function (CDF) answers a different question: how likely is it that X is at most a certain value?

F(x) = P(X ≤ x)

It accumulates probability, starting from the left and adding up as x grows. This works for both types of variable:

How to read a CDF: pick a value on the horizontal axis and read the height of the curve. It always starts at 0, ends at 1 and never goes down. Steep parts are where a lot of probability sits, and flat parts are where few values occur. To get the probability of a range, subtract: P(2 < X ≤ 4) = F(4) − F(2) ≈ 0.84 − 0.16 = 0.68, which matches the shaded area from before.

Two stacked charts: the PDF with the area up to 4 minutes shaded at about 84 percent, and the CDF showing the same value as a height of 0.84 at 4 minutes
Chart 5 The CDF is the PDF accumulated: the area on top becomes the height below.

This is the relationship between PDF and CDF: the CDF is the accumulated area under the PDF, and the PDF is the slope of the CDF. For a discrete variable, the CDF is a staircase built from the PMF bars.

PMF vs PDF vs CDF

Here is how everything fits together:

A random variable is either discrete or continuous; discrete variables use a PMF and continuous variables use a PDF, and both lead to the CDF
Chart 6 The big picture: which function belongs to which type of variable.
FunctionUsed forAnswersProbability comes from
PMFDiscreteHow likely is exactly this value?The height of the bar, P(X = x)
PDFContinuousHow much probability is around this range?The area under the curve
CDFBothHow likely is this value or less?The height of the curve, P(X ≤ x)
Three panels: the PMF answers how likely exactly 3 clicks are, the PDF answers how much probability is in a range, and the CDF answers how likely 3 clicks or fewer are
Chart 7 Each function answers a different question.

How to think about a distribution

Instead of memorising a catalogue of distributions, ask five questions about any variable:

  1. What is the random variable? What exactly are we measuring? Example: time on the landing page, in minutes.
  2. Is it discrete or continuous? Count or measurement? Here it is a measurement, so continuous.
  3. How is probability distributed? Where are the values concentrated, how spread out are they, and is the distribution skewed? Most visitors may stay 2 to 4 minutes, while a few stay much longer, which would skew the real data to the right.
  4. What probability question am I asking? Exactly this value: PMF. Within a range: PDF, the area. Below a threshold: CDF.
  5. What does the probability tell me? Translate the result into something meaningful: "84% of visitors stay 4 minutes or less" can tell you whether the page content is too long or too short.

From data to distribution

A good way to remember all this is the analytical workflow. In real work you start at the top, with something you observe, not with a formula:

Workflow from a real-world phenomenon to a random variable, discrete or continuous, a distribution, PMF PDF or CDF, a probability and an interpretation, shown with the email campaign example
Chart 8 The workflow, with the email campaign as the example.

The distribution is the bridge between raw data and a statement that a stakeholder can act on.

In one sentence

A distribution is a way of describing uncertainty in a variable, not just a mathematical curve.

Key takeaway

A random variable turns the outcome of an experiment into a number. Discrete variables, which are counts, use a PMF, where probability is the height of a bar. Continuous variables, which are measurements, use a PDF, where probability is an area. The CDF accumulates probability up to a value for both. Always finish by translating the probability back into a plain statement about the business.