Overview

exp2

exp2 is useful when you work with data measured on a binary scale, such as memory sizes, network bandwidths, or binary tree depths. You can also use it to reverse a log2 transformation and recover values on the original scale.

Usage#

Syntax#

exp2(x)

Parameters#

Name Type Required Description
x real Yes The exponent value.

Returns#

The base-2 exponential of x: 2^x.

Example#

Use exp2 to recover the geometric mean of request durations from a log2-transformed average.

Query

['sample-http-logs']
| where req_duration_ms > 0
| summarize geometric_mean = exp2(avg(log2(req_duration_ms))) by bin(_time, 1h)
| project _time, geometric_mean

Run in Playground

Output

_time geometric_mean
2024-11-14 10:00:00 85.3
2024-11-14 11:00:00 92.7
2024-11-14 12:00:00 78.1
  • log2: Returns the base-2 logarithm. Use it as the inverse of exp2.
  • exp: Returns e^x. Use it for natural-log-scale transformations instead of base-2.
  • exp10: Returns 10^x. Use it for base-10 (order-of-magnitude) scales.
  • pow: Raises any base to a power. Use it when neither e, 2, nor 10 is the intended base.
  • log: Returns the natural logarithm. Use it together with exp for natural-log-scale analysis.

Other query languages#

Splunk SPL users

Splunk SPL doesn't include a built-in exp2() function. You compute it as pow(2, x).

Splunk example

| eval result = pow(2, x)

APL equivalent

['sample-http-logs']
| extend result = exp2(x)
ANSI SQL users

Standard SQL does not define EXP2(). You compute it using POWER(2, x).

SQL example

SELECT POWER(2, x) AS result FROM logs

APL equivalent

['sample-http-logs']
| extend result = exp2(x)

Updated

Was this page helpful?