http://zorba.io/modules/excel/statistical

Description

Before using any of the functions below please remember to import the module namespace:

import module namespace excel = "http://zorba.io/modules/excel/statistical";

This is a library module offering a part of the set of statistical functions defined by Microsoft Excel 2003.

Module code

Here is the actual XQuery module code.

Imported modules

See also

Authors

Daniel Turcanu

Version Declaration

xquery version "3.0" encoding "utf-8";

Namespaces

excelhttp://zorba.io/modules/excel/statistical
excel-errhttp://zorba.io/modules/excel/errors
excel-mathhttp://zorba.io/modules/excel/math
verhttp://zorba.io/options/versioning

Function Summary

count-non-empty($numbers as xs:anyAtomicType*) as xs:integer

Function for average function.

average($numbers as xs:anyAtomicType*) as xs:anyAtomicType

Returns the average (arithmetic mean) of the arguments.

count($numbers as xs:anyAtomicType*) as xs:integer

Counts the number of cells that contain numbers or values castable to numeric.

countblank($cells as xs:anyAtomicType*) as xs:integer

Counts the empty values in a sequence.

max($numbers as xs:anyAtomicType*) as xs:anyAtomicType

Returns the largest number in a sequence.

min($numbers as xs:anyAtomicType*) as xs:anyAtomicType

Returns the smallest number in a sequence.

median($numbers as xs:anyAtomicType*) as xs:anyAtomicType

Returns the median of the given numbers.

mode($numbers as xs:anyAtomicType*) as xs:anyAtomicType

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

percentile($numbers as xs:anyAtomicType*, $k_at as xs:anyAtomicType) as xs:anyAtomicType

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

sum-deviations($numbers as xs:anyAtomicType*, $average as xs:anyAtomicType) as xs:anyAtomicType

Function for AVEDEV.

avedev($numbers as xs:anyAtomicType+) as xs:anyAtomicType

Returns the average of the absolute deviations of data points from their mean.

add-all-cells($numbers as xs:anyAtomicType*) as xs:anyAtomicType

Function for AVERAGEA.

averagea($numbers as xs:anyAtomicType+) as xs:anyAtomicType

Calculates the average (arithmetic mean) of the values in the sequence of arguments.

counta($numbers as xs:anyAtomicType*) as xs:integer

Counts the number of values that are not empty.

large($numbers as xs:anyAtomicType*, $k as xs:integer) as xs:anyAtomicType

Returns the k-th largest value in a data set.

maxa($numbers as xs:anyAtomicType*) as xs:anyAtomicType

Returns the largest value in a list of arguments.

mina($numbers as xs:anyAtomicType*) as xs:anyAtomicType

Returns the smallest value in a list of arguments.

rank($x as xs:anyAtomicType, $numbers as xs:anyAtomicType*, $order_ascending as xs:boolean) as xs:decimal

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

rank($x as xs:anyAtomicType, $numbers as xs:anyAtomicType*) as xs:decimal

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

percentrank($numbers as xs:anyAtomicType*, $x as xs:anyAtomicType) as xs:decimal

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

quartile($numbers as xs:anyAtomicType*, $quart as xs:integer) as xs:anyAtomicType

Returns the quartile of a data set.

small($numbers as xs:anyAtomicType*, $k as xs:integer) as xs:anyAtomicType

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

sumsq-deviations($numbers as xs:anyAtomicType*, $average as xs:anyAtomicType) as xs:anyAtomicType

Function for VAR, VARA, VARP, VARPA and SLOPE.

var($numbers as xs:anyAtomicType+) as xs:anyAtomicType

Estimates variance based on a sample.

vara($numbers as xs:anyAtomicType+) as xs:anyAtomicType

Estimates variance based on a sample.

varp($numbers as xs:anyAtomicType+) as xs:anyAtomicType

Calculates variance based on the entire population.

varpa($numbers as xs:anyAtomicType+) as xs:anyAtomicType

Calculates variance based on the entire population.

sum-prob($prob_range as xs:anyAtomicType*) as xs:anyAtomicType

Function for PROB function.

