Topic4 DiscreteRV
Topic4 DiscreteRV
1
Random variables
2
Random variables
3
Discrete vs continuous random variables
4
Discrete probability distribution
Discrete probability distribution
5
Discrete probability distribution
∑ pX (x) = 1.
x
6
Coin tossing examples
7
Expectation (expected value)
E[g(X)] = ∑ g ( x ) pX ( x ) .
x
• Example:
8
Variance and standard deviation
• Example:
9
Laws of expectation and variance
• E(c) = c, V (c) = 0
10
Example
x 0 1 2 3
pX ( x ) .1 .3, .4, .2
11
Bivariate distribution
Bivariate distribution
∑ ∑ pX,Y (x, y) = 1.
x y
12
Example
X, Y are numbers of houses the first and second real estate agent
sells in a month,
x
0 1 2
0 .12 .42 .06
y 1 .21 .06 .03
2 .07 .02 .01
13
Marginal and conditional probability
• Example:
14
Marginal and conditional probability
P({X = x} ∩ {Y = y})
pY | X ( y | x ) = P ( Y = y | X = x ) =
P(X = x)
p (x, y)
= X,Y
pX ( x )
• Example:
15
Covariance and correlation
16
Example
x
0 1 2
0 .12 .42 .06
y 1 .21 .06 .03
2 .07 .02 .01
17
Laws of covariance and correlation
• Cov(X, c) = 0.
• Cov(X, X) = V(X).
18
Laws of covariance and correlation
19
Independence and correlatedness
σXY = ρXY = 0.
20
Sum and linear combinations of
random variables
Sum of random variables
21
Sum of random variables
V (X + Y ) = V (X ) + V (Y ).
22
Linear combination of random variables
23
Linear combination of random variables
is a linear combination of X1 , . . . , Xn .
• The expectation of variance of Z is given by
!
n n
E(Z) = E ∑ ai X i = ∑ ai E ( X i )
i=1 i=1
!
n n n n
V (Z) = V ∑ ai X i = ∑ a2i V (Xi ) + 2 ∑ ∑ ai aj Cov(Xi , Xj )
i=1 i=1 i=1 j>i
24
Linear combination of random variables
25
Example
Stock A Stock B
Expected return 7% 15%
Standard deviation 12% 25%
26
Example
27
Binomial distribution
Bernoulli trial
28
Bernoulli trial
29
Binomial distribution
30
Example
31
Binomial distribution
where
n n!
=
x x!(n − x)!
32
Compute binomial probabilities in R
Example in R code.
33
Shape of binomial distribution
X ∼ Bin(20, p)
0.20
0.15
0.15
0.15
0.10
pX(x)
pX(x)
pX(x)
0.10
0.10
0.05
0.05
0.05
0 5 10 15 20 0 5 10 15 20 0 5 10 15 20
x x x
34
Binomial distribution
35