All problems
Log Transform Series
Problem
Apply the natural logarithm elementwise to a series, a standard variance-stabilizing transform for data that grows multiplicatively.
Return 0.0 for any non-positive value, since the logarithm is undefined there.
Hint
Import the math module and guard against x <= 0.
Test cases
case 1
in: [[1,10,100]]
expected: [0,2.302585092994046,4.605170185988092]
case 2
in: [[0,1]]
expected: [0,0]
case 3
in: [[2.718281828459045]]
expected: [1]
case 4
in: [[0.5]]
expected: [-0.6931471805599453]
Starter codePython
import math
def log_transform(series):
# Your code here
pass4 test cases · run your code against them in the editor