0% found this document useful (0 votes)
20 views11 pages

Assignment 3

assignment of python and more

Uploaded by

Rohit
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)
20 views11 pages

Assignment 3

assignment of python and more

Uploaded by

Rohit
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/ 11

Assignment 3

Q1. In the Advanced Placement (AP) programs of high schools, during the senior year 40% of
students study subject D, 45% study subject E, and 50% study subject F. It is also known that
10% study both subjects D and F, 20% study both subjects E and F, 15% study subject D but
neither subject E nor F. Only 5% of the students study all three subjects.

(a) Define the random variable X as the number subjects taken (out of D, E, and F) by AP
students during the senior year. Obtain the probability mass function and cumulative distribution
function of X and represent it in the tabular form.

(b) Obtain the expected value of X.

Ans.

(a) P(D)= 40%


P(E)= 45%
P(F)= 50%
P(D ∩ F)= 10%

P(E ∩ F)= 20%


P(D ∩ Ec ∩ Fc)= 15%
P(D ∩ E ∩ F)= 5%

X=3
P(D ∩ E ∩ F)= 0.05 = P(X=3)
X=2
P(D ∩ Ec ∩ Fc)= P(D) – P(D∩E)-P(D∩F)+P(D∩E∩F)
0.15 = 0.40-X-0.10+0.05
X=0.20

P(X=2)= P(D ∩ E ∩ Fc)+ P(D ∩ Ec ∩ F)+ P(Dc ∩ E ∩ F)


= 0.15+0.05+0.15 = 0.35

X=1
Given P(D ∩ Ec ∩ Fc)= 0.15
P(E∩Dc∩Fc) = P(E) - P(E∩D∩Fc) - P(E∩F∩Dc) - P(E∩F∩D)
= 0.45 - 0.15 - 0.05 = 0.1
P(F∩Ec∩Dc) = P(F) - P(F∩D∩Ec) - P(F∩E∩Dc) - P(F∩E∩D)
= 0.50 - 0.5 - 0.5 - 0.15 = 0.25
P(X=1) = 0.15 + 0.1 + 0.25 = 0.5

X= 0
P(X=0)= 1- P(DuEuF)
= 1-[P(D)+P(E)+P(F)-P(D∩E)-P(D∩F)-P(E∩F)+P(D∩E∩F)]
= 1-[0.40+0.45+0.50-0.20-0.10-0.20+0.05]
= 1 - 0.90
= 0.10

PμF=
X PμF
0 0.10
1 0.5
2 0.35
3 0.05

CDF=
X CDF
0 0.10
1 0.10+0.5 = 0.6
2 0.6+0.35 = 0.95
3 0.95+0.05 = 1.0

(b). E[x] = 0∑3 x*P[X=x]


= 0*0.10+1*0.5+2*0.35+3*0.05
= 1.35
Q.2 Suppose that X and Y have a discrete joint distribution for which the probability distribution
is defined as follows: P(x,y) = c |x+y| for x =-2,-1, 0, 1, 2 and y =-2,-1, 0, 1, 2; = 0 otherwise.
(a) Determine the value of the constant c.
(b) Compute P(X = 0 and Y =−2)
(c) Compute P(X=1)
(d)Compute P(|X−Y|≤1)
(e)Compute the conditional probability distribution ,P(Y|X=1).
(f)Obtain the conditional mean of Y given X=1, that is, E(Y|X= 1)

Ans.
(a). Sum of probabilities = 1

X=-2 ∑ 2 Y=-2 ∑2 P(X,Y)= 1= C. ∑|X+Y|

X/Y -2 -1 0 1 2

-2 4 3 2 1 0

-1 3 2 1 0 1

0 2 1 0 1 2

1 1 0 1 2 3

2 0 1 2 3 4
Sum(X+Y)= 4+3+2+1+3+2+1+1+2+1+1+2+1+1+2+3+1+2+3+4= 40

Henceforth, C.40 = 1
C= 1
40

(b). P(X=0, Y=-2)


C.|0+(-2)|= 1/40 (2)= 1/20

(c). P(X=1)
P(X=1) = y=-2∑2 P(X=1,Y=y)
= C[(1+(-2))+(1+(-1))+(1+0)+(1+1)+(1+2)]
= 1/40 (1+0+1+2+3)
= 7/40

(d). P(|X-Y|≤1)

|X-Y| -2 -1 0 1 2

-2 0 1 2 3 4

-1 1 0 1 2 3

0 2 1 0 1 2

1 3 2 1 0 1

2 4 3 2 1 0
Pairs are (-2,-1), (-1,-2), (-2,-2), (-1,-1), (-1,0), (2,2), (0,-1), (0,0), (0,1), (1,0), (1,1), (1,2), (2,1)
Referring to the above pairs we will take the value from the table.
P(|X-Y|≤1)= C. ∑|X+Y|
= 1/40 (4+3+2+3+1+1+0+1+1+2+3+3+4)
= 1/40 (28)
= 0.7

(e). P(Y|X =1)


