The log1p transformation compresses the range of nonnegative data while handling zero naturally. Apply the natural logarithm of one plus each value:
yi=ln(1+xi)Here, x_i is an input value and y_i is its transformed value. Round each result to four decimal places and return the transformed values as a list.
Input: values = [0, 1, 2, 3]
Output: [0.0, 0.6931, 1.0986, 1.3863]
Explanation: Adding one makes the zero input valid, and the natural logarithm compresses the remaining values.
Input: values = [99, 999]
Output: [4.6052, 6.9078]
Use math.log1p to compute the transformation directly.
Round each transformed value while building the result list.
Sign in to take notes on this problem
Accepts: array
The log1p transformation compresses the range of nonnegative data while handling zero naturally. Apply the natural logarithm of one plus each value:
yi=ln(1+xi)Here, x_i is an input value and y_i is its transformed value. Round each result to four decimal places and return the transformed values as a list.
Input: values = [0, 1, 2, 3]
Output: [0.0, 0.6931, 1.0986, 1.3863]
Explanation: Adding one makes the zero input valid, and the natural logarithm compresses the remaining values.
Input: values = [99, 999]
Output: [4.6052, 6.9078]
Use math.log1p to compute the transformation directly.
Round each transformed value while building the result list.
Sign in to take notes on this problem
Accepts: array