sum-prob-x($x_range as xs:anyAtomicType*, $prob_range as xs:anyAtomicType*, $range_lower_limit as xs:anyAtomicType, $upper_limit as xs:anyAtomicType) as xs:anyAtomicType

Function for PROB function.

prob($x_range as xs:anyAtomicType+, $prob_range as xs:anyAtomicType+, $range_lower_limit as xs:anyAtomicType, $upper_limit as xs:anyAtomicType) as xs:anyAtomicType

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

prob($x_range as xs:anyAtomicType+, $prob_range as xs:anyAtomicType+, $range_lower_limit as xs:anyAtomicType) as xs:anyAtomicType

This is the same as above, only that upper_limit is not specified.

sum-x-y-deviations($x_numbers as xs:anyAtomicType*, $x_average as xs:anyAtomicType, $y_numbers as xs:anyAtomicType*, $y_average as xs:anyAtomicType) as xs:anyAtomicType

Function for SLOPE function.

slope($known_y as xs:anyAtomicType+, $known_x as xs:anyAtomicType+) as xs:anyAtomicType

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

standardize($x as xs:anyAtomicType, $mean as xs:anyAtomicType, $standard_dev as xs:anyAtomicType) as xs:double

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

Functions

count-non-empty#1

declare %:private function excel:count-non-empty(
    $numbers as xs:anyAtomicType*
) as xs:integer

Function for average function. This function should not be used outside this module. It counts all non-empty arguments from the sequence. The string value of every argument is used for checking.

Parameters

  • $numbers

    The sequence of values.

Returns

  • xs:integer

    The count of non-empty string values.

average#1

declare function excel:average(
    $numbers as xs:anyAtomicType*
) as xs:anyAtomicType

Returns the average (arithmetic mean) of the arguments. Arguments can be empty values, otherwise must be castable to numeric. If sequence is empty then zero is returned. The sequence can be of any length.

Parameters

  • $numbers

    The sequence of numbers or empty values.

Returns

  • xs:anyAtomicType

    The sum of all numbers divided by the number of non-empty values.

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type.

Examples

count#1

declare function excel:count(
    $numbers as xs:anyAtomicType*
) as xs:integer

Counts the number of cells that contain numbers or values castable to numeric.

Parameters

  • $numbers

    The sequence of values, of any length.

Returns

  • xs:integer

    The count of numbers.

Examples

countblank#1

declare function excel:countblank(
    $cells as xs:anyAtomicType*
) as xs:integer

Counts the empty values in a sequence. The empty values are the ones with string value "". The value 0 is not counted.

Parameters

  • $cells

    the sequence of values, of any length

Returns

  • xs:integer

    The count

Examples

max#1

declare function excel:max(
    $numbers as xs:anyAtomicType*
) as xs:anyAtomicType

Returns the largest number in a sequence.

Parameters

  • $numbers

    the sequence of numbers or values castable to numeric. The sequence can be of any length.

Returns

  • xs:anyAtomicType

    The max

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

min#1

declare function excel:min(
    $numbers as xs:anyAtomicType*
) as xs:anyAtomicType

Returns the smallest number in a sequence.

Parameters

  • $numbers

    the sequence of numbers or values castable to numeric. The sequence can be of any length.

Returns

  • xs:anyAtomicType

    The min

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

median#1

declare function excel:median(
    $numbers as xs:anyAtomicType*
) as xs:anyAtomicType

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.

Parameters

  • $numbers

    the sequence of numbers, of any length

Returns

  • xs:anyAtomicType

    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.

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

mode#1

declare function excel:mode(
    $numbers as xs:anyAtomicType*
) as xs:anyAtomicType

Returns the most frequently occurring, or repetitive, value in a sequence. Arguments must be castable to numeric.

Parameters

  • $numbers

    the sequence of numbers, of any length

Returns

  • xs:anyAtomicType

    The most occuring number

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

  • fn:QName("http://zorba.io/modules/excel/errors",

    "excel-err:NA") if there are no duplicate numbers

Examples

percentile#2

declare function excel:percentile(
    $numbers as xs:anyAtomicType*,
    $k_at as xs:anyAtomicType
) as xs:anyAtomicType

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

