Probability mass function and probability density function
You might think that because the names 'probability mass function' and 'probability density function' are so close that they really describe the same thing. Both of them do describe probabilities, and both are functions. The big difference is in what kind of random variable they are used with:
If \(X\) is a discrete random variable, then use a probability mass function, which is a summation.
If \(X\) is a continuous random variable, then use a probability density function, which is an integral.
Going forward you will see information and examples involving the probability density function for a continuous random variable \(X\). If you are interested in probability mass functions, check out the article Discrete Probability Distributions or the article on the Poisson Distribution.
Probability density function graph
First of all, what is a probability density function?
The probability density function, or PDF, of a continuous random variable \(X\) is an integrable function \(f_X(x)\) satisfying the following:
- \(f_X(x) \ge 0\) for all \(x\) in \(X\); and
- \(\displaystyle \int_X f_X(x) \, \mathrm{d} x = 1\).
Then the probability that \(X\) is in the interval \([a,b]\) is \[ P(a<X<b) = \int_a^b f_X(x) \, \mathrm{d} x .\]
That looks more complicated than it actually is. Let's relate it to the graph of a function.
Take the function
\[ f_X(x) = \begin{cases} 0.1 & 1 \le x \le 11 \\ 0 & \text{otherwise} \end{cases} \]
as seen in the graph below.
Fig. 1 - Graph of a potential probability density function.
Let's check it for the properties of a probability density function. It is certainly at least always zero. The area under the curve is \(1\) since that area is just a rectangle with height \(0.1\) and width \(10\). And lastly, you can represent the probability as an area. For example, if you wanted to find \(P(5<X<7)\) you could do so by finding the area of the rectangle in the graph below, getting that \(P(5<X<7) = 0.2\).
Fig. 2 - \(P(5<X<7) = 0.2\)
So \(f_X(x)\) is a probability density function. If you were to graph the probability curve, you would need to integrate it, giving you
\[ P(a<X<b) = \begin{cases} 0 & a \text{ and } b \le 1 \\ 0.2(b-1) & a<1<b \le 11 \\ 0.2(b-a) & 1 \le a \le b \le 11 \\ 0.2(11-a) & 1 <a <11 < b \\ 1 & 11 \le a < b \end{cases} \]
That certainly seems like a lot of cases, but you can see it much more easily by looking at the graph below.
Fig. 3 - Graph of probabilities related to \(f_X(x)\).
Notice that the minimum height of the graph above is \(0\), and the maximum height of the graph is \(1\). This makes sense because probabilities are always at least zero and at most one.
It turns out that the integral of the probability density function is quite useful, and it is called the Cumulative Distribution Function.
Probability density function properties
Using the definition of the probability density function, you can see an important property of them:
\[P(X=a) = 0.\]
It also doesn't matter if you use strict inequalities with continuous density functions:
\[ P(X<a) = P(X\le a).\]
Both of those properties come from the fact that
\[ P(a<X<b) = \int_a^b f_X(x) \, \mathrm{d} x .\]
You might ask if the probability density function can be greater than \(1\). Sure it can! The integral of the function still needs to be equal to \(1\), but the probability density function can take on values larger than that as long as it is also at least zero. One example of this is the probability density function
\[ f_X(x) = \begin{cases} 2 & 0 \le x \le \dfrac{1}{2} \\ 0 & \text{otherwise} \end{cases} .\]
This function is always at least zero, it is integrable, and the integral is \(1\), so it could be a probability density function for a continuous random variable \(X\). Don't confuse the probability density function for actual probabilities!
Probability density function of normal distribution
One of the probability density functions you will see often is the normal distribution. You can see the graph of the standard normal distribution probability density function below.
Fig. 4 - The standard normal distribution.
Just like with other probability density functions, the area under the curve of the standard normal distribution is \(1\).
Probability density function example
Let's look at some examples.
Suppose that someone tells you that
\[ f_X(x) = \begin{cases} 2x & 0 \le x \le 1 \\ 0 & \text{otherwise} \end{cases}\]
is the probability density function for the length of time, in hours, you will spend waiting in the doctor's office.
(a) Check to be sure this is a probability density function.
(b) Find the probability you will wait less than half an hour to see the doctor.
(c) Find the probability you will wait more than half an hour to see the doctor.
Solution
(a) First note that \(X\) is in fact a continuous random variable. In addition, \(f_X(x)\) is always at least zero. It is also integrable, so now it just remains to check that the integral is one. Doing the integration,
\[\begin{align} \int_X f_X(x) \, \mathrm{d} x &= \int_0^1 2x \, \mathrm{d} x \\ &= \left. 2\left(\frac{1}{2}\right)x^2\right|_0^1 \\ &= 1^2-0^2 \\ &= 1.\end{align}\]
So this is, in fact, a probability density function.
(b) You want to know the probability that you will wait less than half an hour. In other words, you need to find \(P(X<0.5)\). Then
\[\begin{align} P(X<0.5) &= \int_0^{0.5} 2x \, \mathrm{d} x \\ &= \left.\phantom{\frac{1}{2}} x^2 \right|_0^{0.5} \\ &= (0.5)^2 - 0^2 \\ &=0.25. \end{align}\]
So the probability that you will wait less than half an hour is \(0.25\). So \(25\%\) of the time, you will wait less than half an hour to see the doctor.
(c) Now you want to find the probability that you will wait more than half an hour to see the doctor. Remember that the area under the probability density function is \(1\), so
\[ P(X > 0.5) = 1 - P(X<0.5).\]
Then using the previous part of the problem, \(P(X> 0.5) =0.75\). This means that \(75\%\) of the time, you will wait at least half an hour to see the doctor!
Probability Density Function - Key takeaways
- A probability mass function is used with discrete random variables, and a probability density function is used with continuous random variables.
The probability density function, or PDF, of a continuous random variable \(X\) is an integrable function \(f_X(x)\) satisfying the following:
- \(f_X(x) \ge 0\) for all \(x\) in \(X\); and
- \(\displaystyle \int_X f_X(x) \, \mathrm{d} x = 1\).
The probability that a continuous random variable \(X\) is in the interval \([a,b]\) is \[ P(a<X<b) = \int_a^b f_X(x) \, \mathrm{d} x .\]
For a continuous random variable \(X\), \(P(X=a) = 0\), and it doesn't matter if you use strict inequalities: \( P(X<a) = P(x \le a)\).
How we ensure our content is accurate and trustworthy?
At StudySmarter, we have created a learning platform that serves millions of students. Meet
the people who work hard to deliver fact based content as well as making sure it is verified.
Content Creation Process:
Lily Hulatt is a Digital Content Specialist with over three years of experience in content strategy and curriculum design. She gained her PhD in English Literature from Durham University in 2022, taught in Durham University’s English Studies Department, and has contributed to a number of publications. Lily specialises in English Literature, English Language, History, and Philosophy.
Get to know Lily
Content Quality Monitored by:
Gabriel Freitas is an AI Engineer with a solid experience in software development, machine learning algorithms, and generative AI, including large language models’ (LLMs) applications. Graduated in Electrical Engineering at the University of São Paulo, he is currently pursuing an MSc in Computer Engineering at the University of Campinas, specializing in machine learning topics. Gabriel has a strong background in software engineering and has worked on projects involving computer vision, embedded AI, and LLM applications.
Get to know Gabriel