Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
queueing theory
def calc(k,p,alpha):
u = 1.0 - 1.0 / float(1<<31)
p_actual = k / pow(1.0 + u * (pow(k / p, alpha) - 1), 1.0/alpha)
print "p actual:", p_actual
def E_X(r, p):
C_a = alpha * pow(k, alpha) / (1 - (pow(k/p,alpha)))
return (C_a / (r - alpha)) * (pow(p, r-alpha) - pow(k,r-alpha))
def C(ex1, ex2):
return ex2 / ex1 - 1
E_X_1_actual = E_X(1, p_actual)
E_X_2_actual = E_X(2, p_actual)
E_X_1_theory = 1
E_X_2_theory = E_X(2, p)
print "E[X_actual]", E_X_1_actual
print "C theory", C(E_X_1_theory, E_X_2_theory)
print "C actual", C(E_X_1_actual, E_X_2_actual)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment