- All Modules
- All Functions
-
www.w3.org
- 2005
- XDM
- store
- introspection
- reflection
- external
-
xqdoc
-
project_xqdoc
-
xqdoc
(E)
- xqdoc2xhtml
-
project_xqdoc
- data processing
- expath.org
- www.functx.com
- error
http://www.zorba-xquery.com/modules/math
import module namespace math = "http://www.zorba-xquery.com/modules/math";
Extensive math library.
Daniel Turcanu, Dan Muresan
xquery version "3.0" encoding "utf-8";
- the XQuery module can be found here.
W3Cmath | http://www.w3.org/2005/xpath-functions/math |
math | http://www.zorba-xquery.com/modules/math |
ver | http://www.zorba-xquery.com/options/versioning |
$math:errDiv0 as xs:QName xs:QName with namespace URI="http://www.zorba-xquery.com/modules/math" and local name "math:Div0" |
|
$math:errNA as xs:QName xs:QName with namespace URI="http://www.zorba-xquery.com/modules/math" and local name "math:NA" |
|
$math:errNS as xs:string Errors namespace URI. |
|
$math:errNum as xs:QName xs:QName with namespace URI="http://www.zorba-xquery.com/modules/math" and local name "math:Num" |
|
$math:errValue as xs:QName xs:QName with namespace URI="http://www.zorba-xquery.com/modules/math" and local name "math:Value" |
![]() |
acosh
(
$arg as xs:double
) as xs:double external Inverse hyperbolic cosine. |
![]() |
asinh
(
$arg as xs:double
) as xs:double external Inverse hyperbolic sine of the number. |
![]() |
atanh
(
$arg as xs:double
) as xs:double external Calculate the hyperbolic tangent. |
avedev
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
|
cast-as-numeric
(
$number as xs:anyAtomicType
) as xs:anyAtomicType Borrowed from excel module. |
|
ceiling
(
$number as xs:double,
$significance as xs:double
) as xs:double Borrowed from excel module. |
|
![]() |
cosh
(
$arg as xs:double
) as xs:double external Returns the hyperbolic cosine of x. |
deg-to-rad
(
$deg as xs:double
) as xs:double Convert angle from degrees to radians. |
|
even
(
$number as xs:double
) as xs:integer Borrowed from excel module. |
|
fact
(
$number as xs:integer
) as xs:integer Borrowed from excel module. |
|
factdouble
(
$number as xs:integer
) as xs:integer Borrowed from excel module. |
|
floor
(
$number as xs:double,
$significance as xs:double
) as xs:double Borrowed from excel module. |
|
![]() |
fmod
(
$x as xs:double,
$y as xs:double
) as xs:double external Function performing the modulo operation between the two arguments. |
![]() |
frexp
(
$arg as xs:double
) as xs:double+ external Returns the argument split as mantissa and exponent. |
gcd
(
$numbers as xs:integer+
) as xs:integer Borrowed from excel module. |
|
int
(
$number as xs:double
) as xs:integer Borrowed from excel module. |
|
is-a-number
(
$value as xs:anyAtomicType
) as xs:boolean Borrowed from excel module. |
|
![]() |
is_inf
(
$arg as xs:double
) as xs:boolean external Checks if the double value is positive or negative infinite. |
![]() |
is_nan
(
$arg as xs:double
) as xs:boolean external Checks if the double value is Not a Number (NaN). |
large
(
$numbers as xs:double+,
$k as xs:integer
) as xs:double Borrowed from excel module. |
|
lcm
(
$numbers as xs:integer+
) as xs:integer Borrowed from excel module. |
|
![]() |
ldexp
(
$x as xs:double,
$i as xs:integer
) as xs:double external Computes a real number from the mantissa and exponent. |
median
(
$numbers as xs:double*
) as xs:double Borrowed from excel module. |
|
mod
(
$number as xs:double,
$divisor as xs:double
) as xs:double Borrowed from excel module. |
|
mode
(
$numbers as xs:double*
) as xs:double Borrowed from excel module. |
|
![]() |
modf
(
$arg as xs:double
) as xs:double+ external Splits a floating-point value into fractional and integer parts. |
mround
(
$number as xs:decimal,
$multiple as xs:double
) as xs:double Borrowed from excel module. |
|
odd
(
$number as xs:double
) as xs:integer Borrowed from excel module. |
|
percentile
(
$numbers as xs:double*,
$k_at as xs:double
) as xs:double Borrowed from excel module. |
|
percentrank
(
$numbers as xs:double*,
$x as xs:double
) as xs:double Borrowed from excel module. |
|
prob
(
$x_range as xs:double+,
$prob_range as xs:double+,
$range_lower_limit as xs:double
) as xs:double Borrowed from excel module. |
|
prob
(
$x_range as xs:double+,
$prob_range as xs:double+,
$range_lower_limit as xs:double,
$upper_limit as xs:double
) as xs:double Borrowed from excel module. |
|
product
(
$numbers as xs:double*
) as xs:double Borrowed from excel module. |
|
quartile
(
$numbers as xs:double*,
$quart as xs:integer
) as xs:double Borrowed from excel module. |
|
quotient
(
$numerator as xs:double,
$denominator as xs:double
) as xs:integer Borrowed from excel module. |
|
rad-to-deg
(
$rad as xs:double
) as xs:double Convert angle from radians to degrees. |
|
rank
(
$x as xs:double,
$numbers as xs:double*
) as xs:double Borrowed from excel module. |
|
rank
(
$x as xs:double,
$numbers as xs:double*,
$order_ascending as xs:boolean
) as xs:double Borrowed from excel module. |
|
roman
(
$number as xs:integer
) as xs:string Borrowed from excel module. |
|
round
(
$number as xs:double,
$precision as xs:integer
) as xs:double Borrowed from excel module. |
|
rounddown
(
$number as xs:double,
$precision as xs:integer
) as xs:double Borrowed from excel module. |
|
roundup
(
$number as xs:double,
$precision as xs:integer
) as xs:double Borrowed from excel module. |
|
sign
(
$number as xs:double
) as xs:integer Borrowed from excel module. |
|
![]() |
sinh
(
$arg as xs:double
) as xs:double external Calculate hyperbolic sine. |
slope
(
$known_y as xs:double+,
$known_x as xs:double+
) as xs:double Borrowed from excel module. |
|
small
(
$numbers as xs:double*,
$k as xs:integer
) as xs:double Borrowed from excel module. |
|
sort-numbers
(
$numbers as xs:double*
) as xs:double* Borrowed from excel module. |
|
standardize
(
$x as xs:double,
$mean as xs:double,
$standard_dev as xs:double
) as xs:double Borrowed from excel module. |
|
stdev
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
|
stdeva
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
|
stdevp
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
|
stdevpa
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
|
subtotal
(
$function_num as xs:integer,
$numbers as xs:double*
) as xs:double Borrowed from excel module. |
|
sumproduct
(
$array1 as xs:double*,
$array2 as xs:double*
) as xs:double Borrowed from excel module. |
|
sumsq
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
|
![]() |
tanh
(
$arg as xs:double
) as xs:double external Calculate the hyperbolic tangent. |
trunc
(
$number as xs:double
) as xs:integer Borrowed from excel module. |
|
trunc
(
$number as xs:double,
$precision as xs:integer
) as xs:double Borrowed from excel module. |
|
var
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
|
vara
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
|
varp
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
|
varpa
(
$numbers as xs:double+
) as xs:double Borrowed from excel module. |
declare function math:acosh (
$arg as xs:double
) as xs:double external
Inverse hyperbolic cosine.
- $arg the arg
- the result of acosh(arg)
declare function math:asinh (
$arg as xs:double
) as xs:double external
Inverse hyperbolic sine of the number.
- $arg the arg
- the result of asinh(arg)
declare function math:atanh (
$arg as xs:double
) as xs:double external
Calculate the hyperbolic tangent.
- $arg must be in range -1 ... +1 (exclusive)
- the result of atanh(arg)
declare function math:avedev (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
Returns the average of the absolute deviations of data points from their mean.
The formula is sum(abs(x - average_x))/n, where n is the count of x in the sequence.
- $numbers the sequence of numbers. Sequence can be of any length from 1 up.
- The formula result
declare function math:cast-as-numeric (
$number as xs:anyAtomicType
) as xs:anyAtomicType
Borrowed from excel module.
Cast the xs:anyAtomicType to a numeric type.
If the value is already of a numeric type then nothing is changed.
Otherwise the value is casted to the numeric type that is most appropriate.
- $number The parameter can be a number, string, boolean value.
- The casted value.
- math:errValue if the value cannot be casted to numeric type.
declare function math:ceiling ( $number as xs:double, $significance as xs:double ) as xs:double
Borrowed from excel module.
Returns number rounded up, away from zero, to the nearest multiple of significance.
Significance must have the same sign as number.
Number and significance must be of a numeric type or castable to numeric.
Significance must not be zero.
- $number The value you want to round.
- $significance The multiple to which you want to round.
- The rounded value.
- math:errNum if significance is zero or it doesn't have the same sign as number.
- excel_ceiling1.xq
- excel_ceiling2.xq
- excel_ceiling3.xq
- excel_ceiling4.xq
- excel_ceiling5.xq
- excel_ceiling6.xq
- excel_ceiling7.xq
declare function math:cosh (
$arg as xs:double
) as xs:double external
Returns the hyperbolic cosine of x. If the result it too large, INF is returned.
- $arg must be smaller than 7.104760e+002
- cosh(arg)
declare function math:deg-to-rad (
$deg as xs:double
) as xs:double
Convert angle from degrees to radians.
The parameter is first converted to value range of (-360, 360).
- $deg angle in degrees
- value in radians (-2PI, 2PI)
declare function math:even (
$number as xs:double
) as xs:integer
Borrowed from excel module.
Returns number rounded up to the nearest even integer.
Regardless of the sign of number, a value is rounded up when adjusted away from zero.
- $number The value to round.
- The rounded value casted as numeric type.
declare function math:fact (
$number as xs:integer
) as xs:integer
Borrowed from excel module.
Returns the factorial of a number.
- $number The non-negative number you want the factorial of.
- Returns the factorial of a number. The factorial of a number is equal to 1*2*3*...* number.
- math:errNum if the number is smaller than zero
declare function math:factdouble (
$number as xs:integer
) as xs:integer
Borrowed from excel module.
Returns the double factorial of a number.
Computes the double factorial of n as n(n-2)(n-4)...
- $number The positive integer value.
- The result as integer.
- math:errNum if the number is negative.
declare function math:floor ( $number as xs:double, $significance as xs:double ) as xs:double
Borrowed from excel module.
Rounds number down, toward zero, to the nearest multiple of significance.
Significance must have the same sign as number.
- $number The value you want to round.
- $significance The multiple to which you want to round.
- The rounded value as numeric type.
- math:errNum if significance is zero or it doesn't have the same sign as number.
declare function math:fmod ( $x as xs:double, $y as xs:double ) as xs:double external
Function performing the modulo operation between the two arguments.
- $x the x
- $y the y
- The remainder of x/y.
declare function math:frexp (
$arg as xs:double
) as xs:double+ external
Returns the argument split as mantissa and exponent. The recombining formula is (mantissa * 2^exponent).
- $arg the double to be split.
- A sequence of two doubles (mantissa, exponent)
declare function math:gcd (
$numbers as xs:integer+
) as xs:integer
Borrowed from excel module.
Returns the greatest common divisor GCD of a sequence of integers.
The sequence can have one or more positive integers.
- $numbers The sequence of positive integers.
- The GCD as integer.
- math:errNum if any number is smaller than zero.
- excel_gcd1.xq
- excel_gcd2.xq
- excel_gcd3.xq
- excel_gcd4.xq
- excel_gcd5.xq
- excel_gcd6.xq
- excel_gcd7.xq
- excel_gcd8.xq
declare function math:int (
$number as xs:double
) as xs:integer
Borrowed from excel module.
Rounds a number down to the nearest integer.
Positive numbers are rounded toward zero, negative numbers are rounded away from zero.
- $number The value to be rounded.
- The rounded integer.
declare function math:is-a-number (
$value as xs:anyAtomicType
) as xs:boolean
Borrowed from excel module.
Checks if the xs:anyAtomicType argument is actually a numeric type
or can be converted to numeric.
- $value Parameter to be checked.
- true if the value can be casted to numeric.
declare function math:is_inf (
$arg as xs:double
) as xs:boolean external
Checks if the double value is positive or negative infinite.
- $arg the double to be checked
- boolean true if argument is pos INF or neg INF
declare function math:is_nan (
$arg as xs:double
) as xs:boolean external
Checks if the double value is Not a Number (NaN).
- $arg the arg
- boolean true if the double is NaN
declare function math:large ( $numbers as xs:double+, $k as xs:integer ) as xs:double
Borrowed from excel module.
Returns the k-th largest value in a data set.
If n is the number of data points in a range,
then LARGE(array,1) returns the largest value,
and LARGE(array,n) returns the smallest value.
- $numbers the sequence of numbers The sequence can be of any length, from 1 up.
- $k the position of largest value, with value from 1 to count of values
- The k-th largest value as numeric type
- math:errNum if the sequence is empty or k is not a value between 1 and the size of the sequence
declare function math:lcm (
$numbers as xs:integer+
) as xs:integer
Borrowed from excel module.
Returns the least common multiple of integers.
LCM for two numbers is computed by multiplying them and dividing with GCD.
The function is applied recursively replacing the first two numbers in the sequence with their LCM.
- $numbers The sequence of one or more positive integers.
- The LCM as integer.
- math:errNum if any number is smaller than zero.
declare function math:ldexp ( $x as xs:double, $i as xs:integer ) as xs:double external
Computes a real number from the mantissa and exponent. The formula is (x * 2^i).
- $x the mantissa
- $i the exponent
- the computed real number
declare function math:median (
$numbers as xs:double*
) as xs:double
Borrowed from excel module.
Returns the median of the given numbers.
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.
- $numbers the sequence of numbers, of any length
- 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.
declare function math:mod ( $number as xs:double, $divisor as xs:double ) as xs:double
Borrowed from excel module.
Returns the remainder after number is divided by divisor.
The result has the same sign as divisor.
- $number The number for which you want to find the remainder.
- $divisor The number by which you want to divide number. This cannot be zero.
- The remainder from division as numeric type.
- math:errDiv0 if divisor is zero after casting to numeric.
declare function math:mode (
$numbers as xs:double*
) as xs:double
Borrowed from excel module.
Returns the most frequently occurring, or repetitive, value in a sequence.
- $numbers the sequence of numbers, of any length
- The most occuring number
- math:errNA if there are no duplicate numbers
declare function math:modf (
$arg as xs:double
) as xs:double+ external
Splits a floating-point value into fractional and integer parts. Both the fraction and integer keep the original sign of the value.
- $arg the double to be split.
- A sequence of two doubles (fraction, integer)
declare function math:mround ( $number as xs:decimal, $multiple as xs:double ) as xs:double
Borrowed from excel module.
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.
- $number The value to round,
- $multiple The multiple to which you want to round number.
- The rounded number up to the desired multiple.
declare function math:odd (
$number as xs:double
) as xs:integer
Borrowed from excel module.
Returns number rounded up to the nearest odd integer, away from zero.
- $number The value to round.
- The odd integer.
declare function math:percentile ( $numbers as xs:double*, $k_at as xs:double ) as xs:double
Borrowed from excel module.
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
- $numbers the sequence of numbers, of any length
- $k_at the percentile, with value between 0 .. 1 inclusive
- The computed percentile
- math:errNum if percentile is not between 0 .. 1
declare function math:percentrank ( $numbers as xs:double*, $x as xs:double ) as xs:double
Borrowed from excel module.
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) .
- $numbers the sequence of numbers. The sequence can be of any length, from 1 up.
- $x is the value for which you want to know the rank
- The percentage of rank.
- math:errNum if the sequence is zero length
- excel_percentrank1.xq
- excel_percentrank2.xq
- excel_percentrank3.xq
- excel_percentrank4.xq
- excel_percentrank5.xq
declare function math:prob ( $x_range as xs:double+, $prob_range as xs:double+, $range_lower_limit as xs:double ) as xs:double
Borrowed from excel module.
This is the same as above, only that upper_limit is not specified.
The probability is computed only for range_lower_limit.
- $x_range is the range of numeric values of x with which there are associated probabilities. This does not need to be ordered.
- $prob_range is a set of probabilities associated with values in x_range.
- $range_lower_limit is the value for which you want a probability.
- The probability of the range_lower_limit value
- math:errNum if any probability is not between 0 and 1
- math:errNum if the sum of probabilities is not equal to 1
- math:errNum if x_range and prob_range do not have the same number of values
declare function math:prob ( $x_range as xs:double+, $prob_range as xs:double+, $range_lower_limit as xs:double, $upper_limit as xs:double ) as xs:double
Borrowed from excel module.
Returns the probability that values in a range are between two limits.
- $x_range is the range of numeric values of x with which there are associated probabilities. This does not need to be ordered.
- $prob_range is a set of probabilities associated with values in x_range.
- $range_lower_limit is the lower bound on the value for which you want a probability.
- $upper_limit is the upper bound on the value for which you want a probability.
- The probability of the entire range
- math:errNum if any probability is not between 0 and 1
- math:errNum if the sum of probabilities is not equal to 1
- math:errNum if x_range and prob_range do not have the same number of values
declare function math:product (
$numbers as xs:double*
) as xs:double
Borrowed from excel module.
Multiplies all the numbers given as arguments and returns the product.
- $numbers The sequence of arguments convertible to numeric types. The sequence can be of any length.
- The multiplication result as numeric type.
declare function math:quartile ( $numbers as xs:double*, $quart as xs:integer ) as xs:double
Borrowed from excel module.
Returns the quartile of a data set.
- $numbers sequence of numbers. The sequence can be of any length, from 1 up.
- $quart 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
- the computed quartile, as numeric type
- math:errNum if the sequence is zero length or $quart is not one of the values 0,1,3,4
declare function math:quotient ( $numerator as xs:double, $denominator as xs:double ) as xs:integer
Borrowed from excel module.
Returns the integer portion of a division.
- $numerator The divider.
- $denominator The divisor. It cannot be zero.
- The result value as numeric type.
- math:errDiv0 if denominator casted as numeric type has value zero.
declare function math:rad-to-deg (
$rad as xs:double
) as xs:double
Convert angle from radians to degrees.
- $rad value in radians
- value in degrees (-360, 360)
declare function math:rank ( $x as xs:double, $numbers as xs:double* ) as xs:double
Borrowed from excel module.
This RANK function is same as the above, only that $order_ascending is set by default to false.
- $x The number whose rank you want to find.
- $numbers the sequence of numbers. The sequence can be of any length.
- The rank of $x.
declare function math:rank ( $x as xs:double, $numbers as xs:double*, $order_ascending as xs:boolean ) as xs:double
Borrowed from excel module.
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.
- $x The number whose rank you want to find.
- $numbers The sequence of numbers. The sequence can be of any length.
- $order_ascending 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.
- The rank of $x.
declare function math:roman (
$number as xs:integer
) as xs:string
Borrowed from excel module.
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.
- $number A positive integer.
- The roman string representation.
- math:errNum if the input integer is negative
declare function math:round ( $number as xs:double, $precision as xs:integer ) as xs:double
Borrowed from excel module.
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.
- $number The number to round.
- $precision The number of decimal places to keep.
- The rounded number as numeric type.
declare function math:rounddown ( $number as xs:double, $precision as xs:integer ) as xs:double
Borrowed from excel module.
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.
- $number The number to round
- $precision The number of decimal places to keep.
- the truncated number toward zero, as numeric type.
declare function math:roundup ( $number as xs:double, $precision as xs:integer ) as xs:double
Borrowed from excel module.
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.
- $number The number to round
- $precision The number of decimal places to keep.
- The truncated number away from zero, as numeric type.
declare function math:sign (
$number as xs:double
) as xs:integer
Borrowed from excel module.
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.
- $number The argument
- The sign as (-1, 0, 1).
declare function math:sinh (
$arg as xs:double
) as xs:double external
Calculate hyperbolic sine.
- $arg the arg
- the result of sinh(arg)
declare function math:slope ( $known_y as xs:double+, $known_x as xs:double+ ) as xs:double
Borrowed from excel module.
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.
- $known_y the sequence of y numbers. The sequence can be of any length, from 1 up.
- $known_x the sequence of x numbers. The sequence can be of any length, from 1 up.
- The slope value, as numeric type
- math:errNA if there are different numbers of x's and y's or if the sequence is empty
- math:errDiv0 if all x's are equal
declare function math:small ( $numbers as xs:double*, $k as xs:integer ) as xs:double
Borrowed from excel module.
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.
- $numbers A sequence of numbers. The sequence can be of any length, from 1 up.
- $k The position (from the smallest) in the sequence of data to return. Must have value between 1 and size of sequence.
- The k-th smallest value of $numbers.
- math:errNum if the sequence is zero length or $k is not a value between 1 and the size of sequence.
declare function math:sort-numbers (
$numbers as xs:double*
) as xs:double*
Borrowed from excel module.
Helper function.
Sorts a sequence of numbers or arguments castable to numeric.
It first casts all arguments to numeric and then sorts ascending.
- $numbers The sequence of arguments castable to numeric.
- The sorted sequence as numeric types.
declare function math:standardize ( $x as xs:double, $mean as xs:double, $standard_dev as xs:double ) as xs:double
Borrowed from excel module.
Returns a normalized value from a distribution characterized by mean and standard_dev.
The formula is (x - mean) / standard_dev .
- $x is the value you want to normalize
- $mean is the arithmetic mean of the distribution.
- $standard_dev is the standard deviation of the distribution.
- The normalized x, as numeric type
- math:errNum if standard_dev is a value smaller than zero or equal
declare function math:stdev (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
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) )
- $numbers the sequence of numbers The sequence can be of any length, from 1 up.
- the standard deviation, as numeric type
declare function math:stdeva (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
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) )
- $numbers the sequence of numbers. The sequence can be of any length, from 1 up.
- the standard deviation, as numeric type
declare function math:stdevp (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
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) )
- $numbers the sequence of numbers or values castable to numeric The sequence can be of any length, from 1 up.
- the standard deviation, as numeric type
declare function math:stdevpa (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
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) )
- $numbers the sequence of numbers or values castable to numeric The sequence can be of any length, from 1 up.
- the standard deviation, as numeric type
declare function math:subtotal ( $function_num as xs:integer, $numbers as xs:double* ) as xs:double
Borrowed from excel module.
Returns a subtotal in a sequence of numbers.
The function applied is given by $function_num.
- $function_num 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 the sequence of numbers. The sequence can be of any length.
- The function result, as numeric type
- * depends on the function called
- math:errNum if $function_num is not a value between 1 .. 11 or 101 .. 111
- excel_subtotal1.xq
- excel_subtotal2.xq
- excel_subtotal3.xq
- excel_subtotal4.xq
- excel_subtotal5.xq
- excel_subtotal6.xq
- excel_subtotal7.xq
- excel_subtotal8.xq
- excel_subtotal9.xq
- excel_subtotal10.xq
- excel_subtotal11.xq
declare function math:sumproduct ( $array1 as xs:double*, $array2 as xs:double* ) as xs:double
Borrowed from excel module.
Multiplies the elements on the same position in each sequence
and sums up the results.
- $array1 the sequences of numbers
- $array2 the sequences of numbers
- the sum of products
declare function math:sumsq (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
Returns the sum of the squares of the arguments.
It uses the sumproduct function.
- $numbers the sequence of one or more numbers
- the sum of squared values, as numeric type
declare function math:tanh (
$arg as xs:double
) as xs:double external
Calculate the hyperbolic tangent.
- $arg the arg
- the result of tanh(arg)
declare function math:trunc (
$number as xs:double
) as xs:integer
Borrowed from excel module.
Truncates a number to an integer by removing the fractional part of the number.
- $number The argument .
- The integer value.
declare function math:trunc ( $number as xs:double, $precision as xs:integer ) as xs:double
Borrowed from excel module.
Truncates a number down to precision.
This behaves exactly like rounddown.
- $number The argument castable to numeric type.
- $precision The number of decimal places to keep .
- The integer value.
declare function math:var (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
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.
- $numbers the sequence of numbers. The sequence can be of any length, from 1 up.
- The variance, as numeric type
declare function math:vara (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
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.
- $numbers the sequence of numbers. The sequence can be of any length, from 1 up.
- The variance, as numeric type
declare function math:varp (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
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.
- $numbers the sequence of numbers. The sequence can be of any length, from 1 up.
- The variance, as numeric type
declare function math:varpa (
$numbers as xs:double+
) as xs:double
Borrowed from excel module.
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.
- $numbers the sequence of numbers. The sequence can be of any length, from 1 up.
- The variance, as numeric type