Logarithm

Element-wiseCore Math

The Log node computes the logarithm of each value in the specified base (default: Math.E for natural log). Input values must be strictly positive; non-positive or null inputs yield null. Log transforms compress skewed price distributions, convert multiplicative returns to additive log-returns, linearize exponential growth curves, and are essential for any entropy or information-theoretic computation.

Algorithm

  • output[i] = Math.log(input[i]) / Math.log(b)
  • b defaults to Math.E (natural logarithm)
  • input ≤ 0 or b ≤ 0 or b === 1 → null (guards for undefined log)

Parameters

NameTypeDefaultDescription
bnumberMath.E (≈ 2.718)Logarithm base. Use 10 for common log, 2 for binary, or e for natural log-returns.

Inputs & Outputs

PortTypeDescription
Inputs
inputnumber[]Source numeric array
Outputs
valuesnumber | nullComputed value at each bar; null before the warmup period completes
timestampsnumber[]Bar timestamps (UNIX ms), aligned 1-to-1 with values
Live mode: In live streaming mode the node updates only the last bar in-place rather than recalculating the full array, keeping CPU usage minimal during real-time data feeds.

Use Cases

Log Returns

Apply natural log to closing prices, then subtract the previous bar with the Subtract node, to produce continuous log-returns: ln(close[i]) - ln(close[i-1]).

Log Scale Oscillators

Log-transform a volume series before feeding it into Average and Stddev to prevent large volume spikes from dominating the mean.

Exponential Growth Linearization

Take the log of an exponentially growing equity curve to linearize it, making trend-following nodes like Slope and R-Squared meaningful.