Skip to content

Instantly share code, notes, and snippets.

@seckcoder
Created April 8, 2015 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seckcoder/4c4483d718921d6a16c5 to your computer and use it in GitHub Desktop.
Save seckcoder/4c4483d718921d6a16c5 to your computer and use it in GitHub Desktop.
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