Light
Dark
System
v4latest
v4latest
v3
v2
v1

Mathematical Functions

math::abs()

Returns the absolute value of the input.

math::ceil()

Rounds up a given value to the nearest integer.

math::floor()

Rounds down a given value to the nearest integer.

math::ln()

Returns the natural logarithm of a given value.

math::lg()

Returns the base 10 logarithm of a given value.

math::log()

Returns the logarithm of a given value in the specified base.

math::mean()

Returns the arithmetic mean of the input set.

math::stddev()

Returns the sample standard deviation of the input set.

math::stddev_pop()

Returns the population standard deviation of the input set.

math::var()

Returns the sample variance of the input set.

math::var_pop()

Returns the population variance of the input set.

function

math::abs()
math::abs(x: anyreal) -> anyreal

Returns the absolute value of the input.

Copy
db> 
select math::abs(1);
{1}
Copy
db> 
select math::abs(-1);
{1}

function

math::ceil()
math::ceil(x: int64) -> float64math::ceil(x: float64) -> float64math::ceil(x: bigint) -> bigintmath::ceil(x: decimal) -> decimal

Rounds up a given value to the nearest integer.

Copy
db> 
select math::ceil(1.1);
{2}
Copy
db> 
select math::ceil(-1.1);
{-1}

function

math::floor()
math::floor(x: int64) -> float64math::floor(x: float64) -> float64math::floor(x: bigint) -> bigintmath::floor(x: decimal) -> decimal

Rounds down a given value to the nearest integer.

Copy
db> 
select math::floor(1.1);
{1}
Copy
db> 
select math::floor(-1.1);
{-2}

function

math::ln()
math::ln(x: int64) -> float64math::ln(x: float64) -> float64math::ln(x: decimal) -> decimal

Returns the natural logarithm of a given value.

Copy
db> 
select 2.718281829 ^ math::ln(100);
{100.00000009164575}

function

math::lg()
math::lg(x: int64) -> float64math::lg(x: float64) -> float64math::lg(x: decimal) -> decimal

Returns the base 10 logarithm of a given value.

Copy
db> 
select 10 ^ math::lg(42);
{42.00000000000001}

function

math::log()
math::log(x: decimal, named only base: decimal) -> decimal

Returns the logarithm of a given value in the specified base.

Copy
db> 
select 3 ^ math::log(15n, base := 3n);
{15.0000000000000005n}

function

math::mean()
math::mean(vals: set of int64) -> float64math::mean(vals: set of float64) -> float64math::mean(vals: set of decimal) -> decimal

Returns the arithmetic mean of the input set.

Copy
db> 
select math::mean({1, 3, 5});
{3}

function

math::stddev()
math::stddev(vals: set of int64) -> float64math::stddev(vals: set of float64) -> float64math::stddev(vals: set of decimal) -> decimal

Returns the sample standard deviation of the input set.

Copy
db> 
select math::stddev({1, 3, 5});
{2}

function

math::stddev_pop()
math::stddev_pop(vals: set of int64) -> float64math::stddev_pop(vals: set of float64) -> float64math::stddev_pop(vals: set of decimal) -> decimal

Returns the population standard deviation of the input set.

Copy
db> 
select math::stddev_pop({1, 3, 5});
{1.63299316185545}

function

math::var()
math::var(vals: set of int64) -> float64math::var(vals: set of float64) -> float64math::var(vals: set of decimal) -> decimal

Returns the sample variance of the input set.

Copy
db> 
select math::var({1, 3, 5});
{4}

function

math::var_pop()
math::var_pop(vals: set of int64) -> float64math::var_pop(vals: set of float64) -> float64math::var_pop(vals: set of decimal) -> decimal

Returns the population variance of the input set.

Copy
db> 
select math::var_pop({1, 3, 5});
{2.66666666666667}
Light
Dark
System

We use ChatGPT with additional context from our documentation to answer your questions. Not all answers will be accurate. Please join our Discord if you need more help.