ECE 463/514 - Midterm Solution: Instructor

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Faculty of Engineering | Electrical and Computer Engineering

Engineering Office Wing Room 448 PO Box 1700 STN CSC Victoria BC V8W 2Y2 Canada
T 250-721-6036 | ecesec@uvic.ca |

ECE 463/514– Midterm Solution

Instructor
Dr. Sana Shuja
E-mail: sanashuja@uvic.ca

Question 1

On a given day, friendly talkative and social Shayla, calls one of her three
friends: Nicole (Friend 1), Nihmot (Friend 2), or Sonam (Friend 3). On any
given day if she calls Friend 1, next day she will call Friend 2 or Friend
3 with probability 0.25 and 0.45 respectively. If she calls Friend 2, next
day she will call Friend 1 or Friend 3 with probability 0.4 and 0.5
respectively. Similarly, if she calls Friend 3, next day she will call Friend
1 or Friend 2 with probability 0.25 and 0.4 respectively. For 1 ≤ i ≤ 3, let
Xn = i if Shayla on any day n calls friend i. Suppose that {X: n = 1, 2,...}
is a Markov chain, if the probability of calling a friend depicts Shayla’s
trust on a given friend, which friend do you think Shayla trusts the most
and why? (5 Points)

Solution:

0.3 0.4 0.25


𝐏 = |0.25 0.1 0.40| (2 Points)
0.45 0.5 0.35

s = [0.3062 0.2724 0.4215]T (2 Points)

Friend 3 (Sonam) is called 42.15 % of the time, so she is the most trusted
friend of Shayla. (1 Point)
MATLAB Code

P = [0.30 0.40 0.25; 0.25 0.10 0.40;0.45 0.50 0.35]


%Direct Method
I=eye(3);
A=P-I;
n=[0;0;1];
A(3,:)=1;
steady1=linsolve(A,n)
%Multiplication Method
P3000=P^3000;
steady2=P3000(:,1)
%Eigen Value
[x,v]=eig(P)
norm=sum(x(:,1))
steady3=x(:,1)/norm

Output:

P =

0.3000 0.4000 0.2500


0.2500 0.1000 0.4000
0.4500 0.5000 0.3500

steady1 =

0.3062
0.2724
0.4215

steady2 =

0.3062
0.2724
0.4215

x =

-0.5208 -0.8142 0.4606


-0.4633 0.4606 -0.8142
-0.7170 0.3536 0.3536

v =

1.0000 0 0
0 -0.0349 0
0 0 -0.2151

norm =

-1.7011

steady3 =

0.3062
0.2724
0.4215

Question 2

You as a network designer are told that the Throughput and efficiency of a
Network Buffer is 0.3550, and 0.8874 respectively. Based on the resources on
hand, load factor is bound to be at 1.043. Analyze the queue, and find:
a) The size B of the queue if the queue is empty 14.97% of time. (3
Points)
b) The transition Matrix P and steady state probabilities (round the
arrival and departure probabilities to 2 significant digits after the
decimal point). (5 Points)
c) Comment on the stability of the queue (comparison of steady state
probabilities). (1 Point)
d) What is the most obvious flaw in this queueing system? (1 Point)

Solution:

𝑁𝑎 (𝑜𝑢𝑡) 𝑇ℎ 𝑐(1−𝑏𝑠0 )
𝜂= = =
𝑁𝑎(ⅈ𝑛) 𝑎 𝑎
𝑇ℎ 0.3550
𝑎= = = 0.4
𝜂 0.8874
𝑎𝑑 𝑎(1 − 𝑐)
𝜌= =
𝑏𝑐 (1 − 𝑎)𝑐
0.4(1 − 𝑐)
1.043 =
(0.6)𝑐
𝑐 = 0.39

a)

(1 − 𝜌)
𝑠0 =
1 − 𝜌𝐵+1

(1 − 1.043)
0.1497 =
1 − 1.043(𝐵+1)

𝐵 = 4.98
𝐵≅5 (3 Points)

b)

P =

0.7560 0.2340 0 0 0 0
0.2440 0.5220 0.2340 0 0 0
0 0.2440 0.5220 0.2340 0 0
0 0 0.2440 0.5220 0.2340 0
0 0 0 0.2440 0.5220 0.2340
0 0 0 0 0.2440 0.7660
(2 Points)
s = [0.1497 0.1561 0.1628 0.1698 0.1770 0.1846]T (3 Points)

c) The probability of being at si+1 will always be greater than the


probability of being at si. hence the queue is unstable. (1 Point)
d) The arrival probability a is greater than the departure probability c.
(1 Point)

MATLAB Code
clc
clear all
a=0.4;
c=0.39;
d=1-c;b=1-a;f0=1-(a*d);f=1-a*d-b*c;
ad=a*d;
bc=b*c;
ro=ad/bc;
B=5;
P=transpose([1-
ad,ad,0,0,0,0;bc,f,ad,0,0,0;0,bc,f,ad,0,0;0,0,bc,f,ad,0;0,0,0,bc,f,ad;0,0,
0,0,bc,1-bc])
%Direct Method
I=eye(6);
A=P-I;
n=[0;0;0;0;0;1];
A(6,:)=1;
steady1=linsolve(A,n)

%Multiplication Method
P3000=P^3000;
steady2=P3000(:,1)

%Eigen Value
[x,v]=eig(P);
norm=sum(x(:,5));
steady3=x(:,5)/norm
%Performance Metrics
s0=steady1(1,1)
sb=steady1(6,1)
Th = c*(1-b*s0)
Nain= a
Nalost=sb*a*d
Eff=Th/a
L=sb*d
neu=ro*(1-(B+1)*ro^B+B*ro^(B+1));
den=(1-ro)*(1-ro^(B+1));
Qa = neu/den
W= Qa/Th

Output:

P =

0.7560 0.2340 0 0 0 0
0.2440 0.5220 0.2340 0 0 0
0 0.2440 0.5220 0.2340 0 0
0 0 0.2440 0.5220 0.2340 0
0 0 0 0.2440 0.5220 0.2340
0 0 0 0 0.2440 0.7660

steady1 =

0.1497
0.1561
0.1628
0.1698
0.1770
0.1846
steady2 =

0.1497
0.1561
0.1628
0.1698
0.1770
0.1846

steady3 =

0.1497
0.1561
0.1628
0.1698
0.1770
0.1846

s0 =

0.1497

sb =

0.1846

Th =

0.3550
Nain =

0.4000

Nalost =

0.0450

Eff =

0.8874

L =

0.1126

Qa =

2.6219

W =

7.3865
Question 3

Suppose you play the following game with a friend, both of you start with
$2. You flip a fair coin for $1 a flip. If the coin comes up heads, you win
$1. If the coin comes up tails, you lose $1. The game ends when either of
you do not have anymore money.
(a) Construct a Markov transition diagram and transition matrix for this
game considering a fair coin. (6 points)
(b) What is the initial probability vector when you start the game? (1
points)
(c) Construct the transition matrix for this game considering a biased coin
(choose an arbitrary bias for the coin yourself). (3 points)

Solution:

(a)

(3 Points)
P =

1.0000 0.5000 0 0 0
0 0 0.5000 0 0
0 0.5000 0 0.5000 0
0 0 0.5000 0 0
0 0 0 0.5000 1.0000

(3 Points)
b) Game starts when both friends have 2$ so,

s = [0 0 1 0 0]T (1 Point)

c)

P =

1 x 0 0 0
0 0 x 0 0
0 1-x 0 x 0
0 0 1-x 0 0
0 0 0 1-x 1
(3 Points)

You might also like