Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-211

M/G/1 Pollaczek-Khinchine Queue Length

Problem

Expected queue length in an M/G/1 queue from the Pollaczek-Khinchine formula:

Lq = (lam^2 * var_service + rho^2) / (2 * (1 - rho)) with rho = lam * mean_service.

Return -1.0 when rho >= 1 and 0.0 for invalid inputs.

Hint

With exponential service this reduces to the M/M/1 result rho^2 / (1 - rho).

Test cases

case 1
in: [1,0.5,0.25]
expected: 0.5
case 2
in: [2,0.25,0.0625]
expected: 0.5
case 3
in: [1,0.5,1]
expected: 1.25
case 4
in: [1,1,0]
expected: -1
Starter codePython
def mg1_expected_queue_length(lam, mean_service, var_service):
    # Your code here
    pass

4 test cases · run your code against them in the editor