Reputation: 39
I am attempting to do some basic dB calculations using Python. If I use either Excel or a scientific calculator:
20*log(0.1) = -20
in Python:
20*log(0.1) = -46.0517018599
to simplify further, Excel and Scientific calc:
log(0.1) = -1
Python:
log(0.1) = -2.30258509299
I start my script with
import math
log = math.log
Can someone explain why this is and how I can fix it?
Upvotes: 2
Views: 1952
Reputation: 20336
math.log
is actually ln
(with a base of e). To get the expected results, use math.log(0.1, 10)
or math.log10(0.1)
.
Upvotes: 11