Introduction to Random Variables
Discrete Random Variables
Dr. Bülent Yılmaz
Introduction
• A discrete sample space Ω is a finite or
listable set of outcomes {ω1, ω2 . . .}.
• The probability of an outcome ω is denoted
P(ω).
• An event E is a subset of Ω. The probability
of an event E is P(E) = sum of all P(ω)’s in E.
Definition
• A random variable is a real-valued variable whose
value is determined by an underlying random
experiment.
• In a soccer game we may be interested in the
number of goals, shots, shots on goal, corners
kicks, fouls, etc.
• If we consider an entire soccer match as a
random experiment, then each of these
numerical results gives some information about
the outcome of the random experiment.
• These are examples of random variables.
Example
• I toss a coin five times. This is a random experiment
and the sample space can be written as
– S={TTTTT,TTTTH,...,HHHHH}.
– Note that here the sample space S has 25=32 elements.
• Suppose that in this experiment, we are interested in
the number of heads.
• We can define a random variable X whose value is the
number of observed heads. The value of X will be one
of 0, 1, 2, 3, 4 or 5 depending on the outcome of the
random experiment.
Example cont’d
• A random variable is a real-valued function that
assigns a numerical value to each possible
outcome of the random experiment.
• The random variable X defined above assigns the
value 0 to the outcome TTTTT, the value 2 to the
outcome THTHT, and so on.
• Hence, the random variable X is a function from
the sample space S={TTTTT, TTTTH, ⋯, ⋯,
HHHHH} to the real numbers
– for this particular random variable, the values are
always integers between 0 and 5
Random variables
• We usually show random variables by capital
letters such as X, Y, and Z. Since a random
variable is a function, we can talk about its
range.
• The range of a random variable X, shown by
Range(X) or RX, is the set of possible values for
X. Range(X) = RX= {0,1,2,3,4,5}.
Range Examples
1. I toss a coin 100 times. Let X be the number
of heads I observe.
2. I toss a coin until the first heads appears. Let
Y be the total number of coin tosses.
3. The random variable T is defined as the time
(in hours) from now until the next
earthquake occurs in a certain city.
1) 0,1,…100 2) 1,2,... 3) any positive real number
Discrete random variable
• X is a discrete random variable, if its range is
countable.
• Remember that a set A is countable if either
– A is a finite set such as {1,2,3,4}, or
– it can be put in one-to-one correspondence with natural
numbers (in this case the set is said to be countably
infinite)
– the set of integers {0,1,−1,2,−2,3,−3,…} is clearly infinite.
However, as suggested by the above arrangement, we can
count off all the integers. Counting off every integer will
take forever. But, if you specify any integer, say
−10,234,872,306 we will get to this integer in the counting
process in a finite amount of time.
Probability Mass Function (PMF)
• Let X be a discrete random variable with range
RX={x1,x2,x3,...} (finite or countably infinite).
• The function PX(xk) = P(X = xk), for k=1,2,3,..., is
called the probability mass function (PMF) of X.
• The PMF is a probability measure that gives us
probabilities of the possible values for a
random variable.
– PX(1) shows the probability that X=1.
Example
• I toss a fair coin twice, and let X be defined as the
number of heads I observe. Find the range of X,
RX, as well as its probability mass function PX.
• Answer:
– S = {HH, HT, TH, TT}
– RX = {0, 1, 2}
– PX(k) = P(X = k) for k=0, 1 or 2
• PX(0) = ¼, PX(1) = ½, PX(2) = ¼
Exercise
• I have an unfair coin for which P(H)=p, where
0 < p < 1. I toss the coin repeatedly until I
observe a heads for the first time. Let Y be the
total number of coin tosses. Find the
distribution of Y.
• Y can potentially take any positive integer.
Solution
• PY(1) = P(Y=1) = P(H) = p,
• PY(2) = P(Y=2) = P(TH) = (1−p)p,
• PY(3) = P(Y=3) = P(TTH) = (1−p)2p,
…
• PY(k) = P(Y=k) = P(TT...TH) = (1−p)k−1p.
Properties of PMF
Independent discrete random variables
• Consider two discrete random variables X and
Y. We say that X and Y are independent if
– P(X=x,Y=y) = P(X=x)P(Y=y), for all x,y.
• In general, if two random variables are
independent, then you can write
– P(X∈A,Y∈B) = P(X∈A)P(Y∈B), for all sets A and B.
Example
• I toss a coin twice and define X to be the
number of heads I observe. Then, I toss the
coin two more times and define Y to be the
number of heads that I observe this time. Find
P((X<2) and (Y>1))
Solution
• Since X and Y are the result of different
independent coin tosses, the two random
variables X and Y are independent. Also, note that
both random variables have the distribution we
found in our previous example.
• We can write P((X<2) and (Y>1))
=P(X<2)P(Y>1)(because X and Y are independent)
= (PX(0)+PX(1)) PY(2)
= (1/4 + 1/2) 1/4 = 3/16