๐ Continuous Random Variables & Probability Density Function (PDF)
๐ Table of Contents
- Introduction
- Continuous Random Variables
- Why Probability is Tricky
- Understanding PDF
- Mathematical Explanation
- Key Properties
- Worked Example
- Code + CLI Demo
- Key Takeaways
- Related Articles
๐ Introduction
Probability often starts with simple examples like flipping a coin or rolling a die. These are called discrete outcomes, where results are countable.
But real-world data is rarely that simple. Measurements like height, time, temperature, and weight can take infinitely many values.
๐ What is a Continuous Random Variable?
A continuous random variable is one that can take any value within a range.
- Height (5.6 ft, 5.61 ft, 5.612 ft…)
- Time (9.2 sec, 9.23 sec…)
- Temperature (30.1°C, 30.12°C…)
๐ Expand Deep Explanation
Unlike discrete variables, continuous variables are not countable. Between any two numbers, infinite values exist. This makes direct probability calculation impossible for exact points.
⚠️ The Challenge of Continuous Probability
If you ask:
What is the probability that height = exactly 6 ft?
Answer: 0
Because there are infinite possibilities, the probability of one exact value becomes negligible.
๐ What is a Probability Density Function (PDF)?
A Probability Density Function (PDF) describes how values are distributed.
Instead of giving direct probabilities, it provides a density curve.
Higher curve = more likely region.
Visual Understanding
Think of a smooth curve where:
- Tall regions → more common values
- Flat regions → less common values
๐ Mathematical Explanation
Probability is calculated using integration:
P(a ≤ X ≤ b) = ∫ f(x) dx from a to b
Where:
- f(x) = PDF
- a, b = interval
Key Concept
Area under the curve = probability.
๐ Why Integration?
Integration sums infinitely small slices of probability across a range. This is why calculus is essential in continuous probability.
➕ Advanced Mathematical Explanation
To deeply understand Probability Density Functions (PDFs), we need to connect them with calculus and limits.
A PDF is defined such that:
f(x) ≥ 0 for all x
And the total probability over all possible values is:
∫ (-∞ to ∞) f(x) dx = 1
๐ Probability Over an Interval
The probability that a continuous random variable lies between two values is:
P(a ≤ X ≤ b) = ∫ from a to b f(x) dx
This integral represents the area under the curve between points a and b.
๐ Why Probability at a Point is Zero?
Probability at a single value is:
P(X = a) = ∫ from a to a f(x) dx = 0
Since there is no width, the area is zero.
๐ Connection to Derivatives
The PDF is actually the derivative of the Cumulative Distribution Function (CDF):
f(x) = d/dx [F(x)]
Where:
- F(x) = P(X ≤ x)
- f(x) = density at point x
๐ Example: Normal Distribution
A common PDF is the normal distribution:
f(x) = (1 / (ฯ√2ฯ)) * e^(-(x - ฮผ)² / (2ฯ²))
Where:
- ฮผ = mean
- ฯ = standard deviation
๐ Expand Deep Insight
This equation produces the bell curve. The exponent controls how fast probability decreases away from the mean. Smaller ฯ → sharper peak. Larger ฯ → wider curve.
๐ Important Properties of PDF
- Total area under curve = 1
- PDF is never negative
- Probability at a single point = 0
- Only intervals have probability
๐ Real-World Example
Consider sprint time:
- Most runners finish around 10 seconds
- Few run below 9 or above 12
To find:
P(9 ≤ time ≤ 11)
We calculate area under the curve between 9 and 11.
๐ Expand Interpretation
This area represents how many runners fall in that time range compared to all runners.
๐ป Code Example
import scipy.stats as stats # Normal distribution example prob = stats.norm.cdf(11, loc=10, scale=1) - stats.norm.cdf(9, loc=10, scale=1) print(prob)
๐ฅ CLI Output
Probability between 9 and 11 seconds: 0.6826
๐ Expand CLI Explanation
This shows about 68% probability, which is common in normal distributions within ±1 standard deviation.
๐ฏ Key Takeaways
- Continuous variables take infinite values
- Exact probability = 0
- PDF represents density
- Probability = area under curve
- Integration is used for calculation
๐ Final Thoughts
Continuous probability unlocks real-world data understanding. From machine learning to finance, PDFs play a central role in modeling uncertainty.
Once you grasp the idea of “area under the curve,” the entire concept becomes intuitive and powerful.