Parameters

  • $numbers

    the sequence of numbers, of any length

  • $k_at

    the percentile, with value between 0 .. 1 inclusive

Returns

  • xs:anyAtomicType

    The computed percentile

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

  • excel-err:Num

    if percentile is not between 0 .. 1

Examples

sum-deviations#2

declare %:private function excel:sum-deviations(
    $numbers as xs:anyAtomicType*,
    $average as xs:anyAtomicType
) as xs:anyAtomicType

Function for AVEDEV. This function should not be used outside this module. Computes formula sum(abs(x - average)) for every x in $numbers

Parameters

  • $numbers

    The sequence of numbers or values castable to numeric. Sequence can be of any length.

  • $average

    The average of all numbers, computed with function AVERAGE.

Returns

  • xs:anyAtomicType

    The result of the formula.

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type.

avedev#1

declare function excel:avedev(
    $numbers as xs:anyAtomicType+
) as xs:anyAtomicType

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.

Parameters

  • $numbers

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

Returns

  • xs:anyAtomicType

    The formula result

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

add-all-cells#1

declare %:private function excel:add-all-cells(
    $numbers as xs:anyAtomicType*
) as xs:anyAtomicType

Function for AVERAGEA. This function should not be used outside this module. This function adds all values that are castable to numeric.

Parameters

  • $numbers

    A sequence of any values, any length.

Returns

  • xs:anyAtomicType

    The sum of numbers.

averagea#1

declare function excel:averagea(
    $numbers as xs:anyAtomicType+
) as xs:anyAtomicType

Calculates the average (arithmetic mean) of the values in the sequence of arguments. Arguments can be of any type. The numbers are added, and the sum is divided by the size of entire sequence.

Parameters

  • $numbers

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

Returns

  • xs:anyAtomicType

    The result

Examples

counta#1

declare function excel:counta(
    $numbers as xs:anyAtomicType*
) as xs:integer

Counts the number of values that are not empty. Empty values are the one with string value "".

Parameters

  • $numbers

    the sequence of values of any type, any length

Returns

  • xs:integer

    The count of non-empty values

Examples

large#2

declare function excel:large(
    $numbers as xs:anyAtomicType*,
    $k as xs:integer
) as xs:anyAtomicType

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.

Parameters

  • $numbers

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

  • $k

    the position of largest value, with value from 1 to count of values

Returns

  • xs:anyAtomicType

    The k-th largest value as numeric type

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

  • excel-err:Num

    if the sequence is empty

  • excel-err:Num

    if k is not a value between 1 and the sequence size

Examples

maxa#1

declare function excel:maxa(
    $numbers as xs:anyAtomicType*
) as xs:anyAtomicType

Returns the largest value in a list of arguments. In this implementation there is no difference between MAX and MAXA.

Parameters

  • $numbers

    the sequence of numbers or values castable to numeric The sequence can be of any length.

Returns

  • xs:anyAtomicType

    The max

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

mina#1

declare function excel:mina(
    $numbers as xs:anyAtomicType*
) as xs:anyAtomicType

Returns the smallest value in a list of arguments. In this implementation there is no difference between MAX and MAXA.

Parameters

  • $numbers

    the sequence of numbers or values castable to numeric The sequence can be of any length.

Returns

  • xs:anyAtomicType

    The min

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

rank#3

declare function excel:rank(
    $x as xs:anyAtomicType,
    $numbers as xs:anyAtomicType*,
    $order_ascending as xs:boolean
) as xs:decimal

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.

Parameters

  • $x

    The number whose rank you want to find.

  • $numbers

    The sequence of numbers or values castable to numbers. The sequence can be of any length.

  • $order_ascending

    A boolean having the meaning: falsethen 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

  • xs:decimal

    The rank of $x.

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type.

Examples

rank#2

declare function excel:rank(
    $x as xs:anyAtomicType,
    $numbers as xs:anyAtomicType*
) as xs:decimal

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

Parameters

  • $x

    The number whose rank you want to find.

  • $numbers

    the sequence of numbers or values castable to numbers. The sequence can be of any length.

