How should I compute log to the base two in python. Eg. I have this equation where I am using log base 2
import math e = -(t/T)* math.log((t/T)[, 2])
http://en.wikipedia.org/wiki/Binary_logarithm
def lg(x, tol=1e-13): res = 0.0 # Integer part while x<1: res -= 1 x *= 2 while x>=2: res += 1 x /= 2 # Fractional part fp = 1.0 while fp>=tol: fp /= 2 x *= x if x >= 2: x /= 2 res += fp return res