P(Y=y | X=1)= P(X=1. Y=y)/ P(X=1)
P(X=1)= 7/40
P(X=1, Y=-2)= 1/40 (1)= 1/40
P(X=1, Y=-1)= 1/40 (0)= 0
P(X=1, Y=0)= 1/40 (1)= 1/40
P(X=1, Y=1)= 1/40 (2)= 1/20
P(X=1, Y=2)= 1/40 (3)= 3/40

Conditional Probabilities:-
P(Y=-2|X=1)= 1/7
P(Y=-1|X=1)= 0
P(Y=0|X=1)= 1/7
P(Y=1|X=1)= 2/7
P(Y=2|X=1)= 3/7

(f). X=1 E(Y|X=1)


E(Y|X=1)= y=-2∑2 y.P(Y=y|X=1)
= -2(1/7)+0+0+1(2/7)+2(3/7)
= 6/7

Q3.

Ans.

(a) P(X=2)
P(X=2)= ∑P(X=2,Y=y)
= 0.05+0.06+0.09+0.04+0.03
= 0.27

(b) P(Y≥2)= ∑P(X=x,Y=2,3,4)


=(0.06+0.01+0.01)+(0.12+0.05+0.02)+(0.09+0.04+0.03)+(0.03+0.03+0.04)
= 0.53

(c) P(X≤2 andY≤2)= ∑P(X=0,1,2 andY=0,1,2)


=(0.08+0.07+0.06)+(0.12+0.06+0.10)+(0.09+0.05+0.06)
= 0.69
(d) P(X=Y)= P(X=0,Y=0)+P(X=1,Y=1)+P(X=2,Y=2)+P(X=3,Y=3)
= 0.08+0.10+0.09+0.03
= 0.3

(e) P(X>Y)= P(X=1,Y=0)+P(X=2,Y=0,1)+P(X=3,Y=0,1,2)


=0.06+(0.05+0.06)+(0.02+0.03+0.03)
= 0.25

Q4. Suppose that X and Y have a discrete joint distribution for which the joint p.f. is defined as
follows:

(a)Determine the marginal p.f.s of X and Y.


(b) Show that X and Y not independent.
(c) Obtain the conditional distributions of Y given X = 0, X = 1 and X =2 and plot the three
distributions.
(d) Obtain the conditional means of Y given X = 0, X = 1 and X =2.

Ans.

(a).

f(x,y) = 1/30 (x+y) for x = 0,1,2 and y = 0,1,2,3;


f(x,y) = 0 otherwise,

Marginal p.f of X

The marginal p.f. of X, denoted by fX(x), is found by summing the joint p.f. f(x,y) over all possible
values of y:

fX(x) = y=0∑3 f(x,y)

For x =0
fX(0)= y=0∑3 f(0,y) = y=0∑3 1/30 (0+y)= 1/30 (0+1+2+3)= 6/30 = 1/5

For x=1
fX(1)= y=0∑3 f(1,y) = y=0∑3 1/30 (1+y)= 1/30 (1+2+3+4)= 10/30 = 1/3

For x= 2
fX(2)= y=0∑3 f(2,y) = y=0∑3 1/30 (2+y)= 1/30 (2+3+4+5)= 14/30 = 7/15
The marginal p.f. of X is:
1/5, for x=0
fX(x)= 1/3, for x=1
7/15, for x=2

Marginal p.f. of Y

The marginal p.f. of Y, denoted by fY(y), is found by summing the joint p.f. f(x,y) over all possible
values of x:

fY(y) = x=0∑2 f(x,y)

For y =0
fY(0)= x=0∑2 f(x,0) = x=0∑2 1/30 (0+x)= 1/30 (0+1+2)= 3/30 = 1/10

For y=1
fY(1)= x=0∑2 f(x,1) = x=0∑2 1/30 (1+x)= 1/30 (1+2+3)= 6/30 = 1/5

For y= 2
fY(2)= x=0∑2 f(x,2) = x=0∑2 1/30 (2+x)= 1/30 (2+3+4)= 9/30 = 3/10

For y= 3
fY(3)= x=0∑2 f(x,3) = x=0∑2 1/30 (3+x)= 1/30 (3+4+5)= 12/30 = 2/5

The marginal p.f. of Y is:


1/10, for y=0
fY(y)= 1/5, for y=1
3/10, for y=2
2/5, for y=3

(b).For this we will be requiring to verify the joint probability mass function f(x,y) can be factored
as the product of the marginal p.f.s fX(x) and fY(y). That is, X and Y are independent if and only
if:

F(x,y) = fX(x)fY(y) for all x and y

From part (a), we know the marginal p.f.s of X and Y, therefore the joint p.f. is given by:

f(x,y) = 1/30(x+y), for x=0,1,2 and y= 0,1,2,3.


Now we will check the independence by using various combinations:

1. x=0, y=0
f(0,0)= 1/30 (0+0)= 0

fX(0)fY(0)= 1/5.1/10= 1/50

Since 0 ≠ 1/50, f(x,y) ≠ fX(x)fY(y) for x=0, y=0.

This already shows that X and Y are not independent.

(c). To obtain the conditional distribution of Y given a specific value of X, we will be using the
method of conditional distribution mass function:

f Y|X(y|x) = f(x,y)/fX(x) for each value of y =0,1,2,3

For Y given X=0

The marginal p.f. of X = 0 is fX(0)= 1/5

Therefore:-
fY|X(0|0) = f(0,0)/ fX(0)= 0/1/5 = 0
fY|X(1|0) = f(0,1)/ fX(0)= 1/30.(0+1)/1/5 = (1/30)/(1/5)= 1/6
fY|X(2|0) = f(0,2)/ fX(0)= 1/30.(0+2)/1/5 = (2/30)/(1/5)= 2/6= 1/3
fY|X(3|0) = f(0,3)/ fX(0)= 1/30.(0+3)/1/5 = (3/30)/(1/5)= 3/6= 1/2

For Y given X=1

The marginal p.f. of X = 1 is fX(1)= 1/3

Therefore:-
fY|X(0|1) = f(1,0)/ fX(1)= 1/30.(0+1)/1/3 = (1/30)/(1/3)= 1/10
fY|X(1|1) = f(1,1)/ fX(1)= 1/30.(1+1)/1/3 = (2/30)/(1/3)= 1/5
fY|X(2|1) = f(1,2)/ fX(1)= 1/30.(2+1)/1/3 = (3/30)/(1/3)= 3/10
fY|X(3|1) = f(1,3)/ fX(1)= 1/30.(3+1)/1/3 = (4/30)/(1/3)= 2/5

For Y given X=2

The marginal p.f. of X = 2 is fX(2)= 7/15

Therefore:-
fY|X(0|2) = f(2,0)/ fX(2)= 1/30.(0+2)/7/15 = (2/30)/(7/15)= 1/7
fY|X(1|2) = f(2,1)/ fX(2)= 1/30.(1+2)/7/15 = (3/30)/(7/15)= 3/14
fY|X(2|2) = f(2,2)/ fX(2)= 1/30.(2+2)/7/15 = (4/30)/(7/15)= 2/7
fY|X(3|2) = f(2,3)/ fX(2)= 1/30.(3+2)/7/15 = (5/30)/(7/15)= 5/14
(d). For the conditional mean of Y given X=x is defined as:
E[Y|X = x]= y∑ y.fY|X(y|x)

As we have already proven the conditional distributions of Y given X = 0, X = 1, and X= 2 from


part c.

1. First condition mean of Y given X = 0

E[Y|X=0] = 0 . 0 +1 . 1/6 + 2 . 1/3 + 3 . ½ = 1/6+2/3+3/2 = 7/3

2. Second condition mean of Y given X = 1

E[Y|X=1] = 0 . 1/10 +1 . 1/5 + 2 . 3/10 + 3 . 2/5 = 1/5+6/10+6/5 = 2

3. Third condition mean of Y given X = 2

E[Y|X=2] = 0 . 1/7 +1 . 3/14 + 2 . 2/7 + 3 . 5/14 = 3/14+4/7+15/14 = 26/14

So here we have all the values:-


E[Y∣X=0]=2.33

E[Y∣X=1]=2.00

E[Y∣X=2]=1.857
Q5. Consider the directed arc graphical model below for events A,B,...,E A D C E B

(a) Based on the dependence structure implied by the graphical model, write down the
factorization of the joint probability of events A,B,C,D,E and F.

(b) Based on the dependence structure implied by the graphical model, are there any
independent events ? Please explain your reasoning.

(c) Based on the dependence structure implied by the graphical model, which are the events
conditionally independent of event B ? Please explain your reasoning.

(d) Based on the dependence structure implied by the graphical model, which are the events
conditionally independent of event E ? Please explain your reasoning.

Ans.

(a) The factorization for the joint probability P(A, B, C, D, E) is:-

P(A, B, C, D, E) = P(A) * P(D) * P(C | A, D) * P(B | D, C) * P(E | C, B)

Here, A and D are the parent nodes, and their probabilities are P(A) and P(D), respectively. C is
a child node of A and D, represented by P(C∣A,D). B is a child node of C and D, given by
P(B∣C,D). Lastly, E is a child node of C and B, represented by P(E∣C,B).

(b) Regarding the independence of events based on the graphical model's dependence
structure, A and D do not share a common parent node, nor is there any direct or indirect
connection between them. Therefore they are independent.

(c) Examining the dependence structure, we find that certain events are conditionally
independent of event B. From the factorization, we see that P(B∣C,D) indicates that B is
conditionally dependent on C and D. Similarly, P(E∣C,B) shows that B and E are conditionally
dependent. Therefore, D and E are not conditionally independent of B due to their direct or
indirect dependencies. However, A is conditionally independent of B given C and D.
P(B|C∩D) → B is conditionally dependent on C and D

P(E|C∩B) → B and E are conditionally dependent events

(d)

From the factorization event:


P(E|C∩B) → B and E are conditionally dependent events

Considering the dependence structure with respect to event E, we note that P(E∣C,B) indicates
that E is conditionally dependent on both B and C. Consequently, events A and D are
conditionally independent of event E when conditioned on C and B. Therefore, A and D are
conditionally independent of event E.

You might also like