Returns

  • xs:decimal

    The rank of $x.

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type.

Examples

percentrank#2

declare function excel:percentrank(
    $numbers as xs:anyAtomicType*,
    $x as xs:anyAtomicType
) as xs:decimal
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) .

Parameters

  • $numbers

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

  • $x

    is the value for which you want to know the rank

Returns

  • xs:decimal

    The percentage of rank.

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

  • excel-err:Num

    if the sequence is zero length

Examples

quartile#2

declare function excel:quartile(
    $numbers as xs:anyAtomicType*,
    $quart as xs:integer
) as xs:anyAtomicType

Returns the quartile of a data set.

Parameters

  • $numbers

    sequence of numbers or values castable to 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

Returns

  • xs:anyAtomicType

    the computed quartile, as numeric type

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

  • excel-err:Num

    if the sequence is zero length

  • excel-err:Num

    if $quart is not one of the values 0, 1, 2, 3, 4

Examples

small#2

declare function excel:small(
    $numbers as xs:anyAtomicType*,
    $k as xs:integer
) as xs:anyAtomicType

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.

Parameters

  • $numbers

    A sequence of numbers or values castable to numeric. 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.

Returns

  • xs:anyAtomicType

    The k-th smallest value of $numbers.

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type.

  • excel-err:Num

    if the sequence is zero length.

  • excel-err:Num

    if $k is not a value between 1 and the size of sequence.

Examples

sumsq-deviations#2

declare %:private function excel:sumsq-deviations(
    $numbers as xs:anyAtomicType*,
    $average as xs:anyAtomicType
) as xs:anyAtomicType

Function for VAR, VARA, VARP, VARPA and SLOPE. This function should not be used outside this module. It computes formula sum((x - average_x)^2) for all x in $numbers.

Parameters

  • $numbers

    the sequence of numbers or values castable to numbers. The sequence can be of any length.

  • $average

    The precomputed average over the sequence.

Returns

  • xs:anyAtomicType

    The result as numeric type.

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type.

var#1

declare function excel:var(
    $numbers as xs:anyAtomicType+
) as xs:anyAtomicType
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.

Parameters

  • $numbers

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

Returns

  • xs:anyAtomicType

    The variance, as numeric type

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

vara#1

declare function excel:vara(
    $numbers as xs:anyAtomicType+
) as xs:anyAtomicType
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.

Parameters

  • $numbers

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

Returns

  • xs:anyAtomicType

    The variance, as numeric type

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

varp#1

declare function excel:varp(
    $numbers as xs:anyAtomicType+
) as xs:anyAtomicType
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.

Parameters

  • $numbers

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

Returns

  • xs:anyAtomicType

    The variance, as numeric type

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

varpa#1

declare function excel:varpa(
    $numbers as xs:anyAtomicType+
) as xs:anyAtomicType
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.

Parameters

  • $numbers

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

Returns

  • xs:anyAtomicType

    The variance, as numeric type

Errors

  • excel-err:Value

    if the parameters cannot be casted to numeric type

Examples

sum-prob#1

declare %:private function excel:sum-prob(
    $prob_range as xs:anyAtomicType*
) as xs:anyAtomicType

Function for PROB function. This function should not be used outside this module. Computes the sum over a sequence of numbers. Checks if the values are between 0 and 1.

Parameters

  • $prob_range

    The sequence of probabilities.

Returns

  • xs:anyAtomicType

    The sum of probabilities. This should be 1.

Errors

  • excel-err:Num

    if any probability is not between 0 and 1.

  • excel-err:Value

    if any parameter is not castable to numeric.

sum-prob-x#4

declare %:private function excel:sum-prob-x(
    $x_range as xs:anyAtomicType*,
    $prob_range as xs:anyAtomicType*,
    $range_lower_limit as xs:anyAtomicType,
    $upper_limit as xs:anyAtomicType
) as xs:anyAtomicType

Function for PROB function. This function should not be used outside this module. Checks the prob range and x range if they have the same number of values. Adds all probabilities corresponding to values between range_lower_limit and upper_limit.

