0% found this document useful (0 votes)
23 views29 pages

Lecture Set 4

Uploaded by

berkeal260
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views29 pages

Lecture Set 4

Uploaded by

berkeal260
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Lecture Set 4

DNSC 6311
Stochastic Foundations: Probability

Korel Gundem

The George Washington University


Department of Decision Sciences

1 / 29
Lecture Outline

1. Conditional independence of random variables.

2. Measuring linear dependence.

3. Covariance and correlation.

4. Variance of sum of dependent variables.

5. Probability models: Discrete models.

6. Discrete Uniform model.

7. Bernoulli trials and Binomial model.

8. Applications of the Binomial model.

2 / 29
Conditional Independence of RVs
▶ Let X , Y and Z be random variables. X and Y are
conditionally independent given Z if

PX ,Y |Z (x, y |z) = PX |Z (x|z)PY |Z (y |z)

for all x, y and z.

▶ An equivalent definition is

PX |Z ,Y (x|z, y ) = PX |Z (x|z)

for all x, y and z.

▶ We can represent this with a probability diagram where

PX ,Y ,Z (x, y , z) = PZ (z)PX |Z (x|z)PY |Z (y |z).

3 / 29
Example: Conditional Independence
▶ Consider random variables X , Y and Z with joint distribution:

Z=0 Z=1
Y=0 Y=1 Y=0 Y=1
X=0 0.405 0.045 X=0 0.125 0.125
X=1 0.045 0.005 X=1 0.125 0.125
▶ From the table we have PX ,Y ,Z (0, 0, 0) = 0.405 and
PX ,Y ,Z (0, 0, 1) = 0.125

▶ We have PZ (0) = 0.5, PX ,Y |Z (0, 0|0) = 0.405/0.5 and


PX |Z (0|0) = PY |Z (0|0) = (0.405 + .045)/0.5 implying

PX ,Y |Z (0, 0|0) = PX |Z (0|0)PY |Z (0|0) = 0.81.

Similarly, we can show that


PX ,Y |Z (x, y |z) = PX |Z (x|z)PY |Z (y |z) for all x, y and z.
4 / 29
Linear Dependence
▶ How do we measure linear dependence between two random
variables X and Y ?

▶ Let µX = E [X ] and µY = E [Y ] then covariance of X and Y is

Cov (X , Y ) = E [(X − µX )(Y − µY )] = E (XY ) − µX µY .

▶ What does it mean ?

5 / 29
Linear Independence
▶ If X and Y are independent then Cov (X , Y ) = 0 ⇒ no linear
relationship.
▶ In general Cov (X , Y ) = 0 does not imply independence, but
there are two exceptions: (i) X and Y are Bernoulli RVs (ii)
X and Y has a bivariate normal distribution.
▶ If X and Y are Bernoulli and Cov (X , Y ) = 0 then
E [XY ] = E [X ]E [Y ].
Note that for Bernoulli RVs E [X ] = Pr [X = 1] and
E [Y ] = Pr [Y = 1]. Also,
XX
E [XY ] = xy Pr [X = x, Y = y ],
x y

which is nonzero only when x = y = 1.


Therefore E [XY ] = Pr [X = 1, Y = 1] and
Pr [X = 1, Y = 1] = Pr [X = 1]Pr [Y = 1].
6 / 29
Covariance of Binary RVs
▶ In general for binary RVs we have

Cov (X , Y ) = Pr [X = 1, Y = 1] − Pr [X = 1]Pr [Y = 1].

If Cov (X , Y ) > 0 then

Pr [X = 1, Y = 1] > Pr [X = 1]Pr [Y = 1] and

Pr [Y = 1|X = 1] > Pr [Y = 1].


Higher value of X makes a higher value of Y more likely.

▶ In this case we also say that X and Y are associated.

Similarly, if Cov (X , Y ) < 0 then

Pr [Y = 1|X = 1] < Pr [Y = 1].

▶ Market basket analysis.


7 / 29
Covariance of Discrete RVs

▶ Consider RVs X and Y which are the returns of two stocks


with the joint probability distribution
Y = 5% Y = 10% Y = 15%
X = −20% 0.05 0.05 0.05
X = 10% 0.10 0.10 0.05
X = 30% 0.30 0.10 0.05
X = 50% 0.10 0.05 0

▶ E [X ] = 20.5 which implies an expected return of 20.5


percent. Similarly, we can obtain E [Y ] = 8.

