Question

I need to use Erlang B and Erlang C formulas in python script.

How can I write these formulas in Python?

Was it helpful?

Solution

Try looking for a scientific python library like scipy :=)

from math import factorial
def ErlangB (E, m):
    InvB = 1.0
    for j in range(1, m+1):
        InvB = 1.0 + InvB * (j/E)
    return (1.0 / InvB)

def ErlangC(A, N):
    L = (A**N / factorial(N)) * (N / (N - A))
    sum_ = 0
    for i in range(N):
        sum_ += (A**i) / factorial(i)
    return (L / (sum_ + L))

( According to wikipedia pseudo-code)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top