Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-210

M/M/1 Waiting-Line Length Probability

Problem

For a stable M/M/1 queue, return the probability that k customers are waiting in line, excluding the customer in service:

P(Lq = 0) = 1 - rho and P(Lq = k) = (1 - rho) * rho^(k + 1) for k >= 1.

Return 0.0 for invalid inputs or an unstable queue.

Hint

Shift the geometric distribution of the number in system by one.

Test cases

case 1
in: [1,2,0]
expected: 0.5
case 2
in: [1,2,1]
expected: 0.125
case 3
in: [1,2,2]
expected: 0.0625
case 4
in: [1,1,0]
expected: 0
Starter codePython
def mm1_waiting_line_length_probability(lam, mu, k):
    # Your code here
    pass

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