Log to the base 2 in python

前端 未结 11 1166
刺人心
刺人心 2020-12-07 15:22

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])
         


        
11条回答
  •  眼角桃花
    2020-12-07 16:02

    In python 3 or above, math class has the fallowing functions

    import math
    
    math.log2(x)
    math.log10(x)
    math.log1p(x)
    

    or you can generally use math.log(x, base) for any base you want.

提交回复
热议问题