All problems
M/M/1 Expected Queue Length
Problem
Expected number of customers in an M/M/1 system (including the one in service):
E[N] = rho / (1 - rho) with rho = lam / mu.
Return -1.0 when rho >= 1, since the queue grows without bound.
Hint
This is the mean of a geometric distribution on the number in system.
Test cases
case 1
in: [1,2]
expected: 1
case 2
in: [2,4]
expected: 1
case 3
in: [1,4]
expected: 0.3333333333333333
case 4
in: [1,1]
expected: -1
Starter codePython
def mm1_expected_queue_length(lam, mu):
# Your code here
pass4 test cases · run your code against them in the editor