Log to the base 2 in python

前端 未结 11 1184
刺人心
刺人心 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 15:54

    Don't forget that log[base A] x = log[base B] x / log[base B] A.

    So if you only have log (for natural log) and log10 (for base-10 log), you can use

    myLog2Answer = log10(myInput) / log10(2)
    

提交回复
热议问题