Biostatistics Study NotesFrom concepts and derivations to interpretation

CHAPTER 02 · TOPIC 01

Random Variables and Probability Density

Learn how random variables map outcomes to numbers and how PMFs, PDFs, and CDFs describe discrete and continuous probabilities.

On this page
  1. What is a random variable?
  2. Why do we need random variables?
  3. Coin flip example
  4. Statistics can also be random variables
  5. Discrete and continuous random variables
  6. Probability mass function: discrete type
  7. Probability density function: continuous type
  8. Difference between probability density and probability
  9. Why can the density exceed 1?
  10. Cumulative Distribution Function
  11. Common Probability Distributions

A probabilistic model describes what outcomes can arise from a random phenomenon and how likely each outcome is to occur. To handle these mathematically, we use random variables to convert the trial results into numerical values.

What is a random variable?#

A random variable is a function that associates each random trial result with a numerical value. Since the result is not determined before the trial, there is also uncertainty as to what value the random variable will ultimately take.

Why do we need random variables?#

Real-world random outcomes may be events, conditions, written descriptions, etc. that cannot be calculated as is. Random variables select features of interest, represent them symbolically, and define rules for mapping each outcome to a numerical value. This transformation allows us to construct probability distributions and calculate means, variances, and other statistics.

  1. Observe phenomena with uncertainty.
  2. Choose the features you are really interested in.
  3. Its characteristics are represented by symbols such as X.
  4. Define rules for mapping each result to a numerical value.
  5. Create a distribution from the obtained values ​​and probabilities and perform calculations.

Coin flip example#

If you toss a coin twice in a row, there are four possible outcomes: heads, heads, tails, tails, and tails. If we define X as the number of heads, they correspond to 2, 1, 1, and 0, respectively.

X{0,1,2}X\in\{0,1,2\}
symbolmeaning
XA random variable that represents the number of heads.
0、1、2Possible values ​​of X. Possible or realized value

Statistics can also be random variables#

Statistics such as the sample mean and t, χ², and F are calculated from the sample data. Since the sample is not determined before sampling and the statistics change depending on the sample drawn, it can be treated as a random variable.

Discrete and continuous random variables#

Random variables are divided into discrete and continuous types, depending on whether they can enumerate each possible value one by one. Due to this difference, the functions that describe probability are also different.

kindsFeaturesexampleDescription method
discrete typePossible values ​​can be listedNumber of successes, number of cases, number of hospitalizationsProbability Mass Function (PMF)
Continuous typeCan take values ​​of arbitrary granularity within the rangeHeight, weight, blood pressure, survival timeProbability density function (PDF)

Probability mass function: discrete type#

A probability mass function (PMF) is used for discrete random variables. This directly represents the probability that X takes a particular value x.

probability of taking a certain valuep(x)=P(X=x)p(x)=P(X=x)
sum of probabilities of all possible valuesxp(x)=1\sum_x p(x)=1
symbolmeaning
Xdiscrete random variable
xone possible value of X
p(x)Probability that X takes x
P(X=x)Probability of the event "X is equal to x"
Σsum the probabilities over all possible values ​​of X

Probability density function: continuous type#

For continuous random variables, we use a probability density function (PDF). The height of the curve at a point is the probability density, not the probability of that point itself. The probability of an interval is the area under the density curve.

Difference between probability density and probability#

Probability density is a function that describes how concentrated the possible values ​​of a random variable are around each location. The height of the function at a certain position is the density, and the area under the curve obtained by integrating the density over a certain range is the probability for that interval.

Why can the density exceed 1?#

Probability is always between 0 and 1, but probability density can be higher than 1. If the total area under the density curve is 1, then it is a correct probability density function.

For example, suppose X is uniformly distributed between 0 and 0.5. Since the width is only 0.5, the density height can be 2, and the total area is still 0.5 x 2 = 1.

Uniform probability density with height 2 over an interval of width 0.5, giving a total rectangular area of 1
A density height of 2 does not mean that probability exceeds 1. Probability is the area under the curve, here 2 × 0.5 = 1.Source: Created for this site
density functionf(x)=2,0x0.5f(x)=2,\quad 0\le x\le 0.5
full range probabilitiesP(0X0.5)=00.52dx=1P(0\le X\le 0.5)=\int_0^{0.5}2\,dx=1
partial probabilityP(0X0.1)=00.12dx=0.2P(0\le X\le 0.1)=\int_0^{0.1}2\,dx=0.2
symbolmeaning
f(x)=2High probability density in this range. Not a probability of 1 point
0.5、0.1Width of the interval to be calculated
Integrate the density of the specified section as the area under the curve
1、0.2Interval probability obtained by integration
Probability of 1 pointP(X=x)=0P(X=x)=0
interval probabilityP(aXb)=abf(x)dxP(a\le X\le b)=\int_a^b f(x)\,dx
Total area under the density curvef(x)dx=1\int_{-\infty}^{\infty}f(x)\,dx=1
symbolmeaning
f(x)Probability density around x. The function value itself is not a probability of one point.
a、bLower and upper bounds of the interval for which probability is to be calculated
Area under the density curve in the specified interval
−∞、∞a range containing all possible values ​​of X

Cumulative Distribution Function#

The cumulative distribution function (CDF) can be used in both discrete and continuous forms and represents the cumulative probability up to x.

common definitionF(x)=P(Xx)F(x)=P(X\le x)
Continuous representationF(x)=xf(u)duF(x)=\int_{-\infty}^{x}f(u)\,du
symbolmeaning
F(x)Cumulative probability that X is less than or equal to x
f(u)Probability density function of continuous random variable
uVariable for integration to avoid confusion with integral upper limit x

Common Probability Distributions#

Types of random variablesTypical distribution
discrete typebinomial, Poisson, hypergeometric
Continuous typenormal distribution, uniform distribution, exponential distribution