Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you please help to fix the pN calculation with the users in the queue and being served. function [ Ws , Wq , c
Can you please help to fix the pN calculation with the users in the queue and being served. function Ws Wq cutil, pdrop, pstate MMCQlambda mu c Nwait
Calculate the utilization factor
rho lambda mu;
rho lambda c mu;
Calculate the average number of customers in the queue
cbar rho c rhoc factorialc rho; Fix cbar calculation
Calculate pprobability of no customers in the system
pdenom sumc rho:c factorial:c c rhoc factorialc rho; Fix pdenom calculation
p pdenom;
Calculate the probability of zero customers in the system
Psumcrho:c factorial:ccrhoc factorialc rho;
pstate zeros Nwait ;
pstate p;
Calculate pN probability of having N customers in the system
for i :Nwait
pstatecic c i;
if i c
pstatei rhoi factoriali p;
else
pstatei rhoi factorialcci c p; Fix the pstate calculation
end
end
for i :Nwait
ci mini c;
if i c
pstatei ci c pstatei rho factoriali;
else
pstatei cci factorialci pstatei rhoi factorialc;
end
end
Normalize pstate to ensure probabilities sum to
pstate pstate sumpstate;
pN pstateNwait ; Probability of having N customers in the system
Calculate lambdaloss and lambdaeff
lambdaloss lambda pstateNwait ;
lambdaeff lambda lambdaloss;
Calculate Lq average number of customers in the queue
Lq sum:Nwait pstate;
Calculate Ls average number of customers in the system
Ls Lq lambdaeff mu;
Calculate the utilization
cbar Ls Lq;
cutil cbar c;
Calculate pdrop probability of a customer being dropped
pdrop pstateNwait ;
Calculate Ws and Wq
Ws Ls lambdaeff;
Wq Lq lambdaeff;
end c Total service time Total time
lambda ; arrival rate
mu ; service rate
c ; number of servers
Nwait
Call the MMCQ function with the given parameters
Ws Wq cutil, pdrop, pstate MMCQlambda mu c Nwait;
Ws Wq cutil, pdrop, pstate MMCQ;
Define a relative error function
relerror @x y absx y y;
Validate the results and print "PASS" or "FAIL" for each metric
if relerrorWs
fprintfWs f PASS
Ws;
else
fprintfWs f FAIL
Ws;
end
if relerrorWq
fprintfWq f PASS
Wq;
else
fprintfWq f FAIL
Wq;
end
if relerrorcutil,
fprintfcutil f PASS
cutil;
else
fprintfcutil f FAIL
cutil;
end
if relerrorpdrop,
fprintfpdrop f PASS
pdrop;
else
fprintfpdrop f FAIL
pdrop;
end
fprintfpstate: s
numstrpstate;
fprintfsumpstate: f
sumpstate;
Extra Tests: pstate
pstate should have Nwait probabilities
dispThe probability of being in state numstrNwait is numstrpstateNwait ;
dispThe probability of being in state is numstrpstate;
Check that the probabilities sum to
if abssumpstatee
dispThe probabilities sum to Test PASSED.;
else
dispThe probabilities do not sum to Test FAILED.;
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started