Parameters

Returns

median#1

The median is the number in the middle of a set of numbers.
Half the numbers have values that are greater than the median,
and half the numbers have values that are less than the median.

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers, of any length

Returns

double

for odd count of numbers return the number in the middle of the sorted sequence. For even count of numbers return the average of the two numbers in the middle.

mod#2

declare function math:mod($number as double, $divisor as double) as double

Returns the remainder after number is divided by divisor.

The result has the same sign as divisor.

Borrowed from excel module.

Parameters

number as double

The number for which you want to find the remainder.

divisor as double

The number by which you want to divide number. This cannot be zero.

Returns

double

The remainder from division as numeric type.

mode#1

declare function math:mode($numbers as double*) as double

Returns the most frequently occurring, or repetitive, value in a sequence.

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers, of any length

Returns

double

The most occuring number

modf#1

declare function math:modf($arg as double) as double+ external

Splits a floating-point value into fractional and integer parts.

Both the fraction and integer keep the original sign of the value.

Parameters

arg as double

the double to be split.

Returns

double+

A sequence of two doubles (fraction, integer)

mround#2

declare function math:mround($number as decimal, $multiple as double) as double

Returns a number rounded to the desired multiple.

MROUND rounds up, away from zero, if the remainder of dividing number by multiple
is greater than or equal to half the value of multiple.
MROUND is computed through math:floor function.

Borrowed from excel module.

Parameters

number as decimal

The value to round,

multiple as double

The multiple to which you want to round number.

Returns

double

The rounded number up to the desired multiple.

odd#1

declare function math:odd($number as double) as integer

Returns number rounded up to the nearest odd integer, away from zero.

Borrowed from excel module.

Parameters

number as double

The value to round.

Returns

integer

The odd integer.

percentile#2

declare function math:percentile($numbers as double*, $k_at as double) as double

Returns the k-th percentile of values in a sequence.

If k is not a multiple of 1/(n - 1),
PERCENTILE interpolates to determine the value at the k-th percentile.
The function is computed by (max-min)*k + min

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers, of any length

k_at as double

the percentile, with value between 0 .. 1 inclusive

Returns

double

The computed percentile

percentrank#2

declare function math:percentrank($numbers as double*, $x as double) as double

Returns the rank of a value in a data set as a percentage of the data set.

If x does not match one of the values in array,
PERCENTRANK interpolates to return the correct percentage rank.
The formula is uses: (RANK - 1) / (size - 1) .

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers. The sequence can be of any length, from 1 up.

x as double

is the value for which you want to know the rank

Returns

double

The percentage of rank.

prob#3

declare function math:prob($x_range as double+, $prob_range as double+, $range_lower_limit as double) as double

This is the same as math:prob#4, only that upper_limit is not specified.

The probability is computed only for range_lower_limit.

Borrowed from excel module.

Parameters

x_range as double

is the range of numeric values of x with which there are associated probabilities. This does not need to be ordered.

prob_range as double

is a set of probabilities associated with values in x_range.

range_lower_limit as double

is the value for which you want a probability.

Returns

double

The probability of the range_lower_limit value

prob#4

declare function math:prob($x_range as double+, $prob_range as double+, $range_lower_limit as double, $upper_limit as double) as double

Returns the probability that values in a range are between two limits.

Borrowed from excel module.

Parameters

x_range as double

is the range of numeric values of x with which there are associated probabilities. This does not need to be ordered.

prob_range as double

is a set of probabilities associated with values in x_range.

range_lower_limit as double

is the lower bound on the value for which you want a probability.

upper_limit as double

is the upper bound on the value for which you want a probability.

Returns

double

The probability of the entire range

product#1

declare function math:product($numbers as double*) as double

Multiplies all the numbers given as arguments and returns the product.

Borrowed from excel module.

Parameters

numbers as double

The sequence of arguments convertible to numeric types. The sequence can be of any length.

Returns

double

The multiplication result as numeric type.

quartile#2

declare function math:quartile($numbers as double*, $quart as integer) as double

Returns the quartile of a data set.

Borrowed from excel module.

Parameters

numbers as double

sequence of numbers. The sequence can be of any length, from 1 up.

quart as integer

one of the values 0, 1, 2, 3, 4 with meaning:

0

compute minimum value

1

compute first quartile (25th percentile)

2

compute median value (50th percentile)

3

compute third quartile (75th percentile)

4

compute maximum value

Returns

double

the computed quartile, as numeric type

quotient#2

declare function math:quotient($numerator as double, $denominator as double) as integer

Returns the integer portion of a division.

Borrowed from excel module.

Parameters

numerator as double

The divider.

denominator as double

The divisor. It cannot be zero.

Returns

integer

The result value as numeric type.

rad-to-deg#1

declare function math:rad-to-deg($rad as double) as double

Convert angle from radians to degrees.

Parameters

rad as double

value in radians

Returns

double

value in degrees (-360, 360)

rank#2

declare function math:rank($x as double, $numbers as double*) as double

This RANK function is same as the above, only that $order_ascending is set by default to false.

Borrowed from excel module.

Parameters

x as double

The number whose rank you want to find.

numbers as double

the sequence of numbers. The sequence can be of any length.

Returns

double

The rank of $x.

rank#3

declare function math:rank($x as double, $numbers as double*, $order_ascending as boolean) as double

Returns the rank of a number in a list of numbers.

The rank of a number is its size relative to other values in a list.
(If you were to sort the list, the rank of the number would be its position.)
RANK gives duplicate numbers the same rank.

Borrowed from excel module.

Parameters

x as double

The number whose rank you want to find.

numbers as double

The sequence of numbers. The sequence can be of any length.

order_ascending as boolean

A boolean having the meaning:

false

then rank the number as if the sequence was sorted in descending order.

true

then rank the number as if the sequence was sorted in ascending order.

Returns

double

The rank of $x.

roman#1

declare function math:roman($number as integer) as string

Converts an Arabic numeral to roman, as text.

Only the classic format is supported (out of all formats Excel requires).
M is the largest digit, it represents 1000.
Numbers bigger than 2000 will be represented by a sequence of "M".
D = 500, C = 100, L = 50, X = 10, V = 5, I = 1.

Borrowed from excel module.

Parameters

number as integer

A positive integer.

Returns

string

The roman string representation.

round#2

declare function math:round($number as double, $precision as integer) as double

Rounds a number to a specified number of digits.

If precision is greater than 0 (zero), then number is rounded
to the specified number of decimal places.
If num_digits is 0, then number is rounded to the nearest integer.
If num_digits is less than 0, then number is rounded to the left of the decimal point.
The 0.5 is rounded away from zero.

Borrowed from excel module.

Parameters

number as double

The number to round.

precision as integer

The number of decimal places to keep.

Returns

double

The rounded number as numeric type.

rounddown#2

declare function math:rounddown($number as double, $precision as integer) as double

Rounds a number down, toward zero.

If num_digits is greater than 0 (zero), then number is rounded down
to the specified number of decimal places.
If num_digits is 0, then number is rounded down to the nearest integer.
If num_digits is less than 0, then number is rounded down to the left of the decimal point.

Borrowed from excel module.

Parameters

number as double

The number to round

precision as integer

The number of decimal places to keep.

Returns

double

the truncated number toward zero, as numeric type.

roundup#2

declare function math:roundup($number as double, $precision as integer) as double

Rounds a number up, away from 0 (zero).

If num_digits is greater than 0 (zero), then number is rounded down
to the specified number of decimal places.
If num_digits is 0, then number is rounded down to the nearest integer.
If num_digits is less than 0, then number is rounded down to the left of the decimal point.

Borrowed from excel module.

Parameters

number as double

The number to round

precision as integer

The number of decimal places to keep.

Returns

double

The truncated number away from zero, as numeric type.

sign#1

declare function math:sign($number as double) as integer

Determines the sign of a number.

Returns 1 if the number is positive, zero (0) if the number is 0,
and -1 if the number is negative.

Borrowed from excel module.

Parameters

number as double

The argument

Returns

integer

The sign as (-1, 0, 1).

sinh#1

declare function math:sinh($arg as double) as double external

Calculate the hyperbolic sine.

Parameters

arg as double

the arg

Returns

double

the result of sinh(arg)

slope#2

declare function math:slope($known_y as double+, $known_x as double+) as double

Returns the slope of the linear regression line through data points in known_y's and known_x's.

The slope is the vertical distance divided by the horizontal distance between
any two points on the line, which is the rate of change along the regression line.
It computes the formula:

sum((x - average_x)(y - average_y)) / sum((x - average_x)^2)

where average_x and average_y are computed with AVERAGE function.

Borrowed from excel module.

Parameters

known_y as double

the sequence of y numbers. The sequence can be of any length, from 1 up.

known_x as double

the sequence of x numbers. The sequence can be of any length, from 1 up.

Returns

double

The slope value, as numeric type

small#2

declare function math:small($numbers as double*, $k as integer) as double

This function computes the k-th smallest value in a data set.

Use this function to return values with a particular relative standing in a data set.
If n is the number of data points in array, SMALL(array,1) equals the smallest value,
and SMALL(array,n) equals the largest value.
Borrowed from excel module.

Parameters

numbers as double

A sequence of numbers. The sequence can be of any length, from 1 up.

k as integer

The position (from the smallest) in the sequence of data to return. Must have value between 1 and size of sequence.

Returns

double

The k-th smallest value of $numbers.

sort-numbers#1

declare function math:sort-numbers($numbers as double*) as double*

Sorts a sequence of numbers or arguments castable to numeric.

It first casts all arguments to numeric and then sorts ascending.

Helper function.
Borrowed from excel module.

Parameters

numbers as double

The sequence of arguments castable to numeric.

Returns

double*

The sorted sequence as numeric types.

standardize#3

declare function math:standardize($x as double, $mean as double, $standard_dev as double) as double

Returns a normalized value from a distribution characterized by mean and standard_dev.

The formula is (x - mean) / standard_dev .

Borrowed from excel module.

Parameters

x as double

is the value you want to normalize

mean as double

is the arithmetic mean of the distribution.

standard_dev as double

