Log transform: log(1 + x) to handle zeros.
double log1pSafe(num x) => x <= -1 ? double.negativeInfinity : log(1 + x.toDouble());