class 4
class 4
• Random Variables
• Discrete Random Variables
• Expected Value
• Expectation of a Function
• Variance
• Bernoulli and Binomial Random Variables
• Poisson Random Variables
• Geometric Random Variables
2
Outline
• Random Variables
• Discrete Random Variables
• Expected Value
• Expectation of a Function
• Variance
• Bernoulli and Binomial Random Variables
• Poisson Random Variables
• Geometric Random Variables
3
Random Variables
Frequently, we are mainly interested in some function of the outcome rather than
the outcome itself. These real-valued functions defined on the sample space are
known as random variables (RV’s).
Example: Toss three fair coins. Let Y denote the number of heads happening.
Then Y is a RV taking one of the values 0, 1, 2, 3 with respective probabilities:
1
P (Y = 0) = P ({TTT}) =
8
3
P (Y = 1) = P ({TTH, THT, HTT}) =
8
3
P (Y = 2) = P ({HHT, HTH, THH}) =
8
1
P (Y = 3) = P ({HHH}) =
8
and
3
X
P (Y = i) = 1.
i=0
4
Random Variables
P (X = 1) = P ({H}) = p
P (X = 2) = P ({TH}) = (1 p)p
P (X = 3) = P ({TTH}) = (1 p)2 p
..
.
P (X = n) = P ({TT· · · TH}) = (1 p)n 1
p
and
1
X 1
X p
P (X = n) = (1 p)n 1
p= = 1.
n=1 n=1
1 (1 p)
5
Outline
• Random Variables
• Discrete Random Variables
• Expected Value
• Expectation of a Function
• Variance
• Bernoulli and Binomial Random Variables
• Poisson Random Variables
• Geometric Random Variables
6
Discrete Random Variables
p(a) = P (X = a).
7
Example
Example: Consider a RV Y with
8 1
>
> 0 with probability 8
>
<1 3
with probability 8
Y = 3
>
> 2 with probability
>
: 8
1
4 with probability 8
p(y)
3
8
1
8
y
0 1 2 4 8
Example
Problem: The PMF of a RV X is given by
c x
p(x) = , x = 0, 1, 2, . . .
x!
where is some positive number, and p(x) = 0 for other values. 1) Find the
value of c; 2) Find P (X = 0) and P (X > 2).
and therefore c = e .
2)
0
e
P (X = 0) = p(0) = =e
0!
and
1
X 2
X 2
e
P (X > 2) = p(x) = 1 p(x) = 1 e e
x=3 x=0
2
9
Cumulative Distribution Function
The cumulative distribution function (CDF) of a discrete RV X, denoted by
FX (a) or simply F (a), can be expressed in terms of PMF p(x) by
X
F (a) = p(x).
xa
Later we will generalize CDF to continuous RV’s. Indeed, note that PMF only
exists for discrete RV’s, but CDF can be defined for any RV.
If Y is a discrete RV, then its CDF is a step function. For example, if Y has
PMF given by
1 3 3 1
p(0) = , p(1) = , p(2) = , p(4) =
8 8 8 8
then its CDF is given by
8
>
>0 a < 0
>
>
>
> 1
<8 0 a < 1
F (a) = 21 1 a < 2
>
>
>
> 7
2a<4
>
> 8
:1 a 4
10
Cumulative Distribution Function
p(y) F (y)
1
3 7
8
8
1
2
1
8 1
y 8
y
0 1 2 4 0 1 2 4
11
Outline
• Random Variables
• Discrete Random Variables
• Expected Value
• Expectation of a Function
• Variance
• Bernoulli and Binomial Random Variables
• Poisson Random Variables
• Geometric Random Variables
12
Expected Value
1 1 1
E[X] = 0 · +1· = .
2 2 2
If the PMF of X is p(0) = 13 , p(1) = 23 , then
1 2 2
E[X] = 0 · +1· = .
3 3 3
13
Example
Suppose X is the outcome when we roll a fair die. Then the expectation of X
is
X6 6
1X 7
E[X] = i · p(i) = i=
i=1
6 i=1 2
14
Outline
• Random Variables
• Discrete Random Variables
• Expected Value
• Expectation of a Function
• Variance
• Bernoulli and Binomial Random Variables
• Poisson Random Variables
• Geometric Random Variables
15
Expectation of Function
Given a RV X with PMF p(x), we can also calculate the expectation of some
function g of X. In particular, we have
X
E[g(X)] = g(x) · p(x)
x: p(x) 0
Example: Suppose X has PMF given by p(0) = p(1) = 12 , and g(x) = x2 . Then
1
E[g(X)] = g(0) · p(0) + g(1) · p(1) =
2
In general, the expectation
X
E[X n ] = xn · p(x)
x: p(x) 0
• Random Variables
• Discrete Random Variables
• Expected Value
• Expectation of a Function
• Variance
• Bernoulli and Binomial Random Variables
• Poisson Random Variables
• Geometric Random Variables
17
Variance
Two RV’s can have the same expectation, but behave (quite) di↵erently in their
distributions. For example, consider RV’s Y and Z, where the pmf for Y is
pY (1) = pY ( 1) = 0.5 and the pmf for Z is pZ (100) = pZ ( 100) = 0.5. Both
Y and Z have the same expectation, i.e. E[Y ] = E[Z] = 0, but obviously they
have very di↵erent spread of distributions.
7
Another example: If X denotes the outcome of rolling a fair die, then E[X] = 2
and
X6
91
E[X 2 ] = i2 p(i) = ,
i=1
6
and therefore
✓ ◆2
91 7 35
Var(X) = E[X 2 ] E[X]2 = =
6 2 12
19
Outline
• Random Variables
• Discrete Random Variables
• Expected Value
• Expectation of a Function
• Variance
• Bernoulli and Binomial Random Variables
• Poisson Random Variables
• Geometric Random Variables
20
Bernoulli and Binomial RV
Bernoulli RV (success and failure):
(
1 w.p. p
X=
0 w.p. 1 p
Binomial RV: Now suppose that we do n independent trials (each time being
success w.p. p and failure w.p. 1 p). Let X represent the number of successes
in the n trials. Then X is said to be a binomial RV with parameter (n, p),
denoted by X ⇠ Binomial(n, p); in particular the case of (1, p) is Bernoulli.
n
PMF: p(i) = i pi (1 p)n i
where 0 i n; the shape of PMF is interesting
21
Outline
• Random Variables
• Discrete Random Variables
• Expected Value
• Expectation of a Function
• Variance
• Bernoulli and Binomial Random Variables
• Poisson Random Variables
• Geometric Random Variables
22
Poisson and Geometric RV
Variance: Var(X) = .
Geometric RV: Perform independent trials until a success occurs. The number
of times we do the trials is a Geometric RV.
1 p
Expectation: E[X] = p1 . Variance: Var(X) = p2 .
23