▶ Also we have V [X ] = 444.75 and V [Y ] = 13.5.

8 / 29
Discrete Example
▶ We can obtain the covariance as (See R Code)

Cov (X , Y ) = (−20)(5)(0.05) + (−20)(10)(0.05) + · · · · · · +


(50)(10)(0.05) + 0 − (20.5)(8) = −24.

▶ Note that the value of covariance does not tell us much about
the strength of linear relationship.

▶ We can define the correlation between X and Y as

Cov (X , Y )
ρXY = p ,
V [X ]V [Y ]
such that −1 < ρXY < 1.
In our example we can obtain
−24
ρXY = √ = −0.30973.
444.75 × 13.5
9 / 29
R Code for Computations
R code: Discrete Joint Conditional Computations 3 Correlation.R
2020-09-22

x = c(-20, 10, 30, 50)


y = c(5, 10, 15)

col1 = c(0.05, 0.10, 0.30, 0.1)


col2 = c(0.05, 0.10, 0.10, 0.05)
col3 = c(0.05, 0.05, 0.05, 0)

prob = cbind(col1, col2, col3)

px = c(sum(prob[1, ]), sum(prob[2, ]), sum(prob[3, ]), sum(prob[4, ]))


mu_x = sum(x * px)
sig2_x = sum((x - mu_x) ^ 2 * px)

py = c(sum(prob[, 1]), sum(prob[, 2]), sum(prob[, 3]))


mu_y = sum(y * py)
sig2_y = sum((y - mu_y) ^ 2 * py)

# A nice trick of using outer product function

xy = outer(x - mu_x, y - mu_y)


cov_xy = sum(xy * prob)

cor_xy = cov_xy / (sig2_x * sig2_y) ^ 0.5

10 / 29
Properties of Covariance and Variance
▶ Cov (X , X ) = V [X ]

▶ Cov (X , Y ) = Cov (Y , X )

▶ Cov (a + bX , c + dY ) = bdCov (X , Y )

▶ An important property is

V [X + Y ] = V [X ] + V [Y ] + 2Cov (X , Y )

V [aX + bY ] = a2 V [X ] + b 2 V [Y ] + 2abCov (X , Y ).
▶ The above can be generalized as

Xn n
X n X
X
2
V[ ai Xi ] = ai V [Xi ] + 2 ai aj Cov (Xi Xj )
i=1 i=1 i=1 j<i

11 / 29
Application: Portfolio Management
▶ Consider the two securities with returns X and Y in our
example.

▶ Assume that we want to form a portfolio by determining the


fraction of money invested in each security.

▶ The return of the portfolio will be given by


P = wX + (1 − w )Y where w is the fraction of money
invested in the first security.

▶ What is expected portfolio return ?

E [P] = wE (X ) + (1 − w )E (Y )

▶ What is portfolio variance ?

V [P] = w 2 V [X ] + (1 − w )2 V [Y ] + 2w (1 − w )Cov (X , Y ).

▶ Different choices of w give different portfolios.


12 / 29
Computing Portfolio Risk
▶ If we choose a portfolio with equally allocating our money
between the two securities, that is, w = 0.5 then
E [P] = 0.5 × 20.5 + 0.5 × 8 = 14.25
V [P] = 0.25 × 444.75 + 0.25 × 13.5 + 2 × 0.25 × (−24) =
102.5625.

▶ The above can be generalized to K securities with returns


X1 , . . . , XK with

P = w1 X1 + w2 X2 + · · · · · · + wK XK ,

where w1 + w2 + · · · · · · + wK = 1.
By choosing different (w1 , w2 , . . ., wK ) we obtain different
portfolios.

13 / 29
Discrete Probability Models

There are many probability models (distributions) that are used to


describe uncertainty about random variables such as:
▶ number of times the market will go up during the next ten
days;

▶ number of days until you sell a rare item on line on ebay;

▶ number of clicks a webpage receives during a 1 minute


interval.

These probability models can be motivated from certain random


experiments that arise in real situations.
They assign probabilities to a random variable X using a specific
functional form for Pr (X = x).

14 / 29
Discrete Uniform Model
For any two integers a ≤ b, suppose that the value of a random
variable X is equally likely to be each of the integers a, . . . , b.
X is called the discrete uniform random variable and has the
probability mass function:
1

 b − a + 1 for x = a, . . . , b


Pr (X = x) = P(x) =


