Probability Density/Mass Functions (PDF/PMF)

When analyzing data, we often need to quantify the likelihood of different outcomes. For example, what is the chance a customer makes 3 purchases in a month, or that a sensor reading falls between 20 and 25 degrees Celsius? The tools for answering these questions depend on whether the variable is discrete (countable outcomes) or continuous (outcomes within a range). Probability Mass Functions (PMFs) and Probability Density Functions (PDFs) provide the mathematical framework for this quantification.

Probability Mass Function (PMF) for Discrete Variables

A Probability Mass Function (PMF) describes the probability that a discrete random variable takes on a specific value. For any given outcome xx, the PMF, denoted as P(X=x)P(X=x) or fX(x)f_X(x), directly gives the probability of observing that outcome. This means fX(x)f_X(x) must be between 0 and 1, inclusive, for all possible values of xx. The sum of all probabilities for all possible outcomes must equal 1, representing the certainty that one of the possible outcomes will occur.

📐 PMF Properties

For a discrete random variable XX with possible values x1,x2,…,xnx_1, x_2, \dots, x_n:

  1. 0≤fX(xi)≤10 \leq f_X(x_i) \leq 1 for all ii
  2. ∑i=1nfX(xi)=1\sum_{i=1}^{n} f_X(x_i) = 1

pythonCalculating PMF for Coin Flips
PMF for Number of Heads in 3 Coin Flips
This bar chart visualizes the Probability Mass Function for the number of heads observed in three independent coin flips. The x-axis represents the discrete number of heads (0, 1, 2, or 3), and the y-axis shows the probability of observing that specific number of heads. Notice the symmetric distribution, with 1 and 2 heads being the most probable outcomes.
Loading chart...
Key Insight: The height of each bar directly represents the probability of that specific discrete outcome.
Check Your Understanding
If a PMF for a variable XX has P(X=1)=0.4P(X=1)=0.4 and P(X=2)=0.3P(X=2)=0.3, what can we say about P(X=3)P(X=3) if these are the only possible outcomes?

Probability Density Function (PDF) for Continuous Variables

For continuous random variables, we use a Probability Density Function (PDF), denoted as fX(x)f_X(x). Unlike PMFs, a PDF does not give the probability of a specific value xx. For any continuous variable, the probability of observing exactly one specific value is infinitesimally small, effectively zero. Instead, the PDF describes the relative likelihood for the variable to take on a given value within a continuous range. Higher values of fX(x)f_X(x) indicate a greater density of probability around xx.

⚠️ PDF Values Are Not Probabilities

It is crucial to understand that fX(x)f_X(x) itself is not a probability. A PDF value can even be greater than 1, which is impossible for a probability. Probabilities for continuous variables are found by calculating the area under the curve of the PDF over a specified interval. This requires integration.

📐 PDF Properties and Probability Calculation

For a continuous random variable XX:

  1. fX(x)≥0f_X(x) \geq 0 for all xx
  2. ∫−∞∞fX(x) dx=1\int_{-\infty}^{\infty} f_X(x) \, dx = 1
  3. The probability that XX falls within an interval [a,b][a, b] is given by:
    P(a≤X≤b)=∫abfX(x) dxP(a \leq X \leq b) = \int_{a}^{b} f_X(x) \, dx

pythonEvaluating a Normal Distribution PDF
Standard Normal Distribution PDF with Probability Interval
This line chart displays the Probability Density Function (PDF) of a standard normal distribution (mean = 0, standard deviation = 1). The x-axis represents the continuous variable, and the y-axis shows the probability density. The shaded area between -1 and 1 on the x-axis represents the probability P(−1≤X≤1)P(-1 \leq X \leq 1), which is approximately 0.6827. This visually demonstrates that probability for continuous variables is the area under the curve.
Loading chart...
Key Insight: The area under the PDF curve over an interval represents the probability of the variable falling within that interval.
Check Your Understanding
For a continuous random variable, why is P(X=c)=0P(X=c) = 0 for any specific value cc?

Comparing PMF and PDF

While both PMF and PDF serve to describe the distribution of a random variable, their fundamental differences stem from the nature of the data they represent. Understanding these distinctions is critical for correctly interpreting probabilities and applying statistical methods. The key lies in how probability is assigned and aggregated across the variable's range.

PMF vs. PDF: Key Distinctions
FeatureProbability Mass Function (PMF)Probability Density Function (PDF)
Variable TypeDiscrete (countable outcomes)Continuous (uncountable outcomes within a range)
Output ValueDirect probability P(X=x)P(X=x)Probability density fX(x)f_X(x) (not a direct probability)
Value Range0≤fX(x)≤10 \leq f_X(x) \leq 1fX(x)≥0f_X(x) \geq 0 (can be >1>1)
Total ProbabilitySums to 1: ∑fX(x)=1\sum f_X(x) = 1Integrates to 1: ∫fX(x) dx=1\int f_X(x) \, dx = 1
Probability for Single PointNon-zero probability P(X=x)>0P(X=x) > 0Zero probability P(X=x)=0P(X=x) = 0
Graphical RepresentationBar chart (heights are probabilities)Smooth curve (area under curve is probability)
A side-by-side comparison highlighting the core differences between PMF and PDF.
pythonUsing `scipy.stats` for PMF and PDF
Try It Yourself
Modify the binomial distribution example to calculate the PMF for 5 trials with a success probability of 0.7. Then, find the probability of exactly 3 successes.
python
Key Takeaways
  • PMF for Discrete Variables: A Probability Mass Function assigns a direct probability to each specific, countable outcome of a discrete random variable. The sum of all PMF values must equal 1.

  • PDF for Continuous Variables: A Probability Density Function describes the relative likelihood of outcomes for a continuous random variable. Its value at a point is not a probability; it represents density.

  • Probability from PDF: For continuous variables, probability is found by calculating the area under the PDF curve over a given interval, typically using integration or a Cumulative Distribution Function (CDF).

  • Single Point Probability: For discrete variables, P(X=x)>0P(X=x) > 0. For continuous variables, P(X=x)=0P(X=x) = 0 for any single point xx, because a point has no width.

  • Graphical Interpretation: PMFs are visualized with bar charts where bar heights are probabilities. PDFs are visualized with smooth curves, and probabilities are represented by areas under the curve.

  • Practical Use: Libraries like scipy.stats provide functions (.pmf() and .pdf()) to easily work with these distributions for both discrete and continuous data analysis.

← All lessons in Data Distributions

Ready to keep this from fading?

Bitelrn turns lessons like this into a full course — quizzes, a knowledge map, and spaced review.

Get started free