# Probability Density Function – Explanation & Examples

The definition of probability density function (PDF) is:

“The PDF describes how the probabilities are distributed over the different values of the continuous random variable.”

In this topic, we will discuss the probability density function (PDF) from the following aspects:

• What is a probability density function?
• How to calculate the probability density function?
• Probability density function formula.
• Practice questions.

## What is a probability density function?

The probability distribution for a random variable describes how the probabilities are distributed over the random variable’s different values.

In any probability distribution, the probabilities must be >= 0 and sum to 1.

For the discrete random variable, the probability distribution is called the probability mass function or PMF.

For example, when tossing a fair coin, the probability of head = probability of tail = 0.5.

For the continuous random variable, the probability distribution is called the probability density function or PDF. PDF is the probability density over some intervals.

Continuous random variables can take an infinite number of possible values within a certain range.

For example, a certain weight can be 70.5 kg. Still, with increasing balance accuracy, we can have a value of 70.5321458 kg. So the weight can take infinite values with infinite decimal places.

Since there is an infinite number of values in any interval, it is not meaningful to talk about the probability that the random variable will take on a specific value. Instead, the probability that a continuous random variable will lie within a given interval is considered.

Suppose the probability density around a value x is large. In that case, that means the random variable X is likely to be close to x. If, on the other hand, the probability density = 0 in some interval, then X will not be in that interval.

In general, to determine the probability that X is in any interval, we add up the densities’ values in that interval. By “add up,” we mean to integrate the density curve within that interval.

## How to calculate the probability density function?

### – Example 1

The following are the weights of 30 individuals from a certain survey.

54 53 42 49 41 45 69 63 62 72 64 67 81 85 89 79 84 86 101 104 103 108 97 98 126 129 123 119 117 124.

Estimate the probability density function for these data.

1. Determine the number of bins you need.

The number of bins is log(observations)/log(2).

In this data, the number of bins = log(30)/log(2) = 4.9 will be rounded up to become 5.

2. Sort the data and subtract the minimum data value from the maximum data value to get the data range.

The sorted data will be:

41 42 45 49 53 54 62 63 64 67 69 72 79 81 84 85 86 89 97 98 101 103 104 108 117 119 123 124 126 129.

In our data, the minimum value is 41, and the maximum value is 129, so:

The range = 129 – 41 = 88.

3. Divide the data range in Step 2 by the number of classes you get in Step 1. Round the number, you get up to a whole number to get the class width.

Class width = 88 / 5 = 17.6. Rounded up to 18.

4. Add the class width, 18, sequentially (5 times because 5 is the number of bins) to the minimum value to create the different 5 bins.

41 + 18 = 59 so the first bin is 41-59.

59 + 18 = 77 so the second bin is 59-77.

77 + 18 = 95 so the third bin is 77-95.

95 + 18 = 113 so the fourth bin is 95-113.

113 + 18 = 131 so the fifth bin is 113-131.

5. We draw a table of 2 columns. The first column carries the different bins of our data that we created in step 4.

The second column will contain the frequency of weights in each bin.

 range frequency 41 – 59 6 59 – 77 6 77 – 95 6 95 – 113 6 113 – 131 6

The bin “41-59” contains the weights from 41 to 59, the next bin “59-77” contains the weights larger than 59 till 77, and so on.

By looking at the sorted data in step 2, we see that:

• The first 6 numbers (41, 42, 45, 49, 53, 54) are within the first bin, “41-59,” so this bin’s frequency is 6.
• The next 6 numbers (62, 63, 64, 67, 69, 72) are within the second bin, “59-77,” so this bin’s frequency is 6 too.
• All bins have a frequency of 6.
• If you sum these frequencies, you will get 30 which is the total number of data.

6. Add a third column for the relative frequency or probability.

Relative frequency = frequency/total data number.

 range frequency relative.frequency 41 – 59 6 0.2 59 – 77 6 0.2 77 – 95 6 0.2 95 – 113 6 0.2 113 – 131 6 0.2
• Any bin contains 6 data points or frequency, so the relative frequency of any bin = 6/30 = 0.2.

If you sum these relative frequencies, you will get 1.

7. Use the table to plot a relative frequency histogram, where the data bins or ranges on the x-axis and the relative frequency or proportions on the y-axis.

• In relative frequency histograms, the heights or proportions can be interpreted as probabilities. These probabilities can be used to determine the likelihood of certain results occurring within a given interval.
• For example, the relative frequency of the “41-59” bin is 0.2, so the probability of weights falling in this range is 0.2 or 20%.

8. Add another column for the density.

Density = relative frequency/class width = relative frequency/18.

 range frequency relative.frequency density 41 – 59 6 0.2 0.011 59 – 77 6 0.2 0.011 77 – 95 6 0.2 0.011 95 – 113 6 0.2 0.011 113 – 131 6 0.2 0.011

9. Suppose we decreased the intervals more and more. In that case, we could represent the probability distribution as a curve by connecting the “dots” at the tops of the tiny, tiny, tiny rectangles:

We can write this density function as:

f(x)={■(0.011&”if ” 41≤x≤[email protected]&”if ” x<41,x>131)┤

It means that the probability density = 0.011 if the weight is between 41 and 131. The density is 0 for all weights outside that range.

It is an example of uniform distribution where the density of weight for any value between 41 and 131 is 0.011.

However, unlike probability mass functions, the probability density function’s output is not a probability value but gives a density.

To get the probability from a probability density function, we need to integrate the area under the curve for a certain interval.

The probability= Area under the curve = density X interval length.

In our example, the interval length = 131-41 = 90 so the area under the curve = 0.011 X 90 = 0.99 or ~1.

It means that the probability of weight that lies between 41-131 is 1 or 100%.

For the interval, 41-61, the probability = density X interval length = 0.011 X 20 = 0.22 or 22%.

We can plot this as follows:

The red shaded area represents 22% of the total area, so the probability of weight in the interval 41-61 = 22%.

### – Example 2

The following are the below poverty percentages for 100 counties from the midwest region of the USA.

12.90 12.51 10.22 17.25 12.66 9.49 9.06 8.99 14.16 5.19 13.79 10.48 13.85 9.13 18.16 15.88 9.50 20.54 17.75 6.56 11.40 12.71 13.62 15.15 13.44 17.52 17.08 7.55 13.18 8.29 23.61 4.87 8.35 6.90 6.62 6.87 9.47 7.20 26.01 16.00 7.28 12.35 13.41 12.80 6.12 6.81 8.69 11.20 14.53 25.17 15.51 11.63 15.56 11.06 11.25 6.49 11.59 14.64 16.06 11.30 9.50 14.08 14.20 15.54 14.23 17.80 9.15 11.53 12.08 28.37 8.05 10.40 10.40 3.24 11.78 7.21 16.77 9.99 16.40 13.29 28.53 9.91 8.99 12.25 10.65 16.22 6.14 7.49 8.86 16.74 13.21 4.81 12.06 21.21 16.50 13.26 11.52 19.85 6.13 5.63.

Estimate the probability density function for these data.

1. Determine the number of bins you need.

The number of bins is log(observations)/log(2).

In this data, the number of bins = log(100)/log(2) = 6.6 will be rounded up to become 7.

2. Sort the data and subtract the minimum data value from the maximum data value to get the data range.

The sorted data will be:

3.24 4.81 4.87 5.19 5.63 6.12 6.13 6.14 6.49 6.56 6.62 6.81 6.87 6.90 7.20 7.21 7.28 7.49 7.55 8.05 8.29 8.35 8.69 8.86 8.99 8.99 9.06 9.13 9.15 9.47 9.49 9.50 9.50 9.91 9.99 10.22 10.40 10.40 10.48 10.65 11.06 11.20 11.25 11.30 11.40 11.52 11.53 11.59 11.63 11.78 12.06 12.08 12.25 12.35 12.51 12.66 12.71 12.80 12.90 13.18 13.21 13.26 13.29 13.41 13.44 13.62 13.79 13.85 14.08 14.16 14.20 14.23 14.53 14.64 15.15 15.51 15.54 15.56 15.88 16.00 16.06 16.22 16.40 16.50 16.74 16.77 17.08 17.25 17.52 17.75 17.80 18.16 19.85 20.54 21.21 23.61 25.17 26.01 28.37 28.53.

In our data, the minimum value is 3.24, and the maximum value is 28.53, so:

The range = 28.53-3.24 = 25.29.

3. Divide the data range in Step 2 by the number of classes you get in Step 1. Round the number you get up to a whole number to get the class width.

Class width = 25.29 / 7 = 3.6. Rounded up to 4.

4. Add the class width, 4, sequentially (7 times because 7 is the number of bins) to the minimum value to create the different 7 bins.

3.24 + 4 = 7.24 so the first bin is 3.24-7.24.

7.24 + 4 = 11.24 so the second bin is 7.24-11.24.

11.24 + 4 = 15.24 so the third bin is 11.24-15.24.

15.24 + 4 = 19.24 so the fourth bin is 15.24-19.24.

19.24 + 4 = 23.24 so the fifth bin is 19.24-23.24.

23.24 + 4 = 27.24 so the sixth bin is 23.24-27.24.

27.24 + 4 = 31.24 so the seventh bin is 27.24-31.24.

5. We draw a table of 2 columns. The first column carries the different bins of our data that we created in step 4.

The second column will contain the frequency of percentages in each bin.

 range frequency 3.24 – 7.24 16 7.24 – 11.24 26 11.24 – 15.24 33 15.24 – 19.24 17 19.24 – 23.24 3 23.24 – 27.24 3 27.24 – 31.24 2

If you sum these frequencies, you will get 100 which is the total number of data.
16+26+33+17+3+3+2 = 100.

6. Add a third column for the relative frequency or probability.

Relativefrequency=frequency/totaldatanumber.

 range frequency relative.frequency 3.24 – 7.24 16 0.16 7.24 – 11.24 26