Definition of Random Variable

DefinitionRandom variable

On a probability space (Ω,F,P)(\Omega,\mathcal F,P), a real random variable is a function X:Ω→RX:\Omega\to\mathbb R such that {ω:X(ω)≤x}∈F\{\omega:X(\omega)\le x\}\in\mathcal F for every real xx. This measurability condition makes the probabilities below meaningful.

Probability functions

A discrete variable has a countable set SS with P(X∈S)=1P(X\in S)=1. Its probability mass function is pX(x)=P(X=x)p_X(x)=P(X=x). Countable additivity on the disjoint events {X=x}\{X=x\} gives

pX(x)≥0,∑x∈SpX(x)=1.p_X(x)\ge0,\qquad \sum_{x\in S}p_X(x)=1.

An absolutely continuous distribution has a nonnegative integrable density fXf_X such that, for every Borel set BB,

P(X∈B)=∫BfX(t) dt.P(X\in B)=\int_B f_X(t)\,dt.

Taking B=RB=\mathbb R gives total integral one; taking a singleton gives P(X=x)=0P(X=x)=0. Density values at individual points do not affect probabilities. Having infinitely many possible values does not imply existence of a density. Mixed distributions have both atoms and a continuous part; singular continuous distributions also exist, so PMFs and PDFs do not exhaust all distributions. In the examples below, “continuous” means absolutely continuous.

Cumulative distribution function

Every real random variable has a CDF:

FX(x)=P(X≤x).F_X(x)=P(X\le x).

For a discrete variable it is the sum of masses at t≤xt\le x; when a density exists it is the integral of that density over (−∞,x](-\infty,x].

TheoremCDF properties

FXF_X is nondecreasing and right-continuous, with limits zero at −∞-\infty and one at +∞+\infty. Moreover,

P(a<X≤b)=FX(b)−FX(a).P(a<X\le b)=F_X(b)-F_X(a).P(X=x)=FX(x)−FX(x−).P(X=x)=F_X(x)-F_X(x-).
Proof

First derive continuity of probability from countable additivity. If An↑AA_n\uparrow A, partition AA into A1A_1 and the disjoint increments An∖An−1A_n\setminus A_{n-1}. The partial sums show P(An)→P(A)P(A_n)\to P(A). Taking complements proves the analogous result for decreasing events.

The events {X≤x}\{X\le x\} are nested, giving monotonicity. As n→∞n\to\infty, the events {X≤x+1/n}\{X\le x+1/n\} decrease to {X≤x}\{X\le x\}, proving right-continuity (monotonicity then handles every approach from the right). The events {X≤n}\{X\le n\} increase to Ω\Omega and {X≤−n}\{X\le -n\} decrease to the empty set because XX is finite-valued. These give the two limits. Subtract the probabilities of nested events to obtain the interval formula. Finally {X≤x−1/n}\{X\le x-1/n\} increases to {X<x}\{X<x\}, so its limiting probability is FX(x−)F_X(x-); subtracting from FX(x)F_X(x) gives the atom formula.

See Expectation and Variance for integrals of random variables.

Some Examples

Below are some examples of random variables in different contexts: discrete, continuous, and mixed.

Discrete Random Variable

ExampleRolling a Die

Consider a simple example of rolling a fair six-sided die. The sample space Ω\Omega consists of the outcomes {1,2,3,4,5,6}\{1, 2, 3, 4, 5, 6\}. We can define a random variable XX that maps each outcome to its value. For example, if we roll a die and get a 3, then X(ω)=3X(\omega) = 3. The probability distribution of this random variable is uniform, meaning each outcome has an equal probability of 16\frac{1}{6}.

PMF: pX(x)=16p_X(x) = \frac{1}{6} for x∈{1,2,3,4,5,6}x \in \{1, 2, 3, 4, 5, 6\}

For detailed calculations of expected value and variance, see Expectation and Variance.

Discrete PMF and step CDF. For a fair die, the CDF accumulates the six equal probability masses into a staircase.

Discrete PMF and step CDF. For a fair die, the CDF accumulates the six equal probability masses into a staircase.