is the standard deviation of the distribution.

Returns

double

The normalized x, as numeric type

stdev#1

declare function math:stdev($numbers as double+) as double

Estimates standard deviation based on a sample.

The standard deviation is a measure of how widely values are dispersed
from the average value (the mean).
It is computed with formula:
sqrt( sum((x-average_x)^2) / (n-1) ) = sqrt ( VAR(numbers) )

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers The sequence can be of any length, from 1 up.

Returns

double

the standard deviation, as numeric type

stdeva#1

declare function math:stdeva($numbers as double+) as double

Estimates standard deviation based on a sample.

The standard deviation is a measure of how widely values are dispersed
from the average value (the mean).
It is computed with formula:
sqrt( sum((x-average_x)^2) / (n-1) ) = sqrt ( VARA(numbers) )

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers. The sequence can be of any length, from 1 up.

Returns

double

the standard deviation, as numeric type

stdevp#1

declare function math:stdevp($numbers as double+) as double

Calculates standard deviation based on the entire population given as arguments.

The standard deviation is a measure of how widely values are dispersed from
the average value (the mean).
It is computed with formula:
sqrt( sum((x-average_x)^2) / n ) = sqrt ( VARP(numbers) )

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers or values castable to numeric The sequence can be of any length, from 1 up.

Returns

double

the standard deviation, as numeric type

stdevpa#1

declare function math:stdevpa($numbers as double+) as double

Calculates standard deviation based on the entire population given as arguments.

The standard deviation is a measure of how widely values are dispersed from
the average value (the mean).
It is computed with formula:
sqrt( sum((x-average_x)^2) / n ) = sqrt ( VARPA(numbers) )

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers or values castable to numeric The sequence can be of any length, from 1 up.

Returns

double

the standard deviation, as numeric type

subtotal#2

declare function math:subtotal($function_num as integer, $numbers as double*) as double

Returns a subtotal in a sequence of numbers.

The function applied is given by $function_num.

Borrowed from excel module.

Parameters

function_num as integer

defines the function to be applied on sequence values. The possible values are:

1 or 101

AVERAGE

2 or 102

COUNT

3 or 103

COUNTA

4 or 104

MAX

5 or 105

MIN

6 or 106

PRODUCT

7 or 107

STDEV

8 or 108

STDEVP

9 or 109

SUM

10 or 110

VAR

11 or 111

VARP

In this implementation there is no difference between x and 10x.

numbers as double

the sequence of numbers. The sequence can be of any length.

Returns

double

The function result, as numeric type

sumproduct#2

declare function math:sumproduct($array1 as double*, $array2 as double*) as double

Multiplies the elements on the same position in each sequence
and sums up the results.

Borrowed from excel module.

Parameters

array1 as double

the sequences of numbers

array2 as double

the sequences of numbers

Returns

double

the sum of products

sumsq#1

declare function math:sumsq($numbers as double+) as double

Returns the sum of the squares of the arguments.

It uses the sumproduct function.

Borrowed from excel module.

Parameters

numbers as double

the sequence of one or more numbers

Returns

double

the sum of squared values, as numeric type

tanh#1

declare function math:tanh($arg as double) as double external

Calculate the hyperbolic tangent.

Parameters

arg as double

the arg

Returns

double

the result of tanh(arg)

trunc#1

declare function math:trunc($number as double) as integer

Truncates a number to an integer by removing the fractional part of the number.

Borrowed from excel module.

Parameters

number as double

The argument .

Returns

integer

The integer value.

trunc#2

declare function math:trunc($number as double, $precision as integer) as double

Truncates a number down to precision.

This behaves exactly like rounddown.

Borrowed from excel module.

Parameters

number as double

The argument castable to numeric type.

precision as integer

The number of decimal places to keep .

Returns

double

The integer value.

var#1

declare function math:var($numbers as double+) as double

Estimates variance based on a sample.

The formula is sum(x - average_x)^2 / (n - 1).
average_x is computed with AVERAGE function.
n is the count of numbers from the sequence, excluding empty values.

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers. The sequence can be of any length, from 1 up.

Returns

double

The variance, as numeric type

vara#1

declare function math:vara($numbers as double+) as double

Estimates variance based on a sample.

The formula is sum(x - average_x)^2 / (n - 1).
average_x is computed with AVERAGE function.
n is the size of sequence, including empty values.

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers. The sequence can be of any length, from 1 up.

Returns

double

The variance, as numeric type

varp#1

declare function math:varp($numbers as double+) as double

Calculates variance based on the entire population.

The formula is sum(x - average_x)^2 / n.
average_x is computed with AVERAGE function.
n is the count of numbers from the sequence, excluding empty values.

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers. The sequence can be of any length, from 1 up.

Returns

double

The variance, as numeric type

varpa#1

declare function math:varpa($numbers as double+) as double

Calculates variance based on the entire population.

The formula is sum(x - average_x)^2 / n.
average_x is computed with AVERAGE function.
n is the size of sequence, including empty values.

Borrowed from excel module.

Parameters

numbers as double

the sequence of numbers. The sequence can be of any length, from 1 up.