EGRE 337, Hw 2
Problem 1: An experiment consists in flipping a fair coin 4 times. The random variable X is
defined as the number of Heads.
(a) Plot the PMF of X.
Solution: The possible outcomes are
{HHHH, HT HH, HHT H, HT T H, HHHT, HT HT, HHT T, HT T T,
T HHH, T T HH, T HT H, T T T H, T HHT, T T HT, T HT T, T T T T }.
So pX (0) = 1/16, pX (1) = 4/16, pX (2) = 6/16, pX (3) = 4/16, pX (4) = 1/16.
(b) Find the expected value and variance of X.
Solution: E[X] = (0)(1/16) + (1)(4/16) + (2)(6/16) + (3)(4/16) + (4)(1/16) = 2
E[X 2 ] = (0)2 (1/16) + (1)2 (4/16) + (2)2 (6/16) + (3)2 (4/16) + (4)2 (1/16) = 5
V ar[X] = E[X 2 ] − (E[X])2 = 5 − 4 = 1
Problem 2: A continuous random variable X has the PDF shown below.
fX (x)
x
0 1 2
(a) Compute P (X < 1.1). (You will need to find the value of A first.)
Solution: The area under the PDF must be one, so A = 2.
Z 1.1 Z 1.1 Z 1.1
P (X < 1.1) = fX (x)dx = (−A)(x − 2)dx = (−2x + 4)dx =
1 1 1
= (−x2 + 4x)|1.1
1 = 3.19 − 3 = 0.19
(b) Find the expected value of the random variable Y = 2X − 2.
Solution:
Z 2 Z 2 Z 2
E[2X − 2] = (2x − 2)fX (x)dx = (2x − 2)(−2x + 4)dx = (−4x2 + 12x − 8)dx =
1 1 1
(−4x3 /3 + 12x2 /2 − 8x)|21 = (−32/3 + 48/2 − 16) − (−4/3 + 12/2 − 8) = 2/3 = 0.67
Problem 3: A continuous random variable X has the PDF shown below.
fX (x)
x
1 2 3
(a) Compute P (X > −0.5).
Solution: X only takes positive values, so P (X > −0.5) = 1.
(b) Find (plot or give expression for) the CDF of this random variable.
Solution: To find A, the
Rx
area under the PDF must be 1, so A = 0.5. The CDF is the anti-derivative
of the PDF. FX (x) = −∞ fX (u)du
Z x
x < 0; FX (x) = 0du = 0
−∞
Z x
0 < x < 1; FX (x) = Adu = Ax = 0.5x
0
Z 1
1 < x < 2; FX (x) = Adu = A = 0.5
0
Z 1 Z x
2 < x < 3; FX (x) = Adu + Adu = A + A(x − 2) = 0.5(x − 1)
0 2
Z 1 Z 3
3 < x; FX (x) = Adu + Adu = A + A = 2A = 1
0 2
fX (x)
0.5
x
1 2 3
(c) Find the mean and variance of this random variable.
Solution:
Z ∞ Z 1 Z 3
x2 1 x2 1−0 9−4
E[X] = xfX (x)dx = xAdx + xAdx = A |0 + A |32 = A +A = 3A = 1.5
−∞ 0 2 2 2 2 2
Z ∞ Z 1 Z 3
x3 1 x3 1−0 27 − 8 20 10
E[X 2 ] = x2 fX (x)dx = x2 Adx+ x2 Adx = A
|0 +A |32 = A +A =A =
−∞ 0 2 3 3 3 3 3 3
10 13
V ar(X) = E[X 2 ] − (E[X])2 = − 2.25 = = 1.083
3 12
Problem 4: Assume we have a random number generator that produces values of a random variable
X that is distributed according to a triangular distribution in the interval (0, 1) with a peak at zero.
But for our application we need random numbers Y that are uniformly distributed in the interval
(0, 1). We want to produce values of Y by defining a mapping defined by a function Y = g(X) and
applying this function to the values of X. Find the function g() that does the job.
Solution: Since we need to work with CDFs rather than PDFs, let’s find these.
0,
Rx
x<0
0, y < 0
2 x 2
FX (x) = 0 (2 − 2u)du = (2u − u )0 = 2x − x , 0 ≤ x ≤ 1 and FY (y) = y, 0 ≤ y ≤ 1
1, x>1
1, y > 1
fX (x) fY (y)
2
fX
(x)
=2
−2
x
x y
0 1 0 1
FX (x) FY (y)
2
x
x−
y
=
2
=
)
(x)
(y
1 1
Y
F X
F
x y
0 x = FX−1 (z) 1 0 y 1
To find the mapping from x to y we will use the relationship between the two CDFs: FY (y) =
FX (g −1 (y)). The easiest way to proceed is to call this common value z and solve for y:
( (
z = FX (x) = 2x − x2 z = 2x − x2
For 0 ≤ z ≤ 1, ⇒ ⇒ y = 2x − x2 = g(x)
z = FY (y) = y z=y
Problem 5
2.11
The CDF of a discrete random variable X is given as follows:
Problem 6
Problem 7
Problem 8
Problem 9
Problem 10