For a fair die, the CDF accumulates the six equal probability masses into a staircase.

Continuous Random Variable

ExampleRainfall measurement

A normal variable W∼N(100,302)W\sim N(100,30^2) can be negative. To model nonnegative rainfall, let YY have the conditional distribution of WW given W≥0W\ge0. Write ϕ\phi and Φ\Phi for the standard normal density and CDF. Conditional probability gives

fY(y)={ϕ((y−100)/30)30Φ(10/3),y≥0,0,y<0,f_Y(y)=\begin{cases}\dfrac{\phi((y-100)/30)}{30\Phi(10/3)},&y\ge0,\\0,&y<0,\end{cases}

because P(W≥0)=1−Φ(−10/3)=Φ(10/3)P(W\ge0)=1-\Phi(-10/3)=\Phi(10/3) by normal symmetry. Integrating gives

FY(y)={0,y<0,Φ((y−100)/30)−Φ(−10/3)Φ(10/3),y≥0.F_Y(y)=\begin{cases}0,&y<0,\\ \dfrac{\Phi((y-100)/30)-\Phi(-10/3)}{\Phi(10/3)},&y\ge0. \end{cases}

The limits are zero and one, verifying normalization. For example,

P(70≤Y≤130)=Φ(1)−Φ(−1)Φ(10/3)≈0.6830,P(70\le Y\le130)=\frac{\Phi(1)-\Phi(-1)}{\Phi(10/3)}\approx0.6830,P(40≤Y≤160)=Φ(2)−Φ(−2)Φ(10/3)≈0.9549.P(40\le Y\le160)=\frac{\Phi(2)-\Phi(-2)}{\Phi(10/3)}\approx0.9549.

The parameters 100100 and 3030 describe the normal variable before truncation; they are not exactly the mean and standard deviation of YY.

Density, area, and cumulative probability. This separate uniform-distribution example shows probability as area under a density, and the CDF as accumulated area.

Density, area, and cumulative probability. This separate uniform-distribution example shows probability as area under a density, and the CDF as accumulated area.

This separate uniform-distribution example shows probability as area under a density, and the CDF as accumulated area.

Mixed Random Variable

ExampleCustomer waiting time

A customer receives immediate service with probability 0.30.3. Otherwise the waiting time ZZ has an exponential distribution with rate λ>0\lambda>0. For x≥0x\ge0, partitioning by the immediate-service event gives

FZ(x)=0.3+0.7(1−e−λx)=1−0.7e−λx.F_Z(x)=0.3+0.7(1-e^{-\lambda x})=1-0.7e^{-\lambda x}.

For x<0x<0, FZ(x)=0F_Z(x)=0. The jump at zero has size 0.30.3, so P(Z=0)=0.3P(Z=0)=0.3. On (0,∞)(0,\infty) the continuous part has density 0.7λe−λx0.7\lambda e^{-\lambda x} and total mass 0.70.7. Its integral alone cannot describe the atom; the full distribution is

P(Z∈B)=0.31{0∈B}+0.7∫B∩(0,∞)λe−λx dx.P(Z\in B)=0.3\mathbf1_{\{0\in B\}}+0.7\int_{B\cap(0,\infty)}\lambda e^{-\lambda x}\,dx.

Comparison: Discrete and Absolutely Continuous Distributions

AspectDiscreteAbsolutely continuous
Defining propertyProbability one on a countable setProbabilities are integrals of a density
Individual pointsAtoms may have positive massEvery point has probability zero
CDFSum of masses at values at most xxIntegral of density up to xx
Expectation, when integrableSum of value times massIntegral of value times density

Joint Random Variables

DefinitionJoint random variables

Random variables X,YX,Y on the same probability space define a random vector (X,Y)(X,Y). Their joint distribution assigns a probability to each Borel subset of R2\mathbb R^2.

For discrete variables, pX,Y(x,y)=P(X=x,Y=y)p_{X,Y}(x,y)=P(X=x,Y=y). Disjointness of the point events gives total mass one and the marginal formulas

pX(x)=∑ypX,Y(x,y),pY(y)=∑xpX,Y(x,y).p_X(x)=\sum_y p_{X,Y}(x,y),\qquad p_Y(y)=\sum_x p_{X,Y}(x,y).

If the joint distribution has a density fX,Yf_{X,Y}, its integral over a set is the probability of that set. Integrating out a coordinate gives

fX(x)=∫RfX,Y(x,y) dy,fY(y)=∫RfX,Y(x,y) dx.f_X(x)=\int_{\mathbb R}f_{X,Y}(x,y)\,dy,\qquad f_Y(y)=\int_{\mathbb R}f_{X,Y}(x,y)\,dx.

Indeed, integrate either expression over a Borel set AA; Tonelli's theorem for nonnegative integrands identifies the result with the probability of A×RA\times\mathbb R or R×A\mathbb R\times A. Tonelli is a measure-theoretic prerequisite not proved here. Individual densities do not guarantee a joint density: if XX is uniform and Y=XY=X, all joint mass lies on the diagonal, whose planar area is zero, contradicting any putative density formula.

Independence means P(X∈A,Y∈B)=P(X∈A)P(Y∈B)P(X\in A,Y\in B)=P(X\in A)P(Y\in B) for all Borel sets A,BA,B. In the discrete case this is equivalent to pX,Y(x,y)=pX(x)pY(y)p_{X,Y}(x,y)=p_X(x)p_Y(y): necessity follows using singletons, and sufficiency by summing over A×BA\times B. For joint densities, factorization fX,Y=fXfYf_{X,Y}=f_Xf_Y almost everywhere is sufficient by iterated integration. Necessity uses uniqueness of probability measures determined by rectangles and uniqueness of densities almost everywhere; these measure-theoretic results are prerequisites not proved here.

ExampleTwo Dice

Consider rolling two fair six-sided dice. Let XX be the outcome of the first die and YY be the outcome of the second die.

Joint PMF: pX,Y(x,y)=136p_{X,Y}(x,y) = \frac{1}{36} for x,y∈{1,2,3,4,5,6}x,y \in \{1, 2, 3, 4, 5, 6\}

Marginal PMFs:

  • pX(x)=∑y=16pX,Y(x,y)=16p_X(x) = \sum_{y=1}^{6} p_{X,Y}(x,y) = \frac{1}{6}
  • pY(y)=∑x=16pX,Y(x,y)=16p_Y(y) = \sum_{x=1}^{6} p_{X,Y}(x,y) = \frac{1}{6}

Since pX,Y(x,y)=pX(x)⋅pY(y)p_{X,Y}(x,y) = p_X(x) \cdot p_Y(y), the dice rolls are independent.

ExampleHeight and Weight

Consider the relationship between height HH and weight WW of adults. These are typically not independent.

In a model admitting a joint density, fH,W(h,w)f_{H,W}(h,w) describes how height and weight are distributed together in the population.

  • The marginal density fH(h)=∫0∞fH,W(h,w)dwf_H(h) = \int_{0}^{\infty} f_{H,W}(h,w) dw gives the distribution of heights regardless of weight
  • The marginal density fW(w)=∫0∞fH,W(h,w)dhf_W(w) = \int_{0}^{\infty} f_{H,W}(h,w) dh gives the distribution of weights regardless of height

Since height and weight are correlated, fH,W(h,w)≠fH(h)⋅fW(w)f_{H,W}(h,w) \neq f_H(h) \cdot f_W(w).

Exercises

ExerciseSubset Cardinality and Minimum Element

One of the 256 subsets of {1,2,3,4,5,6,7,8}\{1,2,3,4,5,6,7,8\} is chosen uniformly at random. Let XX be the number of elements in this subset. Let YY be 1 if the subset is empty and the least element of the subset otherwise.

  1. Are the events "X=1X = 1" and "Y=3Y = 3" independent?
  2. Are the random variables XX and YY independent?
  3. What is Pr⁡(X≤2∣Y≤5)\Pr(X \leq 2 \mid Y \leq 5)?
Solution

Since each of the 28=2562^8 = 256 subsets is equally likely, each is chosen with probability 1256\frac{1}{256}.

  1. Independence of Events X=1X = 1 and Y=3Y = 3: We check whether Pr⁡(X=1∧Y=3)=Pr⁡(X=1)Pr⁡(Y=3)\Pr(X = 1 \land Y = 3) = \Pr(X = 1)\Pr(Y = 3).
    • There are (81)=8\binom{8}{1} = 8 subsets with exactly 1 element, so Pr⁡(X=1)=8256=132\Pr(X = 1) = \frac{8}{256} = \frac{1}{32}.
    • A subset has least element 3 if and only if it contains 3 and a subset of {4,5,6,7,8}\{4,5,6,7,8\}, giving 25=322^5 = 32 subsets. Thus Pr⁡(Y=3)=32256=18\Pr(Y = 3) = \frac{32}{256} = \frac{1}{8}.
    • The event "X=1X = 1 and Y=3Y = 3" corresponds to the unique subset {3}\{3\}, so Pr⁡(X=1∧Y=3)=1256\Pr(X = 1 \land Y = 3) = \frac{1}{256}. Since
Pr⁡(X=1)Pr⁡(Y=3)=132⋅18=1256=Pr⁡(X=1∧Y=3)\Pr(X = 1)\Pr(Y = 3) = \frac{1}{32} \cdot \frac{1}{8} = \frac{1}{256} = \Pr(X = 1 \land Y = 3)

, the events are independent.

  1. Independence of Random Variables XX and YY: Consider X=8X = 8 and Y=8Y = 8.

    • Pr⁡(X=8)=1256\Pr(X = 8) = \frac{1}{256} (only the full set {1,2,3,4,5,6,7,8}\{1,2,3,4,5,6,7,8\}).
    • Pr⁡(Y=8)=1256\Pr(Y = 8) = \frac{1}{256} (only the singleton {8}\{8\}).
    • However, a subset cannot simultaneously have 8 elements and have 8 as its minimum element, so Pr⁡(X=8∧Y=8)=0≠Pr⁡(X=8)Pr⁡(Y=8)\Pr(X = 8 \land Y = 8) = 0 \neq \Pr(X = 8)\Pr(Y = 8). Therefore, XX and YY are not independent random variables.
  2. Conditional Probability Pr⁡(X≤2∣Y≤5)\Pr(X \leq 2 \mid Y \leq 5):

    • The subsets with minimum element ≥6\geq 6 are subsets of {6,7,8}\{6,7,8\} (excluding ∅\emptyset, which has Y=1Y=1). There are 23−1=72^3 - 1 = 7 such subsets: {6},{7},{8},{6,7},{6,8},{7,8},{6,7,8}\{6\}, \{7\}, \{8\}, \{6,7\}, \{6,8\}, \{7,8\}, \{6,7,8\}. Thus Pr⁡(Y≤5)=1−7256=249256\Pr(Y \leq 5) = 1 - \frac{7}{256} = \frac{249}{256}.
    • The total number of subsets with X≤2X \leq 2 is (80)+(81)+(82)=1+8+28=37\binom{8}{0} + \binom{8}{1} + \binom{8}{2} = 1 + 8 + 28 = 37. Among these 37 subsets, those with Y≥6Y \geq 6 are the 6 non-empty subsets with at most 2 elements from {6,7,8}\{6,7,8\}: {6},{7},{8},{6,7},{6,8},{7,8}\{6\}, \{7\}, \{8\}, \{6,7\}, \{6,8\}, \{7,8\}. Therefore, the number of subsets with X≤2X \leq 2 and Y≤5Y \leq 5 is 37−6=3137 - 6 = 31.
Pr⁡(X≤2∣Y≤5)=Pr⁡(X≤2∧Y≤5)Pr⁡(Y≤5)=31/256249/256=31249.\Pr(X \leq 2 \mid Y \leq 5) = \frac{\Pr(X \leq 2 \land Y \leq 5)}{\Pr(Y \leq 5)} = \frac{31/256}{249/256} = \frac{31}{249}.
Remark

A common pitfall in part 3 is attempting to count subsets with X=2X = 2 and Y≤5Y \leq 5 by multiplying (51)×(71)=35\binom{5}{1} \times \binom{7}{1} = 35. This overcounts sets where both elements are ≤5\leq 5, because pairs like {1,2}\{1, 2\} would be counted twice depending on which element is picked first.

ExerciseProduct Distribution of Two Dice

Two fair six-sided dice are rolled independently. Let XX denote the product of the two face values. Determine the probability mass function P(X=i)P(X = i) for all possible values of ii.

Solution

There are 6×6=366 \times 6 = 36 equally likely outcomes (a,b)(a, b) with 1≤a,b≤61 \leq a, b \leq 6. Counting the factor pairs for each product i=a⋅bi = a \cdot b:

P(X=1)=136P(X=6)=436P(X=15)=236P(X=25)=136P(X=2)=236P(X=8)=236P(X=16)=136P(X=30)=236P(X=3)=236P(X=9)=136P(X=18)=236P(X=36)=136P(X=4)=336P(X=10)=236P(X=20)=236P(X=other)=0P(X=5)=236P(X=12)=436P(X=24)=236\begin{aligned} P(X = 1) &= \frac{1}{36} & P(X = 6) &= \frac{4}{36} & P(X = 15) &= \frac{2}{36} & P(X = 25) &= \frac{1}{36} \\ P(X = 2) &= \frac{2}{36} & P(X = 8) &= \frac{2}{36} & P(X = 16) &= \frac{1}{36} & P(X = 30) &= \frac{2}{36} \\ P(X = 3) &= \frac{2}{36} & P(X = 9) &= \frac{1}{36} & P(X = 18) &= \frac{2}{36} & P(X = 36) &= \frac{1}{36} \\ P(X = 4) &= \frac{3}{36} & P(X = 10) &= \frac{2}{36} & P(X = 20) &= \frac{2}{36} & P(X = \text{other}) &= 0 \\ P(X = 5) &= \frac{2}{36} & P(X = 12) &= \frac{4}{36} & P(X = 24) &= \frac{2}{36} & & \end{aligned}
ExerciseHighest Rank of a Group

Five men and five women are ranked according to their examination scores, with all 10!10! possible rankings equally likely and no tied scores. Let XX denote the highest rank achieved by a woman (e.g. X=1X=1 if a woman finishes first). Find the PMF of XX.

Solution

The woman with the highest rank can finish anywhere from rank 1 to rank 6 (since if all 5 men take the top 5 spots, the top woman finishes 6th).

For X=iX = i (1≤i≤61 \leq i \leq 6), the first i−1i - 1 positions must be occupied by men, position ii must be occupied by a woman, and the remaining positions are filled by the remaining 4 women and 5−(i−1)5 - (i - 1) men.

Equivalently, choosing the 5 positions for women out of 10 total positions: the top woman at position ii means the remaining 4 women must be chosen from the 10−i10 - i positions below rank ii. Therefore:

P(X=i)=(10−i4)(105),i∈{1,2,3,4,5,6}P(X = i) = \frac{\binom{10 - i}{4}}{\binom{10}{5}}, \quad i \in \{1, 2, 3, 4, 5, 6\}

Explicit probabilities:

  • P(X=1)=(94)(105)=126252=12P(X = 1) = \frac{\binom{9}{4}}{\binom{10}{5}} = \frac{126}{252} = \frac{1}{2}
  • P(X=2)=(84)252=70252=518P(X = 2) = \frac{\binom{8}{4}}{252} = \frac{70}{252} = \frac{5}{18}
  • P(X=3)=(74)252=35252=536P(X = 3) = \frac{\binom{7}{4}}{252} = \frac{35}{252} = \frac{5}{36}
  • P(X=4)=(64)252=15252=584P(X = 4) = \frac{\binom{6}{4}}{252} = \frac{15}{252} = \frac{5}{84}
  • P(X=5)=(54)252=5252P(X = 5) = \frac{\binom{5}{4}}{252} = \frac{5}{252}
  • P(X=6)=(44)252=1252P(X = 6) = \frac{\binom{4}{4}}{252} = \frac{1}{252}