Parameters

  • $x_range

    The sequence of x values.

  • $prob_range

    The sequence of probabilies associated to x values.

  • $range_lower_limit

    The lower limit of the range to compute the probability.

  • $upper_limit

    The upper limit of the range to compute the probability.

Returns

  • xs:anyAtomicType

    The sum of probabilities.

Errors

  • excel-err:Value

    if any parameter is not castable to numeric.

  • excel-err:Num

    if x_range and prob_range do not have the same number of values.

prob#4

declare function excel:prob(
    $x_range as xs:anyAtomicType+,
    $prob_range as xs:anyAtomicType+,
    $range_lower_limit as xs:anyAtomicType,
    $upper_limit as xs:anyAtomicType
) as xs:anyAtomicType

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

Parameters

  • $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.

Returns

  • xs:anyAtomicType

    The probability of the entire range

Errors

  • excel-err:Num

    if any probability is not between 0 and 1

  • excel-err:Num

    if the sum of probabilities is not equal to 1

  • excel-err:Value

    if any parameter is not castable to numeric

  • excel-err:Num

    if x_range and prob_range do not have the same number of values

Examples

prob#3

declare function excel:prob(
    $x_range as xs:anyAtomicType+,
    $prob_range as xs:anyAtomicType+,
    $range_lower_limit as xs:anyAtomicType
) as xs:anyAtomicType

This is the same as above, only that upper_limit is not specified. The probability is computed only for range_lower_limit.

Parameters

  • $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.

Returns

  • xs:anyAtomicType

    The probability of the range_lower_limit value

Errors

  • excel-err:Num

    if any probability is not between 0 and 1

  • excel-err:Num

    if the sum of probabilities is not equal to 1

  • excel-err:Value

    if any parameter is not castable to numeric

  • excel-err:Num

    if x_range and prob_range do not have the same number of values

Examples

sum-x-y-deviations#4

declare %:private function excel:sum-x-y-deviations(
    $x_numbers as xs:anyAtomicType*,
    $x_average as xs:anyAtomicType,
    $y_numbers as xs:anyAtomicType*,
    $y_average as xs:anyAtomicType
) as xs:anyAtomicType
Function for SLOPE function. This function should not be used outside this module. It computes the formula:

sum((x - average_x)(y - average_y))

where average_x and average_y are computed with AVERAGE function.

Parameters

  • $x_numbers

    The sequence of x numbers.

  • $x_average

    The precomputed AVERAGE over the x_numbers.

  • $y_numbers

    The sequence of y numbers.

  • $y_average

    The precomputed AVERAGE over the y_numbers.

Returns

  • xs:anyAtomicType

    The formula result, as numeric type.

Errors

  • excel-err:Value

    if any parameter cannot be casted to numeric.

  • fn:QName("http://zorba.io/modules/excel/errors",

    "excel-err:NA") if there are different numbers of x's and y's.

slope#2

declare function excel:slope(
    $known_y as xs:anyAtomicType+,
    $known_x as xs:anyAtomicType+
) as xs:anyAtomicType
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.

Parameters

  • $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.

Returns

  • xs:anyAtomicType

    The slope value, as numeric type

Errors

  • excel-err:Value

    if any parameter cannot be casted to numeric

  • fn:QName("http://zorba.io/modules/excel/errors",

    "excel-err:NA") if there are different numbers of x's and y's

  • fn:QName("http://zorba.io/modules/excel/errors",

    "excel-err:NA") if any sequence is empty

  • excel-err:Div0

    if all x's are equal

Examples

standardize#3

declare function excel:standardize(
    $x as xs:anyAtomicType,
    $mean as xs:anyAtomicType,
    $standard_dev as xs:anyAtomicType
) as xs:double
Returns a normalized value from a distribution characterized by mean and standard_dev.

The formula is (x - mean) / standard_dev .

Parameters

  • $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.

Returns

  • xs:double

    The normalized x, as numeric type

Errors

  • excel-err:Value

    if any parameter cannot be casted to numeric

  • excel-err:Num

    if standard_dev is a value smaller than zero or equal

Examples