0 otherwise

▶ The above is the same as randomly selecting a number


between a and b.
▶ Note that a discrete uniform distribution cannot be assigned
to an infinite sequence of possible integers. Why?
▶ The above P(x) is also known as the uniform model on
integers.
15 / 29
Discrete Uniform Random Variable

0.020
0.10
0.08

0.015
0.06
P(X=x)

P(X=x)

0.010
0.04

0.005
0.02

0.000
0.00

1 2 3 4 5 6 7 8 9 10 1 4 7 10 14 18 22 26 30 34 38 42 46 50

X X

Pk k(k + 1) Pk 2 k(k + 1)(2k + 1)


▶ Recall the properties of sums: i=1 i= , i=1 i =
2 6
(can be shown by induction).
a+b (b − a + 1)2 − 1
▶ We can show that E (X ) = and V (X ) = .
2 12

16 / 29
Discrete Probability Models: Binomial Model

▶ Bernoulli trials

Consider an experiment where the outcome is described by


the Bernoulli random variable X , that is,
(
1 with probability p
X =
0 with probability (1 − p)

We have already shown that E [X ] = p and V [X ] = p(1 − p).

▶ Now consider an experiment which consists of n independent


Bernoulli trials where the probability of the outcome 1 (say,
success) and therefore of 0 is constant from one trial to
another.
▶ This is known as the binomial experiment.

17 / 29
Binomial Random Variable
▶ What are some examples ?

- Sampling with replacement versus without replacement

▶ The binomial RV X is the number of successes in the


binomial experiment with n trials.
X is the outcome of the binomial experiment, that is, X can
take values x = 0, 1, . . . , n.

▶ What is the probability distribution of X ?


 
n x
Pr (X = x) = P(x) = p (1−p)n−x where x = 0, 1, . . . , n.
x

Why ?
Pn n
p x (1 − p)n−x = 1 (via binomial

▶ We can show that x=0 x
theorem)
18 / 29
Binomial Random Variable

Binomial probability distribution can exhibit skewed or symmetric


behavior depending on its parametrization of (p, n).

0.08
0.8

0.06
0.6

0.04
0.4

0.02
0.2

0.00
0.0

0 1 2 3 4 5 6 30 40 50 60 70

n=10,p=0.1 n=100,p=0.5

19 / 29
Acceptance Sampling
▶ In quality control we want to decide whether to accept or
reject a group of items (called lot) based on specified quality
characteristics.

▶ Acceptance sampling is a statistical method that enables us to


accept or reject a lot by inspecting a sample of items from it.

▶ There are risks associated with this decision:

- rejecting a good quality lot: producer’s risk


- accepting a bad quality lot: consumer’s risk.

▶ How much to inspect and how to reject/accept a lot ?

▶ Sampling plan: consists of a sample size n and an acceptance


criterion c which is the maximum number of defectives that
can be found in the sample for acceptance of a lot.

20 / 29
Acceptance Sampling: Example
▶ Assume that a sampling plan established as n = 15 and c = 0,
that is, 15 items will be inspected and the lot will be accepted
if 0 defectives are found.
What is the probability that the lot will be accepted if 5% of
the items are defective ?

▶ Inspection can be thought as a Binomial experiment with


n= 15 and p = 0.05.
We want to obtain the probability of accepting the lot, that is,
probability of 0 defectives in the inspection
15!
P(X = 0) = 0.050 (1 − 0.05)15−0 = 0.4633
0! (15 − 0)!

You can use R function dbinom(x, n, p)=dbinom(0, 15,


0.05)=0.4633.

21 / 29
Example

▶ Note that if the lot has 1% defectives, then the probability of


accepting the lot becomes dbinom(0, 15, 0.01)= 0.8601.

▶ What if we have a plan where n = 15 and c = 2 ?

Then the probability of accepting the lot is probability of


having less than or equal to 2 defectives, that is, P(X ≤ 2).
For 1% defectives, we can compute this in R as
pbinom(2,15,0.01)= 0.9996.
For 5% defectives the probability becomes
pbinom(2,15,0.05)= 0.9638.

▶ Operating Characteristic (OC) curve of a sampling plan.

22 / 29
Operating Characteristic Curve
The plot of probability of acceptance versus percent defective is
known as the operating characteristic (OC) curve for the sampling
plan.

OC Curve:c=0,n=15 OC Curve:c=2,n=15
1.0

1.0
0.8

0.8
Probability of Acceptance

Probability of Acceptance
0.6

0.6
0.4

0.4
0.2

0.2
0.0

0.0

0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0

p p

23 / 29
Binomial Trees in Stock Market
Binomial model is used for evolution of stock prices in the market
assuming that the market is up (down) on a given day is a
Bernoulli random variable X = 1(0).
Under the random walk hypothesis, the behavior of the market on
any day is independent of the other days and this behavior can be
represented via a probability tree of Bernoulli Trials.
Example: Assume that we observe the market for 3 days, then we
consider a binomial random variable X where n = 3
X ∼ Binom(3, p)

p (1-p)

p (1-p) p (1-p)

p (1-p) p (1-p) p (1-p) p (1-p)


24 / 29
Back to the GE Stock
Recall that earlier we concluded that the GE stock follows a
discrete Random Walk behaviour.
Then the binomial model should be appropriate for modeling the
number of ups of GE stock over n trading days.
Relative Frequencies of No. of Ups of GE stock over 10 Trading Days
0.25
0.20
Relative Frequency

0.15
0.10
0.05
0.00

0 2 4 6 8 10

25 / 29
Fitting a Binomial Model GE Stock Data Behaviour
Assume that we consider a binomial model to the Number Ups of
the GE Stock over the n = 10 trading days.
Based on the data, we can estimate probability of Up on a given
day as the relative frequency of the number of up days over the
2363 trading days which is 0.4854.
Fitted Binomial Distribution to GE Stock
0.25
0.20
Relative Frequency

0.15
0.10
0.05
0.00

0 2 4 6 8 10

number of up days
26 / 29
R code: stock prices Binomial.R 2020-09-22

# FITTING BINOMIAL MODEL TO THE NUMBER OF UPS OF GE: 11/1/1993 - 4/33/2003

all=read.table("prices.txt",header=TRUE)
ge=all[,4]
n=length(ge)
dge=rep(0,n)
idge=rep(0,n)

for (t in 2:n){
dge[t]=ge[t]-ge[t-1]
if (dge[t]>0) {idge[t]=1} else {idge[t]=0}
}

stge=idge[2:n]
sind=cumsum(stge)
tm=seq(1,n-1,by=1)
mat=cbind(tm,sind)
z=mat[tm%%10==0,]

N=rep(0,236)
N[1]=z[1,2]
for (t in 2:236){
N[t]=z[t,2]-z[t-1,2]
}

freq=rep(0,11)
prob=rep(0,11)

x=seq(0,10,by=1)
for (i in 1:11) {
freq[i]=sum(N==i-1)
}
relfreq=freq/sum(freq)
p=sum(stge)/n

for (i in 1:11) {
prob[i]=dbinom(i-1,10,p)
}
z=x+0.125
plot(x,relfreq,xlab="number of up days",ylab="Relative Frequency",type="h",lwd="3",
col="red",main="Fitted Binomial Distribution to GE Stock")
lines(z,prob,type="h",col="blue",lwd=3)
27 / 29
Properties of the Binomial Distribution
▶ Note that the binomial random variable X can be written as
the sum
Pn of n Bernoulli RVs, say, Y1 , Y2 , . . . , Yn , that is,
X = k=0 Yk and we can obtain the mean as
Xn n
X
E [X ] = E [ Yk ] = E [Yk ] = np.
k=0 k=0

▶ We can show that

V [X ] = np(1 − p).
▶ Why ?

Using the sum of independent Bernoulli RVs:


n
X n
X
V [X ] = V [ Yk ] = V [Yk ] = np(1 − p).
k=0 k=0
28 / 29
R Computations for GE Stock Behavior
Using the binomial model with n = 10 and p = 0.4854 we can
anwser questions such as

▶ What is the probability that GE stock will be up more than 5


days in the next 10 days?
Pr (X > 5) = 1 − pbinom(5, 10, 0.4854) = 0.3416.

▶ What is the probability that GE stock will be up at most 3


days in the next 10 days?
Pr (X ≤ 3) = pbinom(3, 10, 0.4854) = 0.1969

▶ Compute the mean and the standard deviation of the number


of days the GE stock will be up in the next 10 days.
E (X ) = np = 10 × 0.4854 = 4.854 and
V (X ) = np(1 − p) = 10 × 0.4854 × (1 − 0.4854) = 2.4979.
29 / 29

You might also like