# Function library

## core

{"+": [x, y]}
 x any A of {int, long, float, double} y A (returns) A

Details:

• Float and double overflows do not produce runtime errors but result in positive or negative infinity, which would be carried through any subsequent calculations (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values.

Runtime Errors:

• #18000: Integer results above or below -2147483648 and 2147483647 (inclusive) produce an "int overflow" runtime error.
• #18001: Long-integer results above or below -9223372036854775808 and 9223372036854775807 (inclusive) produce a "long overflow" runtime error.

{"-": [x, y]}
 x any A of {int, long, float, double} y A (returns) A

Description: Subtract y from x.

Details:

• Float and double overflows do not produce runtime errors but result in positive or negative infinity, which would be carried through any subsequent calculations (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values.

Runtime Errors:

• #18010: Integer results above or below -2147483648 and 2147483647 (inclusive) produce an "int overflow" runtime error.
• #18011: Long-integer results above or below -9223372036854775808 and 9223372036854775807 (inclusive) produce a "long overflow" runtime error.

{"*": [x, y]}
 x any A of {int, long, float, double} y A (returns) A

Description: Multiply x and y.

Details:

• Float and double overflows do not produce runtime errors but result in positive or negative infinity, which would be carried through any subsequent calculations (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values.

Runtime Errors:

• #18020: Integer results above or below -2147483648 and 2147483647 (inclusive) produce an "int overflow" runtime error.
• #18021: Long-integer results above or below -9223372036854775808 and 9223372036854775807 (inclusive) produce a "long overflow" runtime error.

{"/": [x, y]}
 x double y double (returns) double

Description: Divide y from x, returning a floating-point number (even if x and y are integers).

Details:

• This function returns an infinite value if x is non-zero and y is zero and NaN if both are zero.

{"//": [x, y]}
 x any A of {int, long} y A (returns) A

Description: Divide y from x, returning the largest whole number N for which Nx/y (integral floor division).

Runtime Errors:

• #18040: If y is zero, this function raises a "integer division by zero" runtime error.

{"u-": [x]}
 x any A of {int, long, float, double} (returns) A

Description: Return the additive inverse of x.

Runtime Errors:

• #18050: For exactly one integer value, -2147483648, this function raises an "int overflow" runtime error.
• #18051: For exactly one long value, -9223372036854775808, this function raises a "long overflow" runtime error.

{"%": [k, n]}
 k any A of {int, long, float, double} n A (returns) A

Description: Return k modulo n; the result has the same sign as the modulus n.

Details:

• This is the behavior of the % operator in Python, mod/modulo in Ada, Haskell, and Scheme.

Runtime Errors:

• #18060: If n is zero and k and n are int or long, this function raises a "integer division by zero" runtime error.

{"%%": [k, n]}
 k any A of {int, long, float, double} n A (returns) A

Description: Return the remainder of k divided by n; the result has the same sign as the dividend k.

Details:

• This is the behavior of the % operator in Fortran, C/C++, and Java, rem/remainder in Ada, Haskell, and Scheme.

Runtime Errors:

• #18070: If n is zero and k and n are int or long, this function raises a "integer division by zero" runtime error.

{"**": [x, y]}
 x any A of {int, long, float, double} y A (returns) A

Description: Raise x to the power n.

Details:

• Float and double overflows do not produce runtime errors but result in positive or negative infinity, which would be carried through any subsequent calculations (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values.

Runtime Errors:

• #18080: Integer results above or below -2147483648 and 2147483647 (inclusive) produce an "int overflow" runtime error.
• #18081: Long-integer results above or below -9223372036854775808 and 9223372036854775807 (inclusive) produce a "long overflow" runtime error.

{"cmp": [x, y]}
 x any A y A (returns) int

Description: Return 1 if x is greater than y, -1 if x is less than y, and 0 if x and y are equal.

{"==": [x, y]}
 x any A y A (returns) boolean

Description: Return true if x is equal to y, false otherwise.

{">=": [x, y]}
 x any A y A (returns) boolean

Description: Return true if x is greater than or equal to y, false otherwise.

{">": [x, y]}
 x any A y A (returns) boolean

Description: Return true if x is greater than y, false otherwise.

{"!=": [x, y]}
 x any A y A (returns) boolean

Description: Return true if x is not equal to y, false otherwise.

{"<": [x, y]}
 x any A y A (returns) boolean

Description: Return true if x is less than y, false otherwise.

{"<=": [x, y]}
 x any A y A (returns) boolean

Description: Return true if x is less than or equal to y, false otherwise.

{"max": [x, y]}
 x any A y A (returns) A

Description: Return x if xy, y otherwise.

Details:

• For the maximum of more than two values, see a.max

{"min": [x, y]}
 x any A y A (returns) A

Description: Return x if x < y, y otherwise.

Details:

• For the minimum of more than two values, see a.min

{"&&": [x, y]}
 x boolean y boolean (returns) boolean

Description: Return true if x and y are both true, false otherwise.

Details:

• If x is false, y won't be evaluated. (Only relevant for arguments with side effects.)

{"||": [x, y]}
 x boolean y boolean (returns) boolean

Description: Return true if either x or y (or both) are true, false otherwise.

Details:

• If x is true, y won't be evaluated. (Only relevant for arguments with side effects.)

{"^^": [x, y]}
 x boolean y boolean (returns) boolean

Description: Return true if x is true and y is false or if x is false and y is true, but return false for any other case.

{"!": [x]}
 x boolean (returns) boolean

Description: Return true if x is false and false if x is true.

{"&&&": [x, y]}
 x union of {boolean, null} y union of {boolean, null} (returns) union of {boolean, null}

Description: Return false if x or y is false, true if x and y are true, and null otherwise.

Details:

• This corresponds to Kleene's three-state logic, in which null represents a boolean quantity whose value is unknown.
• If x is false, y won't be evaluated. (Only relevant for arguments with side effects.)

{"|||": [x, y]}
 x union of {boolean, null} y union of {boolean, null} (returns) union of {boolean, null}

Description: Return true if x or y is true, false if both x and y is false, or null otherwise.

Details:

• This corresponds to Kleene's three-state logic, in which null represents a boolean quantity whose value is unknown.
• If x is true, y won't be evaluated. (Only relevant for arguments with side effects.)

{"!!!": [x]}
 x union of {boolean, null} (returns) union of {boolean, null}

Description: Return true if x is false, false if x is true, or null if x is null.

Details:

• This corresponds to Kleene's three-state logic, in which null represents a boolean quantity whose value is unknown.

{"&": [x, y]}
 x int y int (returns) int
{"&": [x, y]}
 x long y long (returns) long

Description: Calculate the bitwise-and of x and y.

{"|": [x, y]}
 x int y int (returns) int
{"|": [x, y]}
 x long y long (returns) long

Description: Calculate the bitwise-or of x and y.

{"^": [x, y]}
 x int y int (returns) int
{"^": [x, y]}
 x long y long (returns) long

Description: Calculate the bitwise-exclusive-or of x and y.

{"~": [x]}
 x int (returns) int
{"~": [x]}
 x long (returns) long

Description: Calculate the bitwise-not of x.

## m

{"m.pi": []}
 (returns) double

Description: The double-precision number that is closer than any other to $$\pi$$, the ratio of a circumference of a circle to its diameter.

{"m.e": []}
 (returns) double

Description: The double-precision number that is closer than any other to $$e$$, the base of natural logarithms.

{"m.abs": [x]}
 x any A of {int, long, float, double} (returns) A

Description: Return the absolute value of x.

Details:

• The domain of this function is the whole real line; no input is invalid.

Runtime Errors:

• #27020: For exactly one integer value, -2147483648, this function produces an "int overflow" runtime error.
• #27021: For exactly one long value, -9223372036854775808, this function produces a "long overflow" runtime error.

{"m.acos": [x]}
 x double (returns) double

Description: Return the arc-cosine (inverse of the cosine function) of x as an angle in radians between $$0$$ and $$\pi$$.

Details:

• The domain of this function is from -1 to 1 (inclusive). Beyond this domain, the result is NaN, not an exception (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values."

{"m.asin": [x]}
 x double (returns) double

Description: Return the arc-sine (inverse of the sine function) of x as an angle in radians between $$-\pi/2$$ and $$\pi/2$$.

Details:

• The domain of this function is from -1 to 1 (inclusive). Beyond this domain, the result is NaN, not an exception (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values."

{"m.atan": [x]}
 x double (returns) double

Description: Return the arc-tangent (inverse of the tangent function) of x as an angle in radians between $$-\pi/2$$ and $$\pi/2$$.

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.atan2": [y, x]}
 y double x double (returns) double

Description: Return the arc-tangent (inverse of the tangent function) of y/x without loss of precision for small x.

Details:

• The domain of this function is the whole real plane; no pair of inputs is invalid.
• Note that y is the first parameter and x is the second parameter.

{"m.ceil": [x]}
 x double (returns) double

Description: Return the smallest (closest to negative infinity, not closest to zero) whole number that is greater than or equal to the input.

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.copysign": [mag, sign]}
 mag any A of {int, long, float, double} sign A (returns) A

Description: Return a number with the magnitude of mag and the sign of sign.

Details:

• The domain of this function is the whole real or integer plane; no pair of inputs is invalid.

{"m.cos": [x]}
 x double (returns) double

Description: Return the trigonometric cosine of x, which is assumed to be in radians.

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.cosh": [x]}
 x double (returns) double

Description: Return the hyperbolic cosine of x, which is equal to $$\frac{e^x + e^{-x}}{2}$$

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.exp": [x]}
 x double (returns) double

Description: Return m.e raised to the power of x.

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.expm1": [x]}
 x double (returns) double

Description: Return $$e^x - 1$$.

Details:

• Avoids round-off or overflow errors in the intermediate steps.
• The domain of this function is the whole real line; no input is invalid.

{"m.floor": [x]}
 x double (returns) double

Description: Return the largest (closest to positive infinity) whole number that is less than or equal to the input.

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.hypot": [x, y]}
 x double y double (returns) double

Description: Return $$\sqrt{x^2 + y^2}$$.

Details:

• Avoids round-off or overflow errors in the intermediate steps.
• The domain of this function is the whole real line; no input is invalid.

{"m.ln": [x]}
 x double (returns) double

Description: Return the natural logarithm of x.

Details:

• The domain of this function is from 0 to infinity (exclusive). Given zero, the result is negative infinity, and below zero, the result is NaN, not an exception (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values."

{"m.log10": [x]}
 x double (returns) double

Description: Return the logarithm base 10 of x.

Details:

• The domain of this function is from 0 to infinity (exclusive). Given zero, the result is negative infinity, and below zero, the result is NaN, not an exception (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values."

{"m.log": [x, base]}
 x double base int (returns) double

Description: Return the logarithm of x with a given base.

Details:

• The domain of this function is from 0 to infinity (exclusive). Given zero, the result is negative infinity, and below zero, the result is NaN, not an exception (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values."

Runtime Errors:

• #27170: If base is less than or equal to zero, this function produces a "base must be positive" runtime error.

{"m.ln1p": [x]}
 x double (returns) double

Description: Return $$ln(x^2 + 1)$$.

Details:

• Avoids round-off or overflow errors in the intermediate steps.
• The domain of this function is from -1 to infinity (exclusive). Given -1, the result is negative infinity, and below -1, the result is NaN, not an exception (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values."

{"m.round": [x]}
 x float (returns) int
{"m.round": [x]}
 x double (returns) long

Description: Return the closest whole number to x, rounding up if the fractional part is exactly one-half.

Details:

• Equal to m.floor of (x + 0.5).

Runtime Errors:

• #27190: Integer results outside of -2147483648 and 2147483647 (inclusive) produce an "int overflow" runtime error.
• #27191: Long-integer results outside of -9223372036854775808 and 9223372036854775807 (inclusive) produce a "long overflow" runtime error.

{"m.rint": [x]}
 x double (returns) double

Description: Return the closest whole number to x, rounding toward the nearest even number if the fractional part is exactly one-half.

{"m.signum": [x]}
 x double (returns) int

Description: Return 0 if x is zero, 1 if x is positive, and -1 if x is negative.

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.sin": [x]}
 x double (returns) double

Description: Return the trigonometric sine of x, which is assumed to be in radians.

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.sinh": [x]}
 x double (returns) double

Description: Return the hyperbolic sine of x, which is equal to $$\frac{e^x - e^{-x}}{2}$$.

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.sqrt": [x]}
 x double (returns) double

Description: Return the positive square root of x.

Details:

• The domain of this function is from 0 (inclusive) to infinity. Beyond this domain, the result is NaN, not an exception (see IEEE 754). Use impute.ensureFinite to produce errors from infinite or NaN values."

{"m.tan": [x]}
 x double (returns) double

Description: Return the trigonometric tangent of x, which is assumed to be in radians.

Details:

• The domain of this function is the whole real line; no input is invalid.

{"m.tanh": [x]}
 x double (returns) double

Description: Return the hyperbolic tangent of x, which is equal to $$\frac{e^x - e^{-x}}{e^x + e^{-x}}$$.

Details:

• The domain of this function is the whole real line; no input is invalid.

## m.special

{"m.special.nChooseK": [n, k]}
 n int k int (returns) int

Description: The number of ways to choose k elements from a set of n elements.

Parameters:

 n Total number of elements. k Numer of elements chosen.

Returns:

 With $$n$$ and $$k$$, this function evaluates the binomial coefficient.

Runtime Errors:

• #36000: Raises "domain error" if $$k \leq 0$$ or $$k \geq n$$.

{"m.special.lnBeta": [a, b]}
 a double b double (returns) double

Description: Compute the beta function parameterized by a and b.

Returns:

 With $$a$$ and $$b$$, this function evaluates natural logarithm of the beta function. The beta function is $$\int_{0}^{1} t^{a - 1}(1 - t)^{b - 1} dt$$.

Runtime Errors:

• #36010: Raises "domain error" if $$a \leq 0$$ or if $$b \leq 0$$.

{"m.special.erf": [x]}
 x double (returns) double

Description: Return the error function of x.

{"m.special.erfc": [x]}
 x double (returns) double

Description: Return the complimentary error function of x.

{"m.special.lnGamma": [x]}
 x double (returns) double

Description: Return the natural log of the gamma function of x.

 x array of double (returns) array of double
 x map of double (returns) map of double

Description: Normalize a prediction with the softmax function.

Returns:

 Each element $$x_i$$ is mapped to $$\exp(x_i)/\sum_j \exp(x_j)$$.

Runtime Errors:

• #25000: If x is an empty array or an empty map, this function raises an "empty input" error.

 x double (returns) double
 x array of double (returns) array of double
 x map of double (returns) map of double

Description: Normalize a prediction with the logit function.

Returns:

 Each element $$x_i$$ is mapped to $$1 / (1 + \exp(-x_i))$$.

 x double (returns) double
 x array of double (returns) array of double
 x map of double (returns) map of double

Description: Normalize a prediction with the probit function.

Returns:

 Each element $$x_i$$ is mapped to $$(\mbox{erf}(x_i/\sqrt{2}) + 1)/2$$.

 x double (returns) double
 x array of double (returns) array of double
 x map of double (returns) map of double

Description: Normalize a prediction with the cloglog function.

Returns:

 Each element $$x_i$$ is mapped to $$1 - \exp(-\exp(x_i))$$.

 x double (returns) double
 x array of double (returns) array of double
 x map of double (returns) map of double

Description: Normalize a prediction with the loglog function.

Returns:

 Each element $$x_i$$ is mapped to $$\exp(-\exp(x_i))$$.

 x double (returns) double
 x array of double (returns) array of double
 x map of double (returns) map of double

Description: Normalize a prediction with the cauchit function.

Returns:

 Each element $$x_i$$ is mapped to $$0.5 + (1/\pi) \tan^{-1}(x_i)$$.

 x double (returns) double
 x array of double (returns) array of double
 x map of double (returns) map of double

Description: Normalize a prediction with the softplus function.

Returns:

 Each element $$x_i$$ is mapped to $$\log(1.0 + \exp(x_i))$$.

 x double (returns) double
 x array of double (returns) array of double
 x map of double (returns) map of double

Description: Normalize a prediction with the rectified linear unit (ReLu) function.

Returns:

 Each element $$x_i$$ is mapped to $$\log(1.0 + \exp(x_i))$$.

 x double (returns) double
 x array of double (returns) array of double
 x map of double (returns) map of double

Description: Normalize a prediction with the hyperbolic tangent function.

Returns:

 Each element $$x_i$$ is mapped to $$\tanh(x_i)$$.

## m.kernel

{"m.kernel.linear": [x, y]}
 x array of double y array of double (returns) double

Description: Linear kernel function.

Parameters:

 x Length n vector. y Length n vector.

Returns:

 Returns the dot product of x and y, $$\sum_{i=1}^{n} x_{i} y_{j}$$.

Runtime Errors:

• #23000: Raises a "arrays must have same length" error if the lengths of x and y are not the same.

{"m.kernel.rbf": [x, y, gamma]}
 x array of double y array of double gamma double (returns) double

Description: Radial Basis Function (RBF) kernel function.

Parameters:

 x Length n vector. y Length n vector. gamma Gamma coefficient.

Returns:

 Returns the result of $$\mathrm{exp}(-\gamma || x - y ||^{2})$$.

Runtime Errors:

• #23010: Raises a "arrays must have same length" error if the lengths of x and y are not the same.

{"m.kernel.poly": [x, y, gamma, intercept, degree]}
 x array of double y array of double gamma double intercept double degree double (returns) double

Description: Polynomial kernel function.

Parameters:

 x Length n vector. y Length n vector. gamma Gamma coefficient. intecept Intercept constant. degree Degree of the polynomial kernel.

Returns:

 Returns the result of $$(\gamma \sum_{i=1}^{n} x_{i} y_{j} + \mathrm{intercept})^{\mathrm{degree}}$$.

Runtime Errors:

• #23020: Raises a "arrays must have same length" error if the lengths of x and y are not the same.

{"m.kernel.sigmoid": [x, y, gamma, intercept]}
 x array of double y array of double gamma double intercept double (returns) double

Description: Sigmoid kernel function.

Parameters:

 x Length n vector. y Length n vector. gamma Gamma coefficient. intecept Intercept constant.

Returns:

 Returns the result of $$\mathrm{tanh}( \mathrm{gamma} \sum_{i=1}^{n} x_{i} y_{j} + \mathrm{intercept})$$.

Runtime Errors:

• #23030: Raises a "arrays must have same length" error if the lengths of x and y are not the same.

## la

{"la.map": [x, fcn]}
 x array of array of double fcn function of (double) → double (returns) array of array of double
{"la.map": [x, fcn]}
 x map of map of double fcn function of (double) → double (returns) map of map of double

Description: Apply fcn to each element from x.

Details:

• This can be used to perform scalar multiplication on a matrix: supply a function that multiplies each element by a constant.
• The order in which elements are computed is not specified, and may be in parallel.

{"la.scale": [x, alpha]}
 x array of double alpha double (returns) array of double
{"la.scale": [x, alpha]}
 x array of array of double alpha double (returns) array of array of double
{"la.scale": [x, alpha]}
 x map of double alpha double (returns) map of double
{"la.scale": [x, alpha]}
 x map of map of double alpha double (returns) map of map of double

Description: Scale vector or matrix x by factor alpha.

Details:

• The order in which elements are computed is not specified, and may be in parallel.

{"la.zipmap": [x, y, fcn]}
 x array of array of double y array of array of double fcn function of (double, double) → double (returns) array of array of double
{"la.zipmap": [x, y, fcn]}
 x map of map of double y map of map of double fcn function of (double, double) → double (returns) map of map of double

Description: Apply fcn to each pair of elements from x and y.

Details:

• This can be used to perform matrix addition: supply a function that adds each pair of elements.
• Like most functions that deal with matrices, this function has an array signature and a map signature. In the array signature, the number of rows and columns in x must be equal to the number of rows and columns of y, respectively (dense matrix). In the map signature, missing row-column combinations are assumed to be zero (sparse matrix).
• The order in which elements are computed is not specified, and may be in parallel.

Runtime Errors:

• #24020: In the array signature, if any element in x does not have a corresponding element in y (or vice-versa), this function raises a "misaligned matrices" error.

 x array of double y array of double (returns) array of double
 x array of array of double y array of array of double (returns) array of array of double
 x map of double y map of double (returns) map of double
 x map of map of double y map of map of double (returns) map of map of double

Description: Add two vectors or matrices x and y.

Details:

• The order in which elements are computed is not specified, and may be in parallel.
• Like most functions that deal with matrices, this function has an array signature and a map signature. In the array signature, the number of rows and/or columns in x must be equal to the number of rows and/or columns of y, respectively (dense matrix). In the map signature, missing row-column combinations are assumed to be zero (sparse matrix).

Runtime Errors:

• #24030: In the array signature, if any element in x does not have a corresponding element in y (or vice-versa), this function raises a "misaligned matrices" error.

{"la.sub": [x, y]}
 x array of double y array of double (returns) array of double
{"la.sub": [x, y]}
 x array of array of double y array of array of double (returns) array of array of double
{"la.sub": [x, y]}
 x map of double y map of double (returns) map of double
{"la.sub": [x, y]}
 x map of map of double y map of map of double (returns) map of map of double

Description: Subtract vector or matrix y from x (returns $$x - y$$).

Details:

• The order in which elements are computed is not specified, and may be in parallel.
• Like most functions that deal with matrices, this function has an array signature and a map signature. In the array signature, the number of rows and/or columns in x must be equal to the number of rows and/or columns of y, respectively (dense matrix). In the map signature, missing row-column combinations are assumed to be zero (sparse matrix).

Runtime Errors:

• #24040: In the array signature, if any element in x does not have a corresponding element in y (or vice-versa), this function raises a "misaligned matrices" error.

{"la.dot": [x, y]}
 x array of array of double y array of double (returns) array of double
{"la.dot": [x, y]}
 x map of map of double y map of double (returns) map of double
{"la.dot": [x, y]}
 x array of array of double y array of array of double (returns) array of array of double
{"la.dot": [x, y]}
 x map of map of double y map of map of double (returns) map of map of double

Description: Multiply two matrices or a matrix and a vector, which may be represented as dense arrays or potentially sparse maps.

Details:

• Like most functions that deal with matrices, this function has an array signature and a map signature. In the array signature, the number of columns of x must be equal to the number of rows (or the number of elements) of y (dense matrix). In the map signature, missing values are assumed to be zero (sparse matrix).
• Matrices supplied as maps may be computed using sparse methods.

Runtime Errors:

• #24050: In the array signature, if the dimensions of x do not correspond to the dimension(s) of y, this function raises a "misaligned matrices" error.
• #24051: If x or y has fewer than 1 row or fewer than 1 column, this function raises a "too few rows/cols" error.
• #24052: If x or y contains any non-finite values, this function raises a "contains non-finite value" error.

{"la.transpose": [x]}
 x array of array of double (returns) array of array of double
{"la.transpose": [x]}
 x map of map of double (returns) map of map of double

Description: Transpose a rectangular matrix.

Runtime Errors:

• #24060: If the matrix has fewer than 1 row or fewer than 1 column, this function raises a "too few rows/cols" error.
• #24061: If the columns are ragged (arrays of different lengths or maps with different sets of keys), this function raises a "ragged columns" error.

{"la.inverse": [x]}
 x array of array of double (returns) array of array of double
{"la.inverse": [x]}
 x map of map of double (returns) map of map of double

Description: Compute the inverse (or Moore-Penrose pseudoinverse, if not square) of x.

Runtime Errors:

• #24070: If the matrix has fewer than 1 row or fewer than 1 column, this function raises a "too few rows/cols" error.
• #24071: If x is an array with ragged columns (arrays of different lengths), this function raises a "ragged columns" error.

{"la.trace": [x]}
 x array of array of double (returns) double
{"la.trace": [x]}
 x map of map of double (returns) double

Description: Compute the trace of a matrix (sum of diagonal elements).

Runtime Errors:

• #24080: If x is an array with ragged columns (arrays of different lengths), this function raises a "ragged columns" error.

{"la.det": [x]}
 x array of array of double (returns) double
{"la.det": [x]}
 x map of map of double (returns) double

Description: Compute the determinant of a matrix.

Runtime Errors:

• #24090: If the matrix has fewer than 1 row or fewer than 1 column, this function raises a "too few rows/cols" error.
• #24091: If x is an array with ragged columns (arrays of different lengths), this function raises a "ragged columns" error.
• #24092: In the array signature, if x is not a square matrix, this function raises a "non-square matrix" error.

{"la.symmetric": [x, tolerance]}
 x array of array of double tolerance double (returns) boolean
{"la.symmetric": [x, tolerance]}
 x map of map of double tolerance double (returns) boolean

Description: Determine if a matrix is symmetric withing tolerance.

Returns:

 Returns true if the absolute value of element $$i$$, $$j$$ minus element $$j$$, $$i$$ is less than tolerance.

Runtime Errors:

• #24100: If the matrix has fewer than 1 row or fewer than 1 column, this function raises a "too few rows/cols" error.
• #24101: If x is an array with ragged columns (arrays of different lengths), this function raises a "ragged columns" error.
• #24102: If x is not a square matrix, this function raises a "non-square matrix" error.

{"la.eigenBasis": [x]}
 x array of array of double (returns) array of array of double
{"la.eigenBasis": [x]}
 x map of map of double (returns) map of map of double

Description: Compute the eigenvalues and eigenvectors of a real, symmetric matrix x (which are all real).

Returns:

 A matrix in which each row (first level of array or map hierarchy) is a normalized eigenvector of x divided by the square root of the corresponding eigenvalue (The sign is chosen such that the first component is positive.). If provided as an array, the rows are in decreasing order of eigenvalue (increasing order of inverse square root eigenvalue). If provided as a map, the rows are keyed by string representations of integers starting with "0", and increasing row keys are in decreasing order of eigenvalue.

Details:

• If x is the covariance matrix of a zero-mean dataset, the matrix that this function returns would transform the dataset to one with unit variances and zero covariances.
• If x is not symmetric or not exactly symmetric, it will first be symmetrized ($$(x + x^T)/2$$). For example, a matrix represented by only the upper triangle (other elements are zero or missing from the map) becomes a symmetric matrix with the upper triangle unchanged.
• Nondeterministic: unstable. This function gives the same results every time it is executed, but those results may not be exactly the same on all systems.

Runtime Errors:

• #24110: If the matrix has fewer than 1 row or fewer than 1 column, this function raises a "too few rows/cols" error.
• #24111: If x is an array with ragged columns (arrays of different lengths), this function raises a "ragged columns" error.
• #24112: If x is not a square matrix, this function raises a "non-square matrix" error.
• #24113: If x contains non-finite values, this function raises a "non-finite matrix" error.

{"la.truncate": [x, keep]}
 x array of array of double keep int (returns) array of array of double
{"la.truncate": [x, keep]}
 x map of map of double keep array of string (returns) map of map of double

Description: Remove rows from a matrix so that it becomes a projection operator.

Parameters:

 x The matrix to truncate. keep If x is an array, this is the number of rows to keep, starting with the first row. If x is a map, this is the set of keys to keep. If keep is larger than the number of rows or is not a subset of the keys, the excess is ignored.

Details:

• In Principle Component Analysis (PCA), this would be applied to the eigenbasis transformation (la.eigenBasis) to keep only a specified number (or set) of transformed components.

Runtime Errors:

• #24120: If the matrix has fewer than 1 row or fewer than 1 column, this function raises a "too few rows/cols" error.
• #24121: If x is an array with ragged columns (arrays of different lengths), this function raises a "ragged columns" error.

## metric

{"metric.simpleEuclidean": [x, y]}
 x array of double y array of double (returns) double

Description: Euclidean metric without a special similarity function and without any handling of missing values.

Parameters:

 x First sample vector. y Second sample vector. (Must have the same dimension as x.)

Returns:

 Returns $$\sqrt{\sum_i (x_i - y_i)^2}$$.

Runtime Errors:

• #28000: Raises "dimensions of vectors do not match" if all vectors do not have the same dimension.

{"metric.absDiff": [x, y]}
 x double y double (returns) double

Description: Similarity function (1-dimensional metric) that returns the absolute Euclidean distance between x and y.

{"metric.gaussianSimilarity": [x, y, sigma]}
 x double y double sigma double (returns) double

Description: Similarity function (1-dimensional metric) that returns $$\exp(-\ln(2) (x - y)^2 / \mbox{sigma}^2)$$.

{"metric.euclidean": [similarity, x, y]}
 similarity function of (any A, any B) → double x array of union of {null, A} y array of union of {null, B} (returns) double
{"metric.euclidean": [similarity, x, y, missingWeight]}
 similarity function of (any A, any B) → double x array of union of {null, A} y array of union of {null, B} missingWeight array of double (returns) double

Description: Euclidean metric, which is the distance function for ordinary space, given by the Pythagorean formula (also known as the 2-norm).

Parameters:

 similarity Similarity function (1-dimensional metric) that quantifies the distance between components of x and components of y. x First sample vector, which may have missing values. y Second sample vector, which may have missing values. (Must have the same dimension as x.) missingWeight Optional missing-value weights: a vector with the same dimension as x and y that determines the normalized contribution of missing values in the sum. If not provided, missing-value weights of 1.0 are assumed.

Returns:

 With $$I(x_i,y_i)$$ = 0 if component $$i$$ of x or y is missing, 1 otherwise, this function returns $$\sqrt{(\sum_i I(x_i,y_i) \mbox{similarity}(x_i,y_i)^2)(\sum_i q_i)/(\sum_i I(x_i,y_i) q_i)}$$ where $$q_i$$ are components of the missing-value weights. Without missing values, it is $$\sqrt{\sum_i \mbox{similarity}(x_i,y_i)^2}$$.

Details:

• If all values are missing, the function returns NaN.

Runtime Errors:

• #28030: Raises "dimensions of vectors do not match" if all vectors do not have the same dimension.

{"metric.squaredEuclidean": [similarity, x, y]}
 similarity function of (double, double) → double x array of union of {null, double} y array of union of {null, double} (returns) double
{"metric.squaredEuclidean": [similarity, x, y, missingWeight]}
 similarity function of (double, double) → double x array of union of {null, double} y array of union of {null, double} missingWeight array of double (returns) double

Description: Euclidean metric squared, which has the same ordering as the Euclidean metric, but avoids a square root calculation.

Parameters:

 similarity Similarity function (1-dimensional metric) that quantifies the distance between components of x and components of y. x First sample vector, which may have missing values. y Second sample vector, which may have missing values. (Must have the same dimension as x.) missingWeight Optional missing-value weights: a vector with the same dimension as x and y that determines the normalized contribution of missing values in the sum. If not provided, missing-value weights of 1.0 are assumed.

Returns:

 With $$I(x_i,y_i)$$ = 0 if component $$i$$ of x or y is missing, 1 otherwise, this function returns $$(\sum_i I(x_i,y_i) \mbox{similarity}(x_i,y_i)^2)(\sum_i q_i)/(\sum_i I(x_i,y_i) q_i)$$ where $$q_i$$ are components of the missing-value weights. Without missing values, it is $$\sum_i \mbox{similarity}(x_i,y_i)^2$$.

Details:

• If all values are missing, the function returns NaN.

Runtime Errors:

• #28040: Raises "dimensions of vectors do not match" if all vectors do not have the same dimension.

{"metric.chebyshev": [similarity, x, y]}
 similarity function of (double, double) → double x array of union of {null, double} y array of union of {null, double} (returns) double
{"metric.chebyshev": [similarity, x, y, missingWeight]}
 similarity function of (double, double) → double x array of union of {null, double} y array of union of {null, double} missingWeight array of double (returns) double

Description: Chebyshev metric, also known as the infinity norm or chessboard distance (since it is the number of moves required for a chess king to travel between two points).

Parameters:

 similarity Similarity function (1-dimensional metric) that quantifies the distance between components of x and components of y. x First sample vector, which may have missing values. y Second sample vector, which may have missing values. (Must have the same dimension as x.) missingWeight Optional missing-value weights: a vector with the same dimension as x and y that determines the normalized contribution of missing values in the sum. If not provided, missing-value weights of 1.0 are assumed.

Returns:

 With $$I(x_i,y_i)$$ = 0 if component $$i$$ of x or y is missing, 1 otherwise, this function returns $$(\max_i I(x_i,y_i) \mbox{similarity}(x_i,y_i))(\sum_i q_i)/(\sum_i I(x_i,y_i) q_i)$$ where $$q_i$$ are components of the missing-value weights. Without missing values, it is $$\max_i \mbox{similarity}(x_i,y_i)$$.

Details:

• If all values are missing, the function returns NaN.

Runtime Errors:

• #28050: Raises "dimensions of vectors do not match" if all vectors do not have the same dimension.

{"metric.taxicab": [similarity, x, y]}
 similarity function of (double, double) → double x array of union of {null, double} y array of union of {null, double} (returns) double
{"metric.taxicab": [similarity, x, y, missingWeight]}
 similarity function of (double, double) → double x array of union of {null, double} y array of union of {null, double} missingWeight array of double (returns) double

Description: Taxicab metric, also known as the 1-norm, city-block or Manhattan distance (since it is the distance when confined to a rectilinear city grid).

Parameters:

 similarity Similarity function (1-dimensional metric) that quantifies the distance between components of x and components of y. x First sample vector, which may have missing values. y Second sample vector, which may have missing values. (Must have the same dimension as x.) missingWeight Optional missing-value weights: a vector with the same dimension as x and y that determines the normalized contribution of missing values in the sum. If not provided, missing-value weights of 1.0 are assumed.

Returns:

 With $$I(x_i,y_i)$$ = 0 if component $$i$$ of x or y is missing, 1 otherwise, this function returns $$(\sum_i I(x_i,y_i) \mbox{similarity}(x_i,y_i))(\sum_i q_i)/(\sum_i I(x_i,y_i) q_i)$$ where $$q_i$$ are components of the missing-value weights. Without missing values, it is $$\sum_i \mbox{similarity}(x_i,y_i)$$.

Details:

• If all values are missing, the function returns NaN.

Runtime Errors:

• #28060: Raises "dimensions of vectors do not match" if all vectors do not have the same dimension.

{"metric.minkowski": [similarity, x, y, p]}
 similarity function of (double, double) → double x array of union of {null, double} y array of union of {null, double} p double (returns) double
{"metric.minkowski": [similarity, x, y, p, missingWeight]}
 similarity function of (double, double) → double x array of union of {null, double} y array of union of {null, double} p double missingWeight array of double (returns) double

Description: Minkowski metric, also known as the p-norm, a generalized norm whose limits include Euclidean, Chebyshev, and Taxicab.

Parameters:

 similarity Similarity function (1-dimensional metric) that quantifies the distance between components of x and components of y. x First sample vector, which may have missing values. y Second sample vector, which may have missing values. (Must have the same dimension as x.) missingWeight Optional missing-value weights: a vector with the same dimension as x and y that determines the normalized contribution of missing values in the sum. If not provided, missing-value weights of 1.0 are assumed.

Returns:

 With $$I(x_i,y_i)$$ = 0 if component $$i$$ of x or y is missing, 1 otherwise, this function returns $$((\sum_i I(x_i,y_i) \mbox{similarity}(x_i,y_i)^p)(\sum_i q_i)/(\sum_i I(x_i,y_i) q_i))^{1/p}$$ where $$q_i$$ are components of the missing-value weights. Without missing values, it is $$(\sum_i \mbox{similarity}(x_i,y_i)^p)^{1/p}$$.

Details:

• If all values are missing, the function returns NaN.
• If p is positive infinity, this function is equivalent to metric.chebyshev.

Runtime Errors:

• #28070: Raises "dimensions of vectors do not match" if all vectors do not have the same dimension.
• #28071: Raises "Minkowski parameter p must be positive" if p is less than or equal to zero.

{"metric.simpleMatching": [x, y]}
 x array of boolean y array of boolean (returns) double

Description: Simple metric on binary vectors.

Parameters:

 x First sample vector. y Second sample vector. (Must have the same dimension as x.)

Returns:

 Where $$a_{11}$$ is the number of x, y coordinate pairs that are equal to true, true, $$a_{10}$$ is the number of true, false, $$a_{01}$$ is the number of false, true, and $$a_{00}$$ is the number of false, false, this function returns $$(a_{11} + a_{00})/(a_{11} + a_{10} + a_{01} + a_{00})$$.

Runtime Errors:

• #28080: Raises "dimensions of vectors do not match" if x and y do not have the same dimension.

{"metric.jaccard": [x, y]}
 x array of boolean y array of boolean (returns) double

Description: Jaccard similarity of binary vectors.

Parameters:

 x First sample vector. y Second sample vector. (Must have the same dimension as x.)

Returns:

 Where $$a_{11}$$ is the number of x, y coordinate pairs that are equal to true, true, $$a_{10}$$ is the number of true, false, $$a_{01}$$ is the number of false, true, and $$a_{00}$$ is the number of false, false, this function returns $$a_{11}/(a_{11} + a_{10} + a_{01})$$.

Runtime Errors:

• #28090: Raises "dimensions of vectors do not match" if x and y do not have the same dimension.

{"metric.tanimoto": [x, y]}
 x array of boolean y array of boolean (returns) double

Description: Tanimoto similarity of binary vectors.

Parameters:

 x First sample vector. y Second sample vector. (Must have the same dimension as x.)

Returns:

 Where $$a_{11}$$ is the number of x, y coordinate pairs that are equal to true, true, $$a_{10}$$ is the number of true, false, $$a_{01}$$ is the number of false, true, and $$a_{00}$$ is the number of false, false, this function returns $$(a_{11} + a_{00})/(a_{11} + 2*(a_{10} + a_{01}) + a_{00})$$.

Runtime Errors:

• #28100: Raises "dimensions of vectors do not match" if x and y do not have the same dimension.

{"metric.binarySimilarity": [x, y, c00, c01, c10, c11, d00, d01, d10, d11]}
 x array of boolean y array of boolean c00 double c01 double c10 double c11 double d00 double d01 double d10 double d11 double (returns) double

Description: Genaralized similarity of binary vectors, using c00, c01, c10, c11, d00, d01, d10, and d11 as parameters to reproduce all other binary similarity metrics.

Parameters:

 x First sample vector. y Second sample vector. (Must have the same dimension as x.)

Returns:

 Where $$a_{11}$$ is the number of x, y coordinate pairs that are equal to true, true, $$a_{10}$$ is the number of true, false, $$a_{01}$$ is the number of false, true, and $$a_{00}$$ is the number of false, false, this function returns $$(c_{11}a_{11} + c_{10}a_{10} + c_{01}a_{01} + c_{00}a_{00})/(d_{11}a_{11} + d_{10}a_{10} + d_{01}a_{01} + d_{00}a_{00})$$.

Runtime Errors:

• #28110: Raises "dimensions of vectors do not match" if x and y do not have the same dimension.

## rand

{"rand.int": []}
 (returns) int
{"rand.int": [low, high]}
 low int high int (returns) int

Description: Return a random integer, either on the entire entire 32-bit range or between low (inclusive) and high (exclusive).

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34000: Raises a "high must be greater than low" error if high is less than or equal to low.

{"rand.long": []}
 (returns) long
{"rand.long": [low, high]}
 low long high long (returns) long

Description: Return a random long integer, either on the entire 64-bit range or between low (inclusive) and high (exclusive).

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34010: Raises a "high must be greater than low" error if high is less than or equal to low.

{"rand.float": [low, high]}
 low float high float (returns) float

Description: Return a random float between low and high.

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34020: Raises a "high must be greater than low" error if high is less than or equal to low.

{"rand.double": [low, high]}
 low double high double (returns) double

Description: Return a random double between low and high.

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34030: Raises a "high must be greater than low" error if high is less than or equal to low.

{"rand.choice": [population]}
 population array of any A (returns) A

Description: Return a random item from a bag of items.

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34040: Raises a "population must not be empty" error if population is empty.

{"rand.choices": [size, population]}
 size int population array of any A (returns) array of A

Description: Return an array of random items (with replacement) from a bag of items.

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34050: Raises a "population must not be empty" error if population is empty.

{"rand.sample": [size, population]}
 size int population array of any A (returns) array of A

Description: Return an array of random items (without replacement) from a bag of items.

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34060: Raises a "population must not be empty" error if population is empty.
• #34061: Raises a "population smaller than requested subsample" error if the size of population is less than size.

{"rand.histogram": [distribution]}
 distribution array of double (returns) int
{"rand.histogram": [distribution]}
 distribution array of any record A with fields {prob: double} (returns) A

Description: Return a random index of distribution with probability proportional to the value of that index or a random item from distribution with probability proportional to the prob field.

Details:

• If the probabilities do not sum to 1.0, they will be normalized first.
• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34070: Raises a "distribution must be non-empty" error if no items of distribution are non-zero.
• #34071: Raises a "distribution must be finite" error if any items of distribution are infinite or NaN.
• #34072: Raises a "distribution must be non-negative" error if any items of distribution are negative.

{"rand.string": [size]}
 size int (returns) string
{"rand.string": [size, population]}
 size int population string (returns) string
{"rand.string": [size, low, high]}
 size int low int high int (returns) string

Description: Return a random string with size characters from a range, if provided.

Parameters:

 size Number of characters in the resulting string. population Bag of characters to choose from. Characters repeated $$N$$ times in the population have probability $$N$$/size, but order is irrelevant. low Minimum code-point to sample (inclusive). high Maximum code-point to sample (exclusive).

Details:

• Without a range, this function samples the entire Unicode table up to and including 0xD800; ASCII characters are rare.
• The ASCII printable range is low = 33, high = 127.
• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34080: Raises a "size must be positive" error if size is less than or equal to zero.
• #34081: Raises a "high must be greater than low" error if high is less than or equal to low.
• #34082: Raises an "invalid char" error if low is less than 1 or greater than 0xD800 or if high is less than 1 or greater than 0xD800.
• #34083: Raises an "population must be non-empty" error if population is empty.

{"rand.bytes": [size]}
 size int (returns) bytes
{"rand.bytes": [size, population]}
 size int population bytes (returns) bytes
{"rand.bytes": [size, low, high]}
 size int low int high int (returns) bytes

Description: Return size random bytes from a range, if provided.

Parameters:

 size Number of bytes in the result. population Bag of bytes to choose from. Bytes repeated $$N$$ times in the population have probability $$N$$/size, but order is irrelevant. low Minimum byte value to sample (inclusive). high Maximum byte value to sample (exclusive).

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #34090: Raises a "size must be positive" error if size is less than or equal to zero.
• #34091: Raises a "high must be greater than low" error if high is less than or equal to low.
• #34092: Raises an "invalid byte" error if low is less than 0 or greater than 255 or if high is less than 0 or greater than 256.
• #34093: Raises an "population must be non-empty" error if population is empty.

{"rand.uuid": []}
 (returns) string
Deprecated; exists until PFA 0.9.0: use rand.uuid4 instead.

Description: Return a random (type 4) UUID with IETF variant (8).

Returns:

 The return value is a string with the form xxxxxxxx-xxxx-4xxx-8xxx-xxxxxxxxxxxx where x are random, lowercase hexidecimal digits (0-9a-f), 4 is the version, and 8 is the IETF variant.

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

{"rand.uuid4": []}
 (returns) string

Description: Return a random (type 4) UUID with IETF variant (8).

Returns:

 The return value is a string with the form xxxxxxxx-xxxx-4xxx-8xxx-xxxxxxxxxxxx where x are random, lowercase hexidecimal digits (0-9a-f), 4 is the version, and 8 is the IETF variant.

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

{"rand.gaussian": [mu, sigma]}
 mu double sigma double (returns) double

Description: Return a random number from a Gaussian (normal) distribution with mean mu and standard deviation sigma.

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

## s

{"s.len": [s]}
 s string (returns) int

Description: Return the length of string s.

{"s.substr": [s, start, end]}
 s string start int end int (returns) string

Description: Return the substring of s from start (inclusive) until end (exclusive).

Details:

• Negative indexes count from the right (-1 is just before the last item), indexes beyond the legal range are truncated, and endstart specifies a zero-length subsequence just before the start character. All of these rules follow Python's slice behavior.

{"s.substrto": [s, start, end, replacement]}
 s string start int end int replacement string (returns) string

Description: Replace s from start (inclusive) until end (exclusive) with replacement.

Details:

• Negative indexes count from the right (-1 is just before the last item), indexes beyond the legal range are truncated, and endstart specifies a zero-length subsequence just before the start character. All of these rules follow Python's slice behavior.

{"s.contains": [haystack, needle]}
 haystack string needle string (returns) boolean

Description: Return true if haystack contains needle, false otherwise.

{"s.count": [haystack, needle]}
 haystack string needle string (returns) int

Description: Count the number of times needle appears in haystack.

Details:

• If the needle is an empty string, the result is zero.

{"s.index": [haystack, needle]}
 haystack string needle string (returns) int

Description: Return the lowest index where haystack contains needle or -1 if haystack does not contain needle.

{"s.rindex": [haystack, needle]}
 haystack string needle string (returns) int

Description: Return the highest index where haystack contains needle or -1 if haystack does not contain needle.

{"s.startswith": [haystack, needle]}
 haystack string needle string (returns) boolean

Description: Return true if the first (leftmost) subseqence of haystack is equal to needle, false otherwise.

{"s.endswith": [haystack, needle]}
 haystack string needle string (returns) boolean

Description: Return true if the last (rightmost) subseqence of haystack is equal to needle, false otherwise.

{"s.join": [array, sep]}
 array array of string sep string (returns) string

Description: Combine strings from array into a single string, delimited by sep.

{"s.split": [s, sep]}
 s string sep string (returns) array of string

Description: Divide a string into an array of substrings, splitting at and removing delimiters sep.

Details:

• If s does not contain sep, this function returns an array whose only element is s. If sep appears at the beginning or end of s, the array begins with or ends with an empty string. These conventions match Python's behavior.
• If sep is an empty string, this function returns an empty array.

{"s.hex": [x]}
 x long (returns) string
 x long width int zeroPad boolean (returns) string

Description: Format an unsigned number as a hexidecimal string.

Parameters:

 x The number. width Width of the string. If negative, left-justify. If omitted, the string will be as wide as it needs to be to provide the precision. zeroPad If true, pad the integer with zeros to fill up to width.

Details:

• If the precision requires more space than width, the string will be wide enough to accommodate the precision.
• Digits "a" (decimal 10) through "f" (decimal 15) are represented by lowercase letters.

Runtime Errors:

• #39110: If width is negative and zeroPad is true, a "negative width cannot be used with zero-padding" error is raised.
• #39111: If x is negative, a "negative number" error is raised.

{"s.int": [x]}
 x long (returns) string
 x long width int zeroPad boolean (returns) string

Description: Format an integer as a decimal string.

Parameters:

 x The integer. width Width of the string. If negative, left-justify. If omitted, the string will be as wide as it needs to be to provide enough precision. zeroPad If true, pad the integer with zeros to fill up to width.

Runtime Errors:

• #39240: If width is negative and zeroPad is true, a "negative width cannot be used with zero-padding" error is raised.

{"s.number": [x]}
 x long (returns) string
Deprecated; exists until PFA 0.9.0: use s.int for integers.
 x long width int zeroPad boolean (returns) string
Deprecated; exists until PFA 0.9.0: use s.int for integers.
{"s.number": [x, width, precision]}
 x double width union of {int, null} precision union of {int, null} (returns) string
{"s.number": [x, width, precision, minNoExp, maxNoExp]}
 x double width union of {int, null} precision union of {int, null} minNoExp double maxNoExp double (returns) string

Description: Format a number as a decimal string.

Parameters:

 x The number. Note that different signatures apply to integers and floating point numbers. width Width of the string. If negative, left-justify. If omitted, the string will be as wide as it needs to be to provide the precision. zeroPad If true, pad the integer with zeros to fill up to width. precision Optional precision with which to represent the number. If omitted, at most six digits after the decimal point will be shown, unless they are zero. minNoExp Minimum absolute value that is not presented in scientific notation; 0.0001 if omitted. maxNoExp Maxiumum absolute value that is not presented in scientific notation; 100000 if omitted.

Details:

• If the precision requires more space than width, the string will be wide enough to accommodate the precision.
• Floating point numbers always have a decimal point with at least one digit after the decimal, even if it is zero.
• Exponents are represented by a lowercase "e" which is always followed by a sign, whether positive or negative, and an exponent of two or more digits (single-digit exponents are zero-padded).
• The base of a number is preceded by a "-" if negative, but not a "+" if positive.
• Special floating point values are represented in the following ways: negative zero as zero (no negative sign), not a number as "nan", positive infinity as "inf", and negative infinity as "-inf" (lowercase). They follow the same precision and width rules as normal numbers, where applicable.
• Nondeterministic: unstable. This function gives the same results every time it is executed, but those results may not be exactly the same on all systems.

Runtime Errors:

• #39120: If width is negative and zeroPad is true, a "negative width cannot be used with zero-padding" error is raised.
• #39121: If precision is provided and is less than zero, a "negative precision" error is raised.

{"s.concat": [x, y]}
 x string y string (returns) string

Description: Append y to x to form a single string.

Details:

• To concatenate an array of strings, use s.join with an empty string as sep.

{"s.repeat": [s, n]}
 s string n int (returns) string

Description: Create a string by concatenating s with itself n times.

{"s.lower": [s]}
 s string (returns) string

Description: Convert s to lower-case.

{"s.upper": [s]}
 s string (returns) string

Description: Convert s to upper-case.

{"s.lstrip": [s, chars]}
 s string chars string (returns) string

Description: Remove any characters found in chars from the beginning (left) of s.

Details:

• The order of characters in chars is irrelevant.

{"s.rstrip": [s, chars]}
 s string chars string (returns) string

Description: Remove any characters found in chars from the end (right) of s.

Details:

• The order of characters in chars is irrelevant.

{"s.strip": [s, chars]}
 s string chars string (returns) string

Description: Remove any characters found in chars from the beginning or end of s.

Details:

• The order of characters in chars is irrelevant.

{"s.replaceall": [s, original, replacement]}
 s string original string replacement string (returns) string

Description: Replace every instance of the substring original from s with replacement.

{"s.replacefirst": [s, original, replacement]}
 s string original string replacement string (returns) string

Description: Replace the first (leftmost) instance of the substring original from s with replacement.

{"s.replacelast": [s, original, replacement]}
 s string original string replacement string (returns) string

Description: Replace the last (rightmost) instance of the substring original from s with replacement.

{"s.translate": [s, oldchars, newchars]}
 s string oldchars string newchars string (returns) string

Description: For each character in s that is also in oldchars with some index i, replace it with the character at index i in newchars. Any character in s that is not in oldchars is unchanged. Any index i that is greater than the length of newchars is replaced with nothing.

Details:

• This is the behavior of the the Posix command tr, where s takes the place of standard input and oldchars and newchars are the tr commandline options.

## re

{"re.index": [haystack, pattern]}
 haystack string pattern string (returns) array of int
{"re.index": [haystack, pattern]}
 haystack bytes pattern bytes (returns) array of int

Description: Return the indices in haystack of the begining and end of the first match defined by pattern.

Runtime Errors:

• #35000: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.contains": [haystack, pattern]}
 haystack string pattern string (returns) boolean
{"re.contains": [haystack, pattern]}
 haystack bytes pattern bytes (returns) boolean

Description: Return true if pattern matches anywhere within haystack, otherwise return false.

Runtime Errors:

• #35010: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.count": [haystack, pattern]}
 haystack string pattern string (returns) int
{"re.count": [haystack, pattern]}
 haystack bytes pattern bytes (returns) int

Description: Count the number of times pattern matches in haystack.

Runtime Errors:

• #35020: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.rindex": [haystack, pattern]}
 haystack string pattern string (returns) array of int
{"re.rindex": [haystack, pattern]}
 haystack bytes pattern bytes (returns) array of int

Description: Return the location indices of the last pattern match in haystack.

Runtime Errors:

• #35030: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.groups": [haystack, pattern]}
 haystack string pattern string (returns) array of array of int
{"re.groups": [haystack, pattern]}
 haystack bytes pattern bytes (returns) array of array of int

Description: Return the location indices of each pattern sub-match (group-match) in haystack.

Runtime Errors:

• #35040: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.indexall": [haystack, pattern]}
 haystack string pattern string (returns) array of array of int
{"re.indexall": [haystack, pattern]}
 haystack bytes pattern bytes (returns) array of array of int

Description: Return the location indices of every pattern match in haystack.

Runtime Errors:

• #35050: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.findall": [haystack, pattern]}
 haystack string pattern string (returns) array of string
{"re.findall": [haystack, pattern]}
 haystack bytes pattern bytes (returns) array of bytes

Description: Return an array containing each string that pattern matched in haystack.

Runtime Errors:

• #35060: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.findfirst": [haystack, pattern]}
 haystack string pattern string (returns) union of {string, null}
{"re.findfirst": [haystack, pattern]}
 haystack bytes pattern bytes (returns) union of {bytes, null}

Description: Return the first occurance of what pattern matched in haystack.

Runtime Errors:

• #35070: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.findgroupsfirst": [haystack, pattern]}
 haystack string pattern string (returns) array of string
{"re.findgroupsfirst": [haystack, pattern]}
 haystack bytes pattern bytes (returns) array of bytes

Description: Return an array of strings or bytes for each pattern sub-match (group-match) at the first occurance of pattern in haystack.

Runtime Errors:

• #35080: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.findgroupsall": [haystack, pattern]}
 haystack string pattern string (returns) array of array of string
{"re.findgroupsall": [haystack, pattern]}
 haystack bytes pattern bytes (returns) array of array of bytes

Description: Return an array of strings or bytes for each pattern sub-match (group-match) at every occurance of pattern in haystack.

Runtime Errors:

• #35090: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.groupsall": [haystack, pattern]}
 haystack string pattern string (returns) array of array of array of int
{"re.groupsall": [haystack, pattern]}
 haystack bytes pattern bytes (returns) array of array of array of int

Description: Return the location indices of each pattern sub-match (group-match) for each occurance of pattern in haystack.

Runtime Errors:

• #35100: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.replacefirst": [haystack, pattern, replacement]}
 haystack string pattern string replacement string (returns) string
{"re.replacefirst": [haystack, pattern, replacement]}
 haystack bytes pattern bytes replacement bytes (returns) bytes

Description: Replace the first pattern match in haystack with replacement.

Runtime Errors:

• #35110: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.replacelast": [haystack, pattern, replacement]}
 haystack string pattern string replacement string (returns) string
{"re.replacelast": [haystack, pattern, replacement]}
 haystack bytes pattern bytes replacement bytes (returns) bytes

Description: Replace the last pattern match in haystack with replacement.

Runtime Errors:

• #35120: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.split": [haystack, pattern]}
 haystack string pattern string (returns) array of string
{"re.split": [haystack, pattern]}
 haystack bytes pattern bytes (returns) array of bytes

Description: Break haystack into an array of strings or bytes on the separator defined by pattern.

Runtime Errors:

• #35130: If pattern is not a valid regular expression, a "bad pattern" error is raised.

{"re.replaceall": [haystack, pattern, replacement]}
 haystack string pattern string replacement string (returns) string
{"re.replaceall": [haystack, pattern, replacement]}
 haystack bytes pattern bytes replacement bytes (returns) bytes

Description: Replace the all pattern matches in haystack with replacement.

Runtime Errors:

• #35140: If pattern is not a valid regular expression, a "bad pattern" error is raised.

## parse

{"parse.int": [str, base]}
 str string base int (returns) int

Description: Parse str and return its value as an integer with base base, if possible.

Details:

• The string is interpreted as though leading and trailing whitespace were removed and is case-insensitive.
• Leading or trailing whitespace and any capitalization is allowed.

Runtime Errors:

• #33000: Raises "not an integer" if the string does not conform to "[-+]?[0-9a-z]+" or the number it evaluates to is too large to represent as a 32-bit integer or uses characters as large as or larger than base ('0' through '9' encode 0 through 9 and 'a' through 'z' encode 10 through 35).
• #33001: Raises "base out of range" if base is less than 2 or greater than 36.

{"parse.long": [str, base]}
 str string base int (returns) long

Description: Parse str and return its value as a long integer with base base, if possible.

Details:

• The string is interpreted as though leading and trailing whitespace were removed and is case-insensitive.
• Leading or trailing whitespace and any capitalization is allowed.

Runtime Errors:

• #33010: Raises "not a long integer" if the string does not conform to "[-+]?[0-9a-z]+" or the number it evaluates to is too large to represent as a 64-bit integer or uses characters as large as or larger than base ('0' through '9' encode 0 through 9 and 'a' through 'z' encode 10 through 35).
• #33011: Raises "base out of range" if base is less than 2 or greater than 36.

{"parse.float": [str]}
 str string (returns) float

Description: Parse str and return its value as a single-precision floating point number.

Details:

• The string is interpreted as though leading and trailing whitespace were removed and is case-insensitive.
• If the string is "nan", the resulting value is not-a-number and if the string is "inf", "+inf", or "-inf", the resulting value is positive infinity, positive infinity, or negative infinity, respectively (see IEEE 754).
• If the number's magnitude is too large to be represented as a single-precision float, the resulting value is positive or negative infinity (depending on the sign). If the numbers magnitude is too small to be represented as a single-precision float, the resulting value is zero.
• Leading or trailing whitespace and any capitalization is allowed.

Runtime Errors:

• #33020: Raises "not a single-precision float" if the string does not conform to "[-+]?(\\.?[0-9]+|[0-9]+\\.[0-9]*)([eE][-+]?[0-9]+)?", "inf", "+inf", "-inf", or "nan".

{"parse.double": [str]}
 str string (returns) double

Description: Parse str and return its value as a double-precision floating point number.

Details:

• The string is interpreted as though leading and trailing whitespace were removed and is case-insensitive.
• If the string is "nan", the resulting value is not-a-number and if the string is "inf", "+inf", or "-inf", the resulting value is positive infinity, positive infinity, or negative infinity, respectively (see IEEE 754).
• If the number's magnitude is too large to be represented as a double-precision float, the resulting value is positive or negative infinity (depending on the sign). If the numbers magnitude is too small to be represented as a double-precision float, the resulting value is zero.
• Leading or trailing whitespace and any capitalization is allowed.

Runtime Errors:

• #33030: Raises "not a double-precision float" if the string does not conform to "[-+]?(\\.?[0-9]+|[0-9]+\\.[0-9]*)([eE][-+]?[0-9]+)?", "inf", "+inf", "-inf", or "nan".

## cast

{"cast.signed": [x, bits]}
 x long bits int (returns) long

Description: Truncate x as though its signed long two's complement representation were inserted, bit-for-bit, into a signed two's complement representation that is bits wide, removing the most significant bits.

Details:

• The result of this function may be negative, zero, or positive.

Runtime Errors:

• #17000: If bits is less than 2 or greater than 64, an "unrepresentable unsigned number" error is raised.

{"cast.unsigned": [x, bits]}
 x long bits int (returns) long

Description: Truncate x as though its signed long two's complement representation were inserted, bit-for-bit, into an unsigned register that is bits wide, removing the most significant bits.

Details:

• The result of this function is always nonnegative.

Runtime Errors:

• #17010: If bits is less than 1 or greater than 63, an "unrepresentable unsigned number" error is raised.

{"cast.int": [x]}
 x int (returns) int
{"cast.int": [x]}
 x long (returns) int
{"cast.int": [x]}
 x float (returns) int
{"cast.int": [x]}
 x double (returns) int

Description: Cast x to an integer, rounding if necessary.

Runtime Errors:

• #17020: Results outside of -2147483648 and 2147483647 (inclusive) produce an "int overflow" runtime error.

{"cast.long": [x]}
 x int (returns) long
{"cast.long": [x]}
 x long (returns) long
{"cast.long": [x]}
 x float (returns) long
{"cast.long": [x]}
 x double (returns) long

Description: Cast x to a 64-bit integer, rounding if necessary.

Runtime Errors:

• #17030: Results outside of -9223372036854775808 and 9223372036854775807 (inclusive) produce a "long overflow" runtime error.

{"cast.float": [x]}
 x int (returns) float
{"cast.float": [x]}
 x long (returns) float
{"cast.float": [x]}
 x float (returns) float
{"cast.float": [x]}
 x double (returns) float

Description: Cast x to a single-precision floating point number, rounding if necessary.

{"cast.double": [x]}
 x int (returns) double
{"cast.double": [x]}
 x long (returns) double
{"cast.double": [x]}
 x float (returns) double
{"cast.double": [x]}
 x double (returns) double

Description: Cast x to a double-precision floating point number.

{"cast.fanoutBoolean": [x]}
 x any enum A (returns) array of boolean
{"cast.fanoutBoolean": [x, dictionary, outOfRange]}
 x string dictionary array of string outOfRange boolean (returns) array of boolean
{"cast.fanoutBoolean": [x, minimum, maximum, outOfRange]}
 x int minimum int maximum int outOfRange boolean (returns) array of boolean

Description: Fanout x to an array of booleans, all false except the matching value.

Parameters:

 x Categorical datum dictionary Possible values of x, which is needed if x is an arbitrary string. minimum Inclusive minimum value of x. maximum Excluded maximum value of x. outOfRange If true, include an extra item in the output to represent values of x that are outside of the specified range.

Runtime Errors:

• #17060: If not all values in dictionary are unique, this function raises a "non-distinct values in dictionary" runtime error.

{"cast.fanoutInt": [x]}
 x any enum A (returns) array of int
{"cast.fanoutInt": [x, dictionary, outOfRange]}
 x string dictionary array of string outOfRange boolean (returns) array of int
{"cast.fanoutInt": [x, minimum, maximum, outOfRange]}
 x int minimum int maximum int outOfRange boolean (returns) array of int

Description: Fanout x to an array of booleans, all false except the matching value.

Parameters:

 x Categorical datum dictionary Possible values of x, which is needed if x is an arbitrary string. minimum Inclusive minimum value of x. maximum Excluded maximum value of x. outOfRange If true, include an extra item in the output to represent values of x that are outside of the specified range.

Runtime Errors:

• #17070: If not all values in dictionary are unique, this function raises a "non-distinct values in dictionary" runtime error.

{"cast.fanoutLong": [x]}
 x any enum A (returns) array of long
{"cast.fanoutLong": [x, dictionary, outOfRange]}
 x string dictionary array of string outOfRange boolean (returns) array of long
{"cast.fanoutLong": [x, minimum, maximum, outOfRange]}
 x int minimum int maximum int outOfRange boolean (returns) array of long

Description: Fanout x to an array of booleans, all false except the matching value.

Parameters:

 x Categorical datum dictionary Possible values of x, which is needed if x is an arbitrary string. minimum Inclusive minimum value of x. maximum Excluded maximum value of x. outOfRange If true, include an extra item in the output to represent values of x that are outside of the specified range.

Runtime Errors:

• #17080: If not all values in dictionary are unique, this function raises a "non-distinct values in dictionary" runtime error.

{"cast.fanoutFloat": [x]}
 x any enum A (returns) array of float
{"cast.fanoutFloat": [x, dictionary, outOfRange]}
 x string dictionary array of string outOfRange boolean (returns) array of float
{"cast.fanoutFloat": [x, minimum, maximum, outOfRange]}
 x int minimum int maximum int outOfRange boolean (returns) array of float

Description: Fanout x to an array of booleans, all false except the matching value.

Parameters:

 x Categorical datum dictionary Possible values of x, which is needed if x is an arbitrary string. minimum Inclusive minimum value of x. maximum Excluded maximum value of x. outOfRange If true, include an extra item in the output to represent values of x that are outside of the specified range.

Runtime Errors:

• #17090: If not all values in dictionary are unique, this function raises a "non-distinct values in dictionary" runtime error.

{"cast.fanoutDouble": [x]}
 x any enum A (returns) array of double
{"cast.fanoutDouble": [x, dictionary, outOfRange]}
 x string dictionary array of string outOfRange boolean (returns) array of double
{"cast.fanoutDouble": [x, minimum, maximum, outOfRange]}
 x int minimum int maximum int outOfRange boolean (returns) array of double

Description: Fanout x to an array of booleans, all false except the matching value.

Parameters:

 x Categorical datum dictionary Possible values of x, which is needed if x is an arbitrary string. minimum Inclusive minimum value of x. maximum Excluded maximum value of x. outOfRange If true, include an extra item in the output to represent values of x that are outside of the specified range.

Runtime Errors:

• #17100: If not all values in dictionary are unique, this function raises a "non-distinct values in dictionary" runtime error.

{"cast.avro": [x]}
 x any A (returns) bytes

Description: Encode an arbitrary object as Avro bytes.

Details:

• May be composed with bytes.toBase64 to get an efficient string representation (e.g. for map keys).

{"cast.json": [x]}
 x any A (returns) string

Description: Encode an arbitrary object as a JSON string.

Details:

• The form of this JSON string (spacing, order of keys in objects, etc.) is not guaranteed from one system to another.
• Should exclude unnecessary whitespace.
• Nondeterministic: unstable. This function gives the same results every time it is executed, but those results may not be exactly the same on all systems.

## a

{"a.len": [a]}
 a array of any A (returns) int

Description: Return the length of array a.

{"a.subseq": [a, start, end]}
 a array of any A start int end int (returns) array of A

Description: Return the subsequence of a from start (inclusive) until end (exclusive).

Details:

• Negative indexes count from the right (-1 is just before the last item), indexes beyond the legal range are truncated, and endstart specifies a zero-length subsequence just before the start character. All of these rules follow Python's slice behavior.

 a array of any A (returns) A

Description: Return the first item of the array.

Runtime Errors:

• #15020: If a is empty, an "empty array" runtime error is raised.

{"a.tail": [a]}
 a array of any A (returns) array of A

Description: Return all but the first item of the array.

Runtime Errors:

• #15030: If a is empty, an "empty array" runtime error is raised.

{"a.last": [a]}
 a array of any A (returns) A

Description: Return the last item of the array.

Runtime Errors:

• #15040: If a is empty, an "empty array" runtime error is raised.

{"a.init": [a]}
 a array of any A (returns) array of A

Description: Return all but the last item of the array.

Runtime Errors:

• #15050: If a is empty, an "empty array" runtime error is raised.

{"a.subseqto": [a, start, end, replacement]}
 a array of any A start int end int replacement array of A (returns) array of A

Description: Return a new array by replacing a from start (inclusive) until end (exclusive) with replacement.

Details:

• Negative indexes count from the right (-1 is just before the last item), indexes beyond the legal range are truncated, and endstart specifies a zero-length subsequence just before the start character. All of these rules follow Python's slice behavior.
• Note: a is not changed in-place; this is a side-effect-free function.

{"a.contains": [haystack, needle]}
 haystack array of any A needle array of A (returns) boolean
{"a.contains": [haystack, needle]}
 haystack array of any A needle A (returns) boolean
{"a.contains": [haystack, needle]}
 haystack array of any A needle function of (A) → boolean (returns) boolean

Description: Return true if haystack contains needle or the needle function evaluates to true, false otherwise.

{"a.count": [haystack, needle]}
 haystack array of any A needle array of A (returns) int
{"a.count": [haystack, needle]}
 haystack array of any A needle A (returns) int
{"a.count": [haystack, needle]}
 haystack array of any A needle function of (A) → boolean (returns) int

Description: Count the number of times needle appears in haystack or the number of times the needle function evaluates to true.

Details:

• If the needle is an empty array, the result is zero.

{"a.index": [haystack, needle]}
 haystack array of any A needle array of A (returns) int
{"a.index": [haystack, needle]}
 haystack array of any A needle A (returns) int
{"a.index": [haystack, needle]}
 haystack array of any A needle function of (A) → boolean (returns) int

Description: Return the lowest index where haystack contains needle or the needle function evaluates to true, $$-1$$ if there is no such element.

{"a.rindex": [haystack, needle]}
 haystack array of any A needle array of A (returns) int
{"a.rindex": [haystack, needle]}
 haystack array of any A needle A (returns) int
{"a.rindex": [haystack, needle]}
 haystack array of any A needle function of (A) → boolean (returns) int

Description: Return the highest index where haystack contains needle or the needle function evaluates to true, $$-1$$ if there is no such element.

{"a.startswith": [haystack, needle]}
 haystack array of any A needle array of A (returns) boolean
{"a.startswith": [haystack, needle]}
 haystack array of any A needle A (returns) boolean

Description: Return true if the first (leftmost) subseqence of haystack is equal to needle, false otherwise.

{"a.endswith": [haystack, needle]}
 haystack array of any A needle array of A (returns) boolean
{"a.endswith": [haystack, needle]}
 haystack array of any A needle A (returns) boolean

Description: Return true if the last (rightmost) subseqence of haystack is equal to needle, false otherwise.

{"a.concat": [a, b]}
 a array of any A b array of A (returns) array of A

Description: Concatenate a and b to make a new array of the same type.

Details:

• The length of the returned array is the sum of the lengths of a and b.

{"a.append": [a, item]}
 a array of any A item A (returns) array of A

Description: Return a new array by adding item at the end of a.

Details:

• Note: a is not changed in-place; this is a side-effect-free function.
• The length of the returned array is one more than a.

{"a.cycle": [a, item, maxLength]}
 a array of any A item A maxLength int (returns) array of A

Description: Return a new array by adding item at the end of a, but keep the length less than or equal to maxLength by removing items from the beginning.

Details:

• Note: a is not changed in-place; this is a side-effect-free function.

Runtime Errors:

• #15150: If maxLength is less than 0, this function raises a "maxLength out of range" error.

{"a.insert": [a, index, item]}
 a array of any A index int item A (returns) array of A

Description: Return a new array by inserting item at index of a.

Details:

• Negative indexes count from the right (-1 is just before the last item), following Python's index behavior.
• Note: a is not changed in-place; this is a side-effect-free function.
• The length of the returned array is one more than a.

Runtime Errors:

• #15160: If index is beyond the range of a, an "index out of range" runtime error is raised.

{"a.replace": [a, index, item]}
 a array of any A index int item A (returns) array of A

Description: Return a new array by replacing index of a with item.

Details:

• Negative indexes count from the right (-1 is just before the last item), following Python's index behavior.
• Note: a is not changed in-place; this is a side-effect-free function.
• The length of the returned array is equal to that of a.

Runtime Errors:

• #15170: If index is beyond the range of a, an "index out of range" runtime error is raised.

{"a.remove": [a, start, end]}
 a array of any A start int end int (returns) array of A
{"a.remove": [a, index]}
 a array of any A index int (returns) array of A

Description: Return a new array by removing elements from a from start (inclusive) until end (exclusive) or just a single index.

Details:

• Negative indexes count from the right (-1 is just before the last item), indexes beyond the legal range are truncated, and endstart specifies a zero-length subsequence just before the start character. All of these rules follow Python's slice behavior.
• Note: a is not changed in-place; this is a side-effect-free function.
• The length of the returned array is one less than a.

Runtime Errors:

• #15180: If index is beyond the range of a, an "index out of range" runtime error is raised.

{"a.rotate": [a, steps]}
 a array of any A steps int (returns) array of A

Description: Return an array formed by rotating a left steps spaces.

Runtime Errors:

• #15190: If steps is less than zero, a "steps out of range" error is raised.

{"a.sort": [a]}
 a array of any A (returns) array of A

Description: Return an array with the same elements as a but in ascending order (as defined by Avro's sort order).

Details:

• Note: a is not changed in-place; this is a side-effect-free function.

{"a.sortLT": [a, lessThan]}
 a array of any A lessThan function of (A, A) → boolean (returns) array of A

Description: Return an array with the same elements as a but in ascending order as defined by the lessThan function.

Details:

• Note: a is not changed in-place; this is a side-effect-free function.

{"a.shuffle": [a]}
 a array of any A (returns) array of A

Description: Return an array with the same elements as a but in a random order.

Details:

• Note: a is not changed in-place; this is a side-effect-free function (except for updating the random number generator).
• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

{"a.reverse": [a]}
 a array of any A (returns) array of A

Description: Return the elements of a in reversed order.

{"a.max": [a]}
 a array of any A (returns) A

Description: Return the maximum value in a (as defined by Avro's sort order).

Runtime Errors:

• #15240: If a is empty, an "empty array" runtime error is raised.

{"a.min": [a]}
 a array of any A (returns) A

Description: Return the minimum value in a (as defined by Avro's sort order).

Runtime Errors:

• #15250: If a is empty, an "empty array" runtime error is raised.

{"a.maxLT": [a, lessThan]}
 a array of any A lessThan function of (A, A) → boolean (returns) A

Description: Return the maximum value in a as defined by the lessThan function.

Runtime Errors:

• #15260: If a is empty, an "empty array" runtime error is raised.

{"a.minLT": [a, lessThan]}
 a array of any A lessThan function of (A, A) → boolean (returns) A

Description: Return the minimum value in a as defined by the lessThan function.

Runtime Errors:

• #15270: If a is empty, an "empty array" runtime error is raised.

{"a.maxN": [a, n]}
 a array of any A n int (returns) array of A

Description: Return the n highest values in a (as defined by Avro's sort order).

Runtime Errors:

• #15280: If a is empty, an "empty array" runtime error is raised.
• #15281: If n is negative, an "n < 0" runtime error is raised.

{"a.minN": [a, n]}
 a array of any A n int (returns) array of A

Description: Return the n lowest values in a (as defined by Avro's sort order).

Runtime Errors:

• #15290: If a is empty, an "empty array" runtime error is raised.
• #15291: If n is negative, an "n < 0" runtime error is raised.

{"a.maxNLT": [a, n, lessThan]}
 a array of any A n int lessThan function of (A, A) → boolean (returns) array of A

Description: Return the n highest values in a as defined by the lessThan function.

Runtime Errors:

• #15300: If a is empty, an "empty array" runtime error is raised.
• #15301: If n is negative, an "n < 0" runtime error is raised.

{"a.minNLT": [a, n, lessThan]}
 a array of any A n int lessThan function of (A, A) → boolean (returns) array of A

Description: Return the n lowest values in a as defined by the lessThan function.

Runtime Errors:

• #15310: If a is empty, an "empty array" runtime error is raised.
• #15311: If n is negative, an "n < 0" runtime error is raised.

{"a.argmax": [a]}
 a array of any A (returns) int

Description: Return the index of the maximum value in a (as defined by Avro's sort order).

Details:

• If the maximum is not unique, this function returns the index of the first maximal value.

Runtime Errors:

• #15320: If a is empty, an "empty array" runtime error is raised.

{"a.argmin": [a]}
 a array of any A (returns) int

Description: Return the index of the minimum value in a (as defined by Avro's sort order).

Details:

• If the minimum is not unique, this function returns the index of the first minimal value.

Runtime Errors:

• #15330: If a is empty, an "empty array" runtime error is raised.

{"a.argmaxLT": [a, lessThan]}
 a array of any A lessThan function of (A, A) → boolean (returns) int

Description: Return the index of the maximum value in a as defined by the lessThan function.

Details:

• If the maximum is not unique, this function returns the index of the first maximal value.

Runtime Errors:

• #15340: If a is empty, an "empty array" runtime error is raised.

{"a.argminLT": [a, lessThan]}
 a array of any A lessThan function of (A, A) → boolean (returns) int

Description: Return the index of the minimum value in a as defined by the lessThan function.

Details:

• If the minimum is not unique, this function returns the index of the first minimal value.

Runtime Errors:

• #15350: If a is empty, an "empty array" runtime error is raised.

{"a.argmaxN": [a, n]}
 a array of any A n int (returns) array of int

Description: Return the indexes of the n highest values in a (as defined by Avro's sort order).

Details:

• If any values are not unique, their indexes will be returned in ascending order.

Runtime Errors:

• #15360: If a is empty, an "empty array" runtime error is raised.
• #15361: If n is negative, an "n < 0" runtime error is raised.

{"a.argminN": [a, n]}
 a array of any A n int (returns) array of int

Description: Return the indexes of the n lowest values in a (as defined by Avro's sort order).

Details:

• If any values are not unique, their indexes will be returned in ascending order.

Runtime Errors:

• #15370: If a is empty, an "empty array" runtime error is raised.
• #15371: If n is negative, an "n < 0" runtime error is raised.

{"a.argmaxNLT": [a, n, lessThan]}
 a array of any A n int lessThan function of (A, A) → boolean (returns) array of int

Description: Return the indexes of the n highest values in a as defined by the lessThan function.

Details:

• If any values are not unique, their indexes will be returned in ascending order.

Runtime Errors:

• #15380: If a is empty, an "empty array" runtime error is raised.
• #15381: If n is negative, an "n < 0" runtime error is raised.

{"a.argminNLT": [a, n, lessThan]}
 a array of any A n int lessThan function of (A, A) → boolean (returns) array of int

Description: Return the indexes of the n lowest values in a as defined by the lessThan function.

Details:

• If any values are not unique, their indexes will be returned in ascending order.

Runtime Errors:

• #15390: If a is empty, an "empty array" runtime error is raised.
• #15391: If n is negative, an "n < 0" runtime error is raised.

{"a.sum": [a]}
 a array of any A of {int, long, float, double} (returns) A

Description: Return the sum of numbers in a.

Details:

• Returns zero if the array is empty.

Runtime Errors:

• #15400: If the array items have integer type and the final result is too large or small to be represented as an integer, an "int overflow" error is raised.
• #15401: If the array items have long integer type and the final result is too large or small to be represented as a long integer, an "long overflow" error is raised.

{"a.product": [a]}
 a array of any A of {int, long, float, double} (returns) A

Description: Return the product of numbers in a.

Details:

• Returns one if the array is empty.

Runtime Errors:

• #15410: If the array items have integer type and the final result is too large or small to be represented as an integer, an "int overflow" error is raised.
• #15411: If the array items have long integer type and the final result is too large or small to be represented as a long integer, an "long overflow" error is raised.

{"a.lnsum": [a]}
 a array of double (returns) double

Description: Return the sum of the natural logarithm of numbers in a.

Details:

• Returns zero if the array is empty and NaN if any value in the array is zero or negative.

{"a.mean": [a]}
 a array of double (returns) double

Description: Return the arithmetic mean of numbers in a.

Details:

• Returns NaN if the array is empty.

{"a.geomean": [a]}
 a array of double (returns) double

Description: Return the geometric mean of numbers in a.

Details:

• Returns NaN if the array is empty.

{"a.median": [a]}
 a array of any A (returns) A

Description: Return the value that is in the center of a sorted version of a.

Details:

• If a has an odd number of elements, the median is the exact center of the sorted array. If a has an even number of elements and is a float or double, the median is the average of the two elements closest to the center of the sorted array. For any other type, the median is the left (first) of the two elements closest to the center of the sorted array.

Runtime Errors:

• #15450: If a is empty, an "empty array" runtime error is raised.

{"a.ntile": [a, p]}
 a array of any A p double (returns) A

Description: Return the value that is at the "n-tile" of a (like a percentile).

Parameters:

 a Array of objects to be take the percentile of. p A double between 0 and 1.

Details:

• If a has an even number of elements and is a float or double, this function will take the average of the two elements closest to the center of the sorted array. For any other type, it returns the left (first) of the two elements closest to the center of the sorted array. If p is exactly one (or greater), the max of the array is returned. If p is zero (or less), the min of the array is returned.

Runtime Errors:

• #15460: If a is empty, an "empty array" runtime error is raised.
• #15461: If p is NaN, this function raises a "p not a number" error.

{"a.mode": [a]}
 a array of any A (returns) A

Description: Return the mode (most common) value of a.

Details:

• If several different values are equally common, the median of these is returned.

Runtime Errors:

• #15470: If a is empty, an "empty array" runtime error is raised.

{"a.logsumexp": [a]}
 a array of double (returns) double

Description: Compute $$z = \\log(\\sum_{n = 1}^{N} e^{x_n})$$ in a numerically stable way.

Details:

• Returns NaN if the array is empty.

{"a.distinct": [a]}
 a array of any A (returns) array of A

Description: Return an array with the same contents as a but with duplicates removed.

Details:

• The order of the original array is preserved.

{"a.seteq": [a, b]}
 a array of any A b array of A (returns) boolean

Description: Return true if a and b are equivalent, ignoring order and duplicates, false otherwise.

{"a.union": [a, b]}
 a array of any A b array of A (returns) array of A

Description: Return an array that represents the union of a and b, treated as sets (ignoring order and duplicates).

Details:

• The order of the original arrays is preserved.

{"a.intersection": [a, b]}
 a array of any A b array of A (returns) array of A

Description: Return an array that represents the intersection of a and b, treated as sets (ignoring order and duplicates).

Details:

• The order of the original arrays is preserved.

{"a.diff": [a, b]}
 a array of any A b array of A (returns) array of A

Description: Return an array that represents the difference of a and b, treated as sets (ignoring order and duplicates).

Details:

• The order of the original arrays is preserved.

{"a.symdiff": [a, b]}
 a array of any A b array of A (returns) array of A

Description: Return an array that represents the symmetric difference of a and b, treated as sets (ignoring order and duplicates).

Details:

• The symmetric difference is (a diff b) union (b diff a).
• The order of the original arrays is preserved.

{"a.subset": [little, big]}
 little array of any A big array of A (returns) boolean

Description: Return true if little is a subset of big, false otherwise.

{"a.disjoint": [a, b]}
 a array of any A b array of A (returns) boolean

Description: Return true if a and b are disjoint, false otherwise.

{"a.map": [a, fcn]}
 a array of any A fcn function of (A) → any B (returns) array of B

Description: Apply fcn to each element of a and return an array of the results.

Details:

• The order in which fcn is called on elements of a is not guaranteed, though it will be called exactly once for each element.

{"a.mapWithIndex": [a, fcn]}
 a array of any A fcn function of (int, A) → any B (returns) array of B

Description: Apply fcn to index, element pairs from a and return an array of the results.

Details:

• The order in which fcn is called on elements of a is not guaranteed, though it will be called exactly once for each element.

{"a.filter": [a, fcn]}
 a array of any A fcn function of (A) → boolean (returns) array of A

Description: Apply fcn to each element of a and return an array of the elements for which fcn returns true.

Details:

• The order in which fcn is called on elements of a is not guaranteed, though it will be called exactly once for each element.

{"a.filterWithIndex": [a, fcn]}
 a array of any A fcn function of (int, A) → boolean (returns) array of A

Description: Apply fcn to each index, element pair of a and return an array of the elements for which fcn returns true.

Details:

• The order in which fcn is called on elements of a is not guaranteed, though it will be called exactly once for each element.

{"a.filterMap": [a, fcn]}
 a array of any A fcn function of (A) → union of {any B, null} (returns) array of B

Description: Apply fcn to each element of a and return an array of the results that are not null.

Details:

• The order in which fcn is called on elements of a is not guaranteed, though it will be called exactly once for each element.

{"a.filterMapWithIndex": [a, fcn]}
 a array of any A fcn function of (int, A) → union of {any B, null} (returns) array of B

Description: Apply fcn to each index, element pair of a and return an array of the results that are not null.

Details:

• The order in which fcn is called on elements of a is not guaranteed, though it will be called exactly once for each element.

{"a.flatMap": [a, fcn]}
 a array of any A fcn function of (A) → array of any B (returns) array of B

Description: Apply fcn to each element of a and flatten the resulting arrays into a single array.

Details:

• The order in which fcn is called on elements of a is not guaranteed, though it will be called exactly once for each element.

{"a.flatMapWithIndex": [a, fcn]}
 a array of any A fcn function of (int, A) → array of any B (returns) array of B

Description: Apply fcn to each index, element pair of a and flatten the resulting arrays into a single array.

Details:

• The order in which fcn is called on elements of a is not guaranteed, though it will be called exactly once for each element.

{"a.zipmap": [a, b, fcn]}
 a array of any A b array of any B fcn function of (A, B) → any Z (returns) array of Z
{"a.zipmap": [a, b, c, fcn]}
 a array of any A b array of any B c array of any C fcn function of (A, B, C) → any Z (returns) array of Z
{"a.zipmap": [a, b, c, d, fcn]}
 a array of any A b array of any B c array of any C d array of any D fcn function of (A, B, C, D) → any Z (returns) array of Z

Description: Apply fcn to the elements of a, b, c, d in lock-step and return a result for row.

Runtime Errors:

• #15650: Raises a "misaligned arrays" error if a, b, c, d do not all have the same length.

{"a.zipmapWithIndex": [a, b, fcn]}
 a array of any A b array of any B fcn function of (int, A, B) → any Z (returns) array of Z
{"a.zipmapWithIndex": [a, b, c, fcn]}
 a array of any A b array of any B c array of any C fcn function of (int, A, B, C) → any Z (returns) array of Z
{"a.zipmapWithIndex": [a, b, c, d, fcn]}
 a array of any A b array of any B c array of any C d array of any D fcn function of (int, A, B, C, D) → any Z (returns) array of Z

Description: Apply fcn to the indexes and elements of a, b, c, d in lock-step and return a result for row.

Runtime Errors:

• #15660: Raises a "misaligned arrays" error if a, b, c, d do not all have the same length.

{"a.reduce": [a, fcn]}
 a array of any A fcn function of (A, A) → A (returns) A

Description: Apply fcn to each element of a and accumulate a tally.

Details:

• The first parameter of fcn is the running tally and the second parameter is an element from a.
• The order in which fcn is called on elements of a is not guaranteed, though it accumulates from left (beginning) to right (end), called exactly once for each element. For predictable results, fcn should be associative. It need not be commutative.

Runtime Errors:

• #15670: If a is empty, an "empty array" runtime error is raised.

{"a.reduceRight": [a, fcn]}
 a array of any A fcn function of (A, A) → A (returns) A

Description: Apply fcn to each element of a and accumulate a tally.

Details:

• The first parameter of fcn is an element from a and the second parameter is the running tally.
• The order in which fcn is called on elements of a is not guaranteed, though it accumulates from right (end) to left (beginning), called exactly once for each element. For predictable results, fcn should be associative. It need not be commutative.

Runtime Errors:

• #15680: If a is empty, an "empty array" runtime error is raised.

{"a.fold": [a, zero, fcn]}
 a array of any A zero any B fcn function of (B, A) → B (returns) B

Description: Apply fcn to each element of a and accumulate a tally, starting with zero.

Details:

• The first parameter of fcn is the running tally and the second parameter is an element from a.
• The order in which fcn is called on elements of a is not guaranteed, though it accumulates from left (beginning) to right (end), called exactly once for each element. For predictable results, fcn should be associative with zero as its identity; that is, fcn(zero, zero) = zero. It need not be commutative.

{"a.foldRight": [a, zero, fcn]}
 a array of any A zero any B fcn function of (A, B) → B (returns) B

Description: Apply fcn to each element of a and accumulate a tally, starting with zero.

Details:

• The first parameter of fcn is an element from a and the second parameter is the running tally.
• The order in which fcn is called on elements of a is not guaranteed, though it accumulates from right (end) to left (beginning), called exactly once for each element. For predictable results, fcn should be associative with zero as its identity; that is, fcn(zero, zero) = zero. It need not be commutative.

{"a.takeWhile": [a, fcn]}
 a array of any A fcn function of (A) → boolean (returns) array of A

Description: Apply fcn to elements of a and create an array of the longest prefix that returns true, stopping with the first false.

Details:

• Beyond the prefix, the number of fcn calls is not guaranteed.

{"a.dropWhile": [a, fcn]}
 a array of any A fcn function of (A) → boolean (returns) array of A

Description: Apply fcn to elements of a and create an array of all elements after the longest prefix that returns true.

Details:

• Beyond the prefix, the number of fcn calls is not guaranteed.

{"a.any": [a, fcn]}
 a array of any A fcn function of (A) → boolean (returns) boolean

Description: Return true if fcn is true for any element in a (logical or).

Details:

• The number of fcn calls is not guaranteed.

{"a.all": [a, fcn]}
 a array of any A fcn function of (A) → boolean (returns) boolean

Description: Return true if fcn is true for all elements in a (logical and).

Details:

• The number of fcn calls is not guaranteed.

{"a.corresponds": [a, b, fcn]}
 a array of any A b array of any B fcn function of (A, B) → boolean (returns) boolean

Description: Return true if fcn is true when applied to all pairs of elements, one from a and the other from b (logical relation).

Details:

• The number of fcn calls is not guaranteed.
• If the lengths of a and b are not equal, this function returns false.

{"a.correspondsWithIndex": [a, b, fcn]}
 a array of any A b array of any B fcn function of (int, A, B) → boolean (returns) boolean

Description: Return true if fcn is true when applied to all triples of index, element from a, element from b (logical relation).

Details:

• The number of fcn calls is not guaranteed.
• If the lengths of a and b are not equal, this function returns false.

{"a.slidingWindow": [a, size, step]}
 a array of any A size int step int (returns) array of array of A

Description: Return an array of subsequences of a with length size that slide through a in steps of length step from left to right.

Runtime Errors:

• #15770: If size is non-positive, a "size < 1" runtime error is raised.
• #15771: If step is non-positive, a "step < 1" runtime error is raised.

{"a.combinations": [a, size]}
 a array of any A size int (returns) array of array of A

Description: Return all combinations of elements of a with length size.

Runtime Errors:

• #15780: If size is non-positive, a "size < 1" runtime error is raised.

{"a.permutations": [a]}
 a array of any A (returns) array of array of A

Description: Return all permutations of elements of a.

Details:

• This function scales rapidly with the length of the array. For reasonably large arrays, it will result in timeout exceptions.

{"a.flatten": [a]}
 a array of array of any A (returns) array of A

Description: Concatenate the arrays in a.

{"a.groupby": [a, fcn]}
 a array of any A fcn function of (A) → string (returns) map of array of A

Description: Groups elements of a by the string that fcn maps them to.

## map

{"map.len": [m]}
 m map of any A (returns) int

Description: Return the length of a map.

{"map.keys": [m]}
 m map of any A (returns) array of string

Description: Return the keys of a map (in no particular order).

Details:

• Nondeterministic: unordered. This function gives the same set of values every time it is executed on all systems, but the values may have a different order.

{"map.values": [m]}
 m map of any A (returns) array of A

Description: Return the values of a map (in no particular order).

Details:

• Nondeterministic: unordered. This function gives the same set of values every time it is executed on all systems, but the values may have a different order.

{"map.containsKey": [m, key]}
 m map of any A key string (returns) boolean
{"map.containsKey": [m, fcn]}
 m map of any A fcn function of (string) → boolean (returns) boolean

Description: Return true if the keys of m contains key or fcn evaluates to true for some key of m, false otherwise.

{"map.containsValue": [m, value]}
 m map of any A value A (returns) boolean
{"map.containsValue": [m, fcn]}
 m map of any A fcn function of (A) → boolean (returns) boolean

Description: Return true if the values of m contains value or fcn evaluates to true for some key of m, false otherwise.

 m map of any A key string value A (returns) map of A
 m map of any A item A (returns) map of A

Description: Return a new map by adding the key value pair to m or a new set by adding the item to set m, where a set is represented as a map from serialized objects to objects.

Details:

• Note: m is not changed in-place; this is a side-effect-free function.
• If key is in m, its value will be replaced.
• The serialization format for keys of sets is base64-encoded Avro.

{"map.remove": [m, key]}
 m map of any A key string (returns) map of A

Description: Return a new map by removing key from m.

Details:

• Note: m is not changed in-place; this is a side-effect-free function.
• If key is not in m, the return value is simply m.

{"map.only": [m, keys]}
 m map of any A keys array of string (returns) map of A

Description: Return a new map, keeping only keys from m.

Details:

• Note: m is not changed in-place; this is a side-effect-free function.
• If some keys are not in m, they are ignored and do not appear in the return value.

{"map.except": [m, keys]}
 m map of any A keys array of string (returns) map of A

Description: Return a new map, keeping all but keys from m.

Details:

• Note: m is not changed in-place; this is a side-effect-free function.
• If some keys are not in m, they are ignored and do not appear in the return value.

{"map.update": [base, overlay]}
 base map of any A overlay map of A (returns) map of A

Description: Return a new map with key-value pairs from overlay in place of or in addition to key-value pairs from base.

Details:

• Note: m is not changed in-place; this is a side-effect-free function.
• Keys of overlay that are not in base are added to those in base and keys of overlay that are in base supersede those in base.

{"map.split": [m]}
 m map of any A (returns) array of map of A

Description: Split the map into an array of maps, each containing only one key-value pair (in no particular order).

Details:

• Nondeterministic: unordered. This function gives the same set of values every time it is executed on all systems, but the values may have a different order.

{"map.join": [a]}
 a array of map of any A (returns) map of A

Description: Join an array of maps into one map, overlaying from left to right.

{"map.argmax": [m]}
 m map of any A (returns) string

Description: Return the key of the highest value in m (as defined by Avro's sort order).

Details:

• If any values are not unique, their keys will be returned in lexicographic order.

Runtime Errors:

• #26120: If m is empty, an "empty map" runtime error is raised.

{"map.argmin": [m]}
 m map of any A (returns) string

Description: Return the key of the lowest value in m (as defined by Avro's sort order).

Details:

• If any values are not unique, their keys will be returned in lexicographic order.

Runtime Errors:

• #26130: If m is empty, an "empty map" runtime error is raised.

{"map.argmaxLT": [m, lessThan]}
 m map of any A lessThan function of (A, A) → boolean (returns) string

Description: Return the key of the highest value in m as defined by the lessThan function.

Details:

• If any values are not unique, their keys will be returned in lexicographic order.

Runtime Errors:

• #26140: If m is empty, an "empty map" runtime error is raised.

{"map.argminLT": [m, lessThan]}
 m map of any A lessThan function of (A, A) → boolean (returns) string

Description: Return the key of the lowest value in m as defined by the lessThan function.

Details:

• If any values are not unique, their keys will be returned in lexicographic order.

Runtime Errors:

• #26150: If m is empty, an "empty map" runtime error is raised.

{"map.argmaxN": [m, n]}
 m map of any A n int (returns) array of string

Description: Return the keys of the n highest values in m (as defined by Avro's sort order).

Details:

• If any values are not unique, their keys will be returned in lexicographic order.

Runtime Errors:

• #26160: If m is empty, an "empty map" runtime error is raised.
• #26161: If n is negative, an "n < 0" runtime error is raised.

{"map.argminN": [m, n]}
 m map of any A n int (returns) array of string

Description: Return the keys of the n lowest values in m (as defined by Avro's sort order).

Details:

• If any values are not unique, their keys will be returned in lexicographic order.

Runtime Errors:

• #26170: If m is empty, an "empty map" runtime error is raised.
• #26171: If n is negative, an "n < 0" runtime error is raised.

{"map.argmaxNLT": [m, n, lessThan]}
 m map of any A n int lessThan function of (A, A) → boolean (returns) array of string

Description: Return the keys of the n highest values in a as defined by the lessThan function.

Details:

• If any values are not unique, their keys will be returned in lexicographic order.

Runtime Errors:

• #26180: If m is empty, an "empty map" runtime error is raised.
• #26181: If n is negative, an "n < 0" runtime error is raised.

{"map.argminNLT": [m, n, lessThan]}
 m map of any A n int lessThan function of (A, A) → boolean (returns) array of string

Description: Return the keys of the n highest values in a as defined by the lessThan function.

Details:

• If any values are not unique, their keys will be returned in lexicographic order.

Runtime Errors:

• #26190: If m is empty, an "empty map" runtime error is raised.
• #26191: If n is negative, an "n < 0" runtime error is raised.

{"map.toset": [a]}
 a array of any A (returns) map of A

Description: Convert an array of objects into a set of objects, where a set is represented as a map from serialized objects to objects.

Details:

• The serialization format is base64-encoded Avro.

{"map.fromset": [s]}
 s map of any A (returns) array of A

Description: Convert a set of objects into an array of objects (in no particular order), where a set is represented as a map from serialized objects to objects.

Details:

• The serialization format is base64-encoded Avro.
• This function does not verify that the serialized objects (keys) and objects (values) match: it considers only values, not keys.
• Nondeterministic: unordered. This function gives the same set of values every time it is executed on all systems, but the values may have a different order.

{"map.in": [s, x]}
 s map of any A x A (returns) boolean

Description: Return true if x is contained in set s, false otherwise, where a set is represented as a map from serialized objects to objects.

Details:

• The serialization format is base64-encoded Avro.
• This function does not verify that the serialized objects (keys) and objects (values) match: it considers only keys, not values.

{"map.union": [a, b]}
 a map of any A b map of A (returns) map of A

Description: Return the union of sets a and b, where a set is represented as a map from serialized objects to objects.

Details:

• The serialization format is base64-encoded Avro.
• This function does not verify that the serialized objects (keys) and objects (values) match: it considers only keys, not values.

{"map.intersection": [a, b]}
 a map of any A b map of A (returns) map of A

Description: Return the intersection of sets a and b, where a set is represented as a map from serialized objects to objects.

Details:

• The serialization format is base64-encoded Avro.
• This function does not verify that the serialized objects (keys) and objects (values) match: it considers only keys, not values.

{"map.diff": [a, b]}
 a map of any A b map of A (returns) map of A

Description: Return the difference of sets a and b, where a set is represented as a map from serialized objects to objects.

Details:

• The serialization format is base64-encoded Avro.
• This function does not verify that the serialized objects (keys) and objects (values) match: it considers only keys, not values.

{"map.symdiff": [a, b]}
 a map of any A b map of A (returns) map of A

Description: Return the difference of sets a and b, where a set is represented as a map from serialized objects to objects.

Details:

• The serialization format is base64-encoded Avro.
• This function does not verify that the serialized objects (keys) and objects (values) match: it considers only keys, not values.

{"map.subset": [little, big]}
 little map of any A big map of A (returns) boolean

Description: Return true if set little is a subset of set big, false otherwise, where a set is represented as a map from serialized objects to objects.

Details:

• The serialization format is base64-encoded Avro.
• This function does not verify that the serialized objects (keys) and objects (values) match: it considers only keys, not values.

{"map.disjoint": [a, b]}
 a map of any A b map of A (returns) boolean

Description: Return true if set a and set b are disjoint, false otherwise, where a set is represented as a map from serialized objects to objects.

Details:

• The serialization format is base64-encoded Avro.
• This function does not verify that the serialized objects (keys) and objects (values) match: it considers only keys, not values.

{"map.map": [m, fcn]}
 m map of any A fcn function of (A) → any B (returns) map of B

Description: Apply fcn to each value of m and return a map of transformed values (keys are unchanged).

Details:

• The order in which fcn is called on items in m is not guaranteed, though it will be called exactly once for each value.
• To transform both keys and values, consider applying map.split, a.map, then map.join.

{"map.mapWithKey": [m, fcn]}
 m map of any A fcn function of (string, A) → any B (returns) map of B

Description: Apply fcn to each key, value pair of m and return a map of transformed values (keys are unchanged).

Details:

• The order in which fcn is called on items in m is not guaranteed, though it will be called exactly once for each value.
• To transform both keys and values, consider applying map.split, a.map, then map.join.

{"map.filter": [m, fcn]}
 m map of any A fcn function of (A) → boolean (returns) map of A

Description: Apply fcn to each value of m and return a map of the values for which fcn returns true (keys are unchanged).

Details:

• The order in which fcn is called on items in m is not guaranteed, though it will be called exactly once for each value.

{"map.filterWithKey": [m, fcn]}
 m map of any A fcn function of (string, A) → boolean (returns) map of A

Description: Apply fcn to each value of m and return a map of the values for which fcn returns true (keys are unchanged).

Details:

• The order in which fcn is called on items in m is not guaranteed, though it will be called exactly once for each value.

{"map.filterMap": [m, fcn]}
 m map of any A fcn function of (A) → union of {any B, null} (returns) map of B

Description: Apply fcn to each value of m and return a map of the results that are not null.

Details:

• The order in which fcn is called on items in m is not guaranteed, though it will be called exactly once for each value.

{"map.filterMapWithKey": [m, fcn]}
 m map of any A fcn function of (string, A) → union of {any B, null} (returns) map of B

Description: Apply fcn to each key-value pair of m and return a map of the results that are not null.

Details:

• The order in which fcn is called on items in m is not guaranteed, though it will be called exactly once for each value.

{"map.flatMap": [m, fcn]}
 m map of any A fcn function of (A) → map of any B (returns) map of B

Description: Apply fcn to each value of m and return a map of overlaid results.

Details:

• The order in which fcn is called on items in m is not guaranteed, though it will be called exactly once for each value.

{"map.flatMapWithKey": [m, fcn]}
 m map of any A fcn function of (string, A) → map of any B (returns) map of B

Description: Apply fcn to each key-value pair of m and return a map of overlaid results.

Details:

• The order in which fcn is called on items in m is not guaranteed, though it will be called exactly once for each value.

{"map.zipmap": [a, b, fcn]}
 a map of any A b map of any B fcn function of (A, B) → any Z (returns) map of Z
{"map.zipmap": [a, b, c, fcn]}
 a map of any A b map of any B c map of any C fcn function of (A, B, C) → any Z (returns) map of Z
{"map.zipmap": [a, b, c, d, fcn]}
 a map of any A b map of any B c map of any C d map of any D fcn function of (A, B, C, D) → any Z (returns) map of Z

Description: Apply fcn to the elements of a, b, c, d in lock-step and return a result for row.

Runtime Errors:

• #26370: Raises a "misaligned maps" error if a, b, c, d do not all have the same keys.

{"map.zipmapWithKey": [a, b, fcn]}
 a map of any A b map of any B fcn function of (string, A, B) → any Z (returns) map of Z
{"map.zipmapWithKey": [a, b, c, fcn]}
 a map of any A b map of any B c map of any C fcn function of (string, A, B, C) → any Z (returns) map of Z
{"map.zipmapWithKey": [a, b, c, d, fcn]}
 a map of any A b map of any B c map of any C d map of any D fcn function of (string, A, B, C, D) → any Z (returns) map of Z

Description: Apply fcn to the keys and elements of a, b, c, d in lock-step and return a result for row.

Runtime Errors:

• #26380: Raises a "misaligned maps" error if a, b, c, d do not all have the same keys.

{"map.corresponds": [a, b, fcn]}
 a map of any A b map of any B fcn function of (A, B) → boolean (returns) boolean

Description: Return true if fcn is true when applied to all pairs of values, one from a and the other from b (logical relation).

Details:

• The number of fcn calls is not guaranteed.
• If the key sets of a and b are not equal, this function returns false.

{"map.correspondsWithKey": [a, b, fcn]}
 a map of any A b map of any B fcn function of (string, A, B) → boolean (returns) boolean

Description: Return true if fcn is true when applied to all triples of key, value from a, value from b (logical relation).

Details:

• The number of fcn calls is not guaranteed.
• If the key sets of a and b are not equal, this function returns false.

## bytes

{"bytes.len": [x]}
 x bytes (returns) int

Description: Return the length of byte array x.

{"bytes.subseq": [x, start, end]}
 x bytes start int end int (returns) bytes

Description: Return the subsequence of x from start (inclusive) until end (exclusive).

Details:

• Negative indexes count from the right (-1 is just before the last item), indexes beyond the legal range are truncated, and endstart specifies a zero-length subsequence just before the start character. All of these rules follow Python's slice behavior.

{"bytes.subseqto": [x, start, end, replacement]}
 x bytes start int end int replacement bytes (returns) bytes

Description: Replace x from start (inclusive) until end (exclusive) with replacement.

Details:

• Negative indexes count from the right (-1 is just before the last item), indexes beyond the legal range are truncated, and endstart specifies a zero-length subsequence just before the start character. All of these rules follow Python's slice behavior.

{"bytes.isAscii": [x]}
 x bytes (returns) boolean
{"bytes.isAscii": [x]}
 x string (returns) boolean

Description: Returns true if x is valid ASCII; false otherwise.

{"bytes.isLatin1": [x]}
 x bytes (returns) boolean
{"bytes.isLatin1": [x]}
 x string (returns) boolean

Description: Returns true if x is valid latin-1 (ISO-8859-1); false otherwise.

{"bytes.isUtf8": [x]}
 x bytes (returns) boolean
{"bytes.isUtf8": [x]}
 x string (returns) boolean

Description: Returns true if x is valid utf-8; false otherwise.

{"bytes.isUtf16": [x]}
 x bytes (returns) boolean
{"bytes.isUtf16": [x]}
 x string (returns) boolean

Description: Returns true if x is valid utf-16 (byte order identified by optional byte-order mark); false otherwise.

{"bytes.isUtf16be": [x]}
 x bytes (returns) boolean
{"bytes.isUtf16be": [x]}
 x string (returns) boolean

Description: Returns true if x is valid big endian utf-16; false otherwise.

{"bytes.isUtf16le": [x]}
 x bytes (returns) boolean
{"bytes.isUtf16le": [x]}
 x string (returns) boolean

Description: Returns true if x is valid little endian utf-16; false otherwise.

{"bytes.decodeAscii": [x]}
 x bytes (returns) string

Description: Decode a bytes object as an ASCII string.

Runtime Errors:

• #16090: Raises an "invalid bytes" error if the bytes cannot be converted.

{"bytes.decodeLatin1": [x]}
 x bytes (returns) string

Description: Decode a bytes object as a latin-1 (ISO-8859-1) string.

Runtime Errors:

• #16100: Raises an "invalid bytes" error if the bytes cannot be converted.

{"bytes.decodeUtf8": [x]}
 x bytes (returns) string

Description: Decode a bytes object as a utf-8 string.

Runtime Errors:

• #16110: Raises an "invalid bytes" error if the bytes cannot be converted.

{"bytes.decodeUtf16": [x]}
 x bytes (returns) string

Description: Decode a bytes object as a utf-16 (byte order identified by optional byte-order mark) string.

Runtime Errors:

• #16120: Raises an "invalid bytes" error if the bytes cannot be converted.

{"bytes.decodeUtf16be": [x]}
 x bytes (returns) string

Description: Decode a bytes object as a big endian utf-16 string.

Runtime Errors:

• #16130: Raises an "invalid bytes" error if the bytes cannot be converted.

{"bytes.decodeUtf16le": [x]}
 x bytes (returns) string

Description: Decode a bytes object as a little endian utf-16 string.

Runtime Errors:

• #16140: Raises an "invalid bytes" error if the bytes cannot be converted.

{"bytes.encodeAscii": [s]}
 s string (returns) bytes

Description: Encode a string as ASCII bytes.

Runtime Errors:

• #16150: Raises an "invalid string" error if the string cannot be converted.

{"bytes.encodeLatin1": [s]}
 s string (returns) bytes

Description: Encode a string as latin-1 (ISO-8859-1) bytes.

Runtime Errors:

• #16160: Raises an "invalid string" error if the string cannot be converted.

{"bytes.encodeUtf8": [s]}
 s string (returns) bytes

Description: Encode a string as utf-8 bytes.

Runtime Errors:

• #16170: Raises an "invalid string" error if the string cannot be converted.

{"bytes.encodeUtf16": [s]}
 s string (returns) bytes

Description: Encode a string as utf-16 (byte order identified by optional byte-order mark) bytes.

Details:

• Nondeterministic: unstable. This function gives the same results every time it is executed, but those results may not be exactly the same on all systems.

Runtime Errors:

• #16180: Raises an "invalid string" error if the string cannot be converted.

{"bytes.encodeUtf16be": [s]}
 s string (returns) bytes

Description: Encode a string as big endian utf-16 bytes.

Runtime Errors:

• #16190: Raises an "invalid string" error if the string cannot be converted.

{"bytes.encodeUtf16le": [s]}
 s string (returns) bytes

Description: Encode a string as little endian utf-16 bytes.

Runtime Errors:

• #16200: Raises an "invalid string" error if the string cannot be converted.

{"bytes.toBase64": [x]}
 x bytes (returns) string

Description: Convert an arbitrary bytes object to a base64-encoded string.

{"bytes.fromBase64": [s]}
 s string (returns) bytes

Description: Convert a base64-encoded string to a bytes object.

Runtime Errors:

• #16220: Raises an "invalid base64" error if the string is not valid base64.

## fixed

{"fixed.toBytes": [x]}
 x any fixed A (returns) bytes

Description: Convert fixed-length, named bytes into arbitrary-length, anonymous bytes.

{"fixed.fromBytes": [original, replacement]}
 original any fixed A replacement bytes (returns) A

Description: Overlay replacement on top of original.

Details:

• If replacement is shorter than original, the bytes beyond replacement's length are taken from original.
• If replacement is longer than original, the excess bytes are truncated.

## enum

{"enum.toString": [x]}
 x any enum A (returns) string

Description: Return the string representation of an enum.

{"enum.toInt": [x]}
 x any enum A (returns) int

Description: Return the integer representation of an enum.

{"enum.numSymbols": [x]}
 x any enum A (returns) int

Description: Return the number of symbols associated with this enum (a constant).

## time

{"time.year": [ts, zone]}
 ts double zone string (returns) int

Description: Get the four-digit year that the timestamp falls within.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40000: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40001: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.monthOfYear": [ts, zone]}
 ts double zone string (returns) int

Description: Get the month that the timestamp falls within, with 1 being January and 12 being December.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40010: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40011: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.dayOfYear": [ts, zone]}
 ts double zone string (returns) int

Description: Get the day of the year that the timestamp falls within, from 1 to 365 or 366 inclusive, depending on leap year.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40020: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40021: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.dayOfMonth": [ts, zone]}
 ts double zone string (returns) int

Description: Get the day of the month that the timestamp falls within, a number from 1 to 28, 29, 30, or 31, inclusive, depending on month.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40030: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40031: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.dayOfWeek": [ts, zone]}
 ts double zone string (returns) int

Description: Get the day of the week that the timestamp falls within, with 0 being Monday and 6 being Sunday.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40040: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40041: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.hourOfDay": [ts, zone]}
 ts double zone string (returns) int

Description: Get the hour of the day that the timestamp falls within, from 0 to 23 inclusive.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40050: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40051: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.minuteOfHour": [ts, zone]}
 ts double zone string (returns) int

Description: Get the minute of the hour that the timestamp falls within, from 0 to 59 inclusive.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40060: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40061: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.secondOfMinute": [ts, zone]}
 ts double zone string (returns) int

Description: Get the second of the minute that the timestamp falls within, from 0 to 59 inclusive.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40070: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40071: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.makeTimestamp": [year, month, day, hour, minute, second, millisecond, zone]}
 year int month int day int hour int minute int second int millisecond int zone string (returns) double

Description: Given the date and time that this time occurs in, return the timestamp.

Parameters:

 year The four-digit year, from 1 to 9999 inclusive. month The month of the year, from 1 to 12 inclusive. day The day of the month, from 1 to 28, 29, 30, or 31 inclusive, depending on month. hour The hour of the day, from 0 to 23 inclusive. minute The minute of the hour, from 0 to 59 inclusive. second The second of the minute, from 0 to 59 inclusive. millisecond The millisecond of the second, from 0 to 999 inclusive. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Returns:

 The number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40080: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40081: Raises "timestamp undefined for given parameters" if any one (or more) of the inputs have impossible values.

{"time.isSecondOfMinute": [ts, zone, low, high]}
 ts double zone string low double high double (returns) boolean

Description: Determines if a timestamp falls within a specified number of seconds in any minute.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank). low Minimum number of seconds (inclusive). high Maximum number of seconds (exclusive).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40090: Raises "bad time range" if low $$\mathrm{low} \geq \mathrm{high}$$.
• #40091: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40092: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.isMinuteOfHour": [ts, zone, low, high]}
 ts double zone string low double high double (returns) boolean

Description: Determines if a timestamp falls within a specified number of minutes in any hour.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank). low Minimum number of minutes (inclusive) high Maximum number of minutes (exclusive).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40100: Raises "bad time range" if low $$\mathrm{low} \geq \mathrm{high}$$.
• #40101: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40102: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.isHourOfDay": [ts, zone, low, high]}
 ts double zone string low double high double (returns) boolean

Description: Determines if a timestamp falls within a specified number of hours in any day.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank). low Minimum number of hours (inclusive). high Maximum number of hours (exclusive).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40110: Raises "bad time range" if low $$\mathrm{low} \geq \mathrm{high}$$.
• #40111: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40112: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.isDayOfWeek": [ts, zone, low, high]}
 ts double zone string low double high double (returns) boolean

Description: Determines if a timestamp falls within a specified day of week range, with 0 being Monday and 6 being Sunday.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank). low Minimum day of the week (inclusive). high Maximum day of the week (exclusive).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40120: Raises "bad time range" if low $$\mathrm{low} \geq \mathrm{high}$$.
• #40121: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40122: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.isDayOfMonth": [ts, zone, low, high]}
 ts double zone string low double high double (returns) boolean

Description: Determines if a timestamp falls within a specified day of month range, with 1 being the first of the month..

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank). low Minimum day of the month (inclusive). high Maximum day of the month (exclusive).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40130: Raises "bad time range" if low $$\mathrm{low} \geq \mathrm{high}$$.
• #40131: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40132: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.isMonthOfYear": [ts, zone, low, high]}
 ts double zone string low double high double (returns) boolean

Description: Determines if a timestamp falls within a specified month of year range, with 1 being January and 12 being December.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank). low Minimum month of the year (inclusive). high Maximum month of the year (exclusive).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40140: Raises "bad time range" if low $$\mathrm{low} \geq \mathrm{high}$$.
• #40141: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40142: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.isDayOfYear": [ts, zone, low, high]}
 ts double zone string low double high double (returns) boolean

Description: Determines if a timestamp falls within a specified day of year range, with 1 being the first of the year.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank). low Minimum day of year (inclusive). high Maximum day of year (exclusive).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40150: Raises "bad time range" if low $$\mathrm{low} \geq \mathrm{high}$$.
• #40151: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40152: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.isWeekend": [ts, zone]}
 ts double zone string (returns) boolean

Description: Returns true if the timestamp falls on a Saturday or Sunday, false otherwise.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40160: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40161: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

{"time.isWorkHours": [ts, zone]}
 ts double zone string (returns) boolean

Description: Returns true if the timestamp falls between 9 am (inclusive) and 5 pm (exclusive) on Monday through Friday, otherwise false.

Parameters:

 ts Number of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC. zone Timezone name from the Olson timezone database, version 2015f (UTC if blank).

Details:

• The earliest expressible date is the beginning (just after midnight) of Jan 1, 1 C.E. in UTC on the proleptic Gregorian calendar, which is a timestamp of -62135596800. The latest expressible date is the end (just before midnight) of Dec 31, 9999 C.E. in UTC on the Gregorian calendar, which is a timestamp of 253402300799.

Runtime Errors:

• #40170: Raises "unrecognized timezone string" if zone is not in the Olson 2015f database.
• #40171: Raises "timestamp out of range" if ts less than -62135596800 or greater than 253402300799.

## impute

{"impute.errorOnNull": [x]}
 x union of {any A, null} (returns) A

Description: Skip an action by raising a runtime error when x is null.

Runtime Errors:

• #21000: Raises an "encountered null" error if x is null.

{"impute.defaultOnNull": [x, default]}
 x union of {any A, null} default A (returns) A

Description: Replace null values in x with default.

{"impute.isnan": [x]}
 x float (returns) boolean
{"impute.isnan": [x]}
 x double (returns) boolean

Description: Return true if x is nan, false otherwise.

{"impute.isinf": [x]}
 x float (returns) boolean
{"impute.isinf": [x]}
 x double (returns) boolean

Description: Return true if x is positive or negative infinity, false otherwise.

{"impute.isnum": [x]}
 x float (returns) boolean
{"impute.isnum": [x]}
 x double (returns) boolean

Description: Return true if x is neither nan nor infinite, false otherwise.

{"impute.errorOnNonNum": [x]}
 x float (returns) float
{"impute.errorOnNonNum": [x]}
 x double (returns) double

Description: Pass through x if it is neither nan nor infinite, but raise an error otherwise.

Runtime Errors:

• #21050: Raises an "encountered nan" if x is nan.
• #21051: Raises an "encountered +inf" if x is positive infinity.
• #21052: Raises an "encountered -inf" if x is negative infinity.

{"impute.defaultOnNonNum": [x, default]}
 x float default float (returns) float
{"impute.defaultOnNonNum": [x, default]}
 x double default double (returns) double

Description: Pass through x if it is neither nan nor infinite, and return default otherwise.

## interp

{"interp.bin": [x, numbins, low, high]}
 x double numbins int low double high double (returns) int
{"interp.bin": [x, origin, width]}
 x double origin double width double (returns) int

Description: Finds the bin that contains x, declared either as numbins between two endpoints or a bin width starting at some origin.

Details:

• Bins are inclusive on the low end and exclusive on the high end, so if x equal low or origin, the resulting bin is 0, but if x is equal to high, it is out of range.
• If the first signature is used, the resulting bin must be between 0 (inclusive) and numbins (exclusive). If the second signature is used, the resulting bin may be any integer, including negative numbers.

Runtime Errors:

• #22000: If low is greater or equal to high or origin is not finite, raises "bad histogram range"
• #22001: If numbins is less than 1 or width is less or equal to 0, raises "bad histogram scale"
• #22002: Raises "x out of range" if x is less than low or greater or equal to high.

{"interp.nearest": [x, table]}
 x double table array of any record R with fields {x: double, to: any T} (returns) T
{"interp.nearest": [x, table]}
 x array of double table array of any record R with fields {x: array of double, to: any T} (returns) T
{"interp.nearest": [x, table, metric]}
 x any X1 table array of any record R with fields {x: any X2, to: any T} metric function of (X1, X2) → double (returns) T

Description: Finds the closest x value in the table to the input x and returns the corresponding to value.

Details:

• Any ties in distance are resolved in favor of the first instance in the table.

Runtime Errors:

• #22010: Raises a "table must have at least one entry" error if table has fewer than one entry.
• #22011: Raises an "inconsistent dimensionality" error if any input x and record x have different numbers of dimensions.

{"interp.linear": [x, table]}
 x double table array of any record R with fields {x: double, to: double} (returns) double
{"interp.linear": [x, table]}
 x double table array of any record R with fields {x: double, to: array of double} (returns) array of double

Description: Finds the closest x values in the table that are below and above the input x and linearly projects their to values to the input x.

Details:

• Any ties in distance are resolved in favor of the first instance in the table.
• If the to values are arrays, each component will be interpolated.

Runtime Errors:

• #22020: Raises a "table must have at least two distinct x values" error if fewer than two of the table x entries are unique.
• #22021: Raises an "inconsistent dimensionality" error if the to values of the two closest entries have different numbers of dimensions.

{"interp.linearFlat": [x, table]}
 x double table array of any record R with fields {x: double, to: double} (returns) double
{"interp.linearFlat": [x, table]}
 x double table array of any record R with fields {x: double, to: array of double} (returns) array of double

Description: Like interp.linear, but returns the closest entry's to if the input x is beyond the table.

Details:

• Any ties in distance are resolved in favor of the first instance in the table.
• If the to values are arrays, each component will be interpolated.

Runtime Errors:

• #22030: Raises a "table must have at least two distinct x values" error if table has fewer than two entries.
• #22031: Raises an "inconsistent dimensionality" error if the to values of the two closest entries have different numbers of dimensions.

{"interp.linearMissing": [x, table]}
 x double table array of any record R with fields {x: double, to: double} (returns) union of {null, double}
{"interp.linearMissing": [x, table]}
 x double table array of any record R with fields {x: double, to: array of double} (returns) union of {null, array of double}

Description: Like interp.linear, but returns a missing value (null) if the input x is beyond the table.

Details:

• Any ties in distance are resolved in favor of the first instance in the table.
• If the to values are arrays, each component will be interpolated.

Runtime Errors:

• #22040: Raises a "table must have at least two distinct x values" error if table has fewer than two entries.
• #22041: Raises an "inconsistent dimensionality" error if the to values of the two closest entries have different numbers of dimensions.

## prob.dist

{"prob.dist.gaussianLL": [x, mu, sigma]}
 x double mu double sigma double (returns) double
{"prob.dist.gaussianLL": [x, params]}
 x double params any record A with fields {mean: double, variance: double} (returns) double

Description: Compute the log-likelihood of a Gaussian (normal) distribution parameterized by mu and sigma or a record params.

Parameters:

 x Value at which to compute the log-likelihood. mu Centroid of the distribution (same as mean). sigma Width of the distribution (same as the square root of variance). params Alternate way of specifying the parameters of the distribution; this record could be created by stat.sample.update.

Returns:

 With $$\mu$$ = mu or mean and $$\sigma$$ = sigma or the square root of variance, this function returns $$-(x - \mu)^2/(2 \sigma^2) - \log(\sigma \sqrt{2\pi})$$.

Runtime Errors:

• #13000: Raises an "invalid parameterization" error if sigma or variance is negative or any argument is not finite.
• #13001: Raises "invalid input" if x is not finite.

{"prob.dist.gaussianCDF": [x, mu, sigma]}
 x double mu double sigma double (returns) double
{"prob.dist.gaussianCDF": [x, params]}
 x double params any record A with fields {mean: double, variance: double} (returns) double

Description: Compute the cumultive distribution function (CDF) for the normal distribution, parameterized by mu and sigma or a record params.

Parameters:

 x Value at which to compute the CDF. mu Centroid of the distribution (same as mean). sigma Width of the distribution (same as the square root of variance). params Alternate way of specifying the parameters of the distribution; this record could be created by stat.sample.update.

Returns:

 With $$\mu$$ = mu or mean and $$\sigma$$ = sigma or the square root of variance, this function returns $$0.5 * ( 1.0 + \mathrm{Erf}(\frac{x - \mu}{\sigma \sqrt{2}}))$$.

Runtime Errors:

• #13010: Raises an "invalid parameterization" error if sigma or variance is negative or any argument is not finite.
• #13011: Raises "invalid input" if x is not finite.

{"prob.dist.gaussianQF": [p, mu, sigma]}
 p double mu double sigma double (returns) double
{"prob.dist.gaussianQF": [p, params]}
 p double params any record A with fields {mean: double, variance: double} (returns) double

Description: Compute the normal quantile (QF, the inverse of the CDF) parameterized by mu and sigma or a record params.

Parameters:

 p Probability at which to compute the QF. Must be a value between 0 and 1. mu Centroid of the distribution (same as mean). sigma Width of the distribution (same as the square root of variance). params Alternate way of specifying the parameters of the distribution; this record could be created by stat.sample.update.

Returns:

 With $$\mu$$ = mu or mean and $$\sigma$$ = sigma or the square root of variance, this function returns $$\mu + \sigma \sqrt{2} \mathrm{Erf}^{-1} (2p - 1)$$.

Runtime Errors:

• #13020: Raises an "invalid parameterization" error if sigma or variance is negative or any argument is not finite.
• #13021: Raises an "invalid input" error if p is less than zero or greater than one.

{"prob.dist.exponentialPDF": [x, lambda]}
 x double lambda double (returns) double

Description: Compute the density (PDF) of the exponential distribution parameterized by lambda.

Parameters:

 x Value at which to compute the PDF. lambda Rate parameter.

Returns:

 With $$lambda$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\lambda \mathrm{e}^{- \lambda x}$$.

Runtime Errors:

• #13030: Raises "invalid parameterization" if $$lambda < 0$$ or any argument is not finite.
• #13031: Raises "invalid input" if x is not finite.

{"prob.dist.exponentialCDF": [x, lambda]}
 x double lambda double (returns) double

Description: Compute the distribution function (CDF) of the exponential distribution parameterized by lambda.

Parameters:

 x Value at which to compute the CDF. lambda Rate parameter.

Returns:

 With $$lambda$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13040: Raises "invalid parameterization" if $$lambda < 0$$ or any argument is not finite.
• #13041: Raises "invalid input" if x is not finite.

{"prob.dist.exponentialQF": [p, lambda]}
 p double lambda double (returns) double

Description: Compute the quantile function (QF) of the exponential distribution parameterized by lambda.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. lambda Rate parameter.

Returns:

 With $$lambda$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X~\leq~x)~=~p$$.

Runtime Errors:

• #13050: Raises "invalid parameterization" if $$lambda < 0$$ or any argument is not finite.
• #13051: Raises an "invalid input" error if p is less than zero or greater than one.

{"prob.dist.chi2PDF": [x, dof]}
 x double dof int (returns) double

Description: Compute the density (PDF) of the Chi-squared distribution parameterized by its degrees of freedom dof.

Parameters:

 x Value at which to compute the PDF. dof Degrees of freedom parameter.

Returns:

 With $$dof$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{1}{2^{\frac{\mathrm{df}}{2}} \Gamma(\frac{\mathrm{df}}{2})} x^{\frac{\mathrm{df}}{2}-1}\mathrm{e}^{-\frac{x}{2}}$$.

Runtime Errors:

• #13060: Raises "invalid parameterization" if dof < 0 or any argument is not finite.
• #13061: Raises "invalid input" if x is not finite.

{"prob.dist.chi2CDF": [x, dof]}
 x double dof int (returns) double

Description: Compute the distribution function (CDF) of the Chi-squared distribution parameterized by its degrees of freedom dof.

Parameters:

 x Value at which to compute the CDF. dof Degrees of freedom parameter.

Returns:

 With $$x1$$, $$x1$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13070: Raises "invalid parameterization" if dof < 0 or any argument is not finite.
• #13071: Raises "invalid input" if x is not finite.

{"prob.dist.chi2QF": [p, dof]}
 p double dof int (returns) double

Description: Compute the quantile function (QF) of the Chi-squared distribution parameterized by its degrees of freedom dof.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. dof Degrees of freedom parameter.

Returns:

 With $$x1$$, $$x1$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X \leq x) = p$$.

Runtime Errors:

• #13080: Raises "invalid parameterization" if dof < 0 or any argument is not finite.
• #13081: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.poissonPDF": [x, lambda]}
 x int lambda double (returns) double

Description: Compute the density (PDF) of the poisson distribution parameterized by lambda.

Parameters:

 x Value at which to compute the PDF. lambda Mean and variance parameter.

Returns:

 With $$lambda$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{\lambda^{x}}{x!} \mathrm{e}^{-\lambda}$$.

Runtime Errors:

• #13090: Raises "invalid parameterization" if $$lambda < 0$$ or any argument is not finite.

{"prob.dist.poissonCDF": [x, lambda]}
 x int lambda double (returns) double

Description: Compute the distribution function (CDF) of the poisson distribution parameterized by lambda.

Parameters:

 x Value at which to compute the CDF. lambda Mean and variance parameter.

Returns:

 With $$lambda$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13100: Raises "invalid parameterization" if $$lambda < 0$$ or any argument is not finite.
• #13101: Raises "invalid input" if x is not finite.

{"prob.dist.poissonQF": [p, lambda]}
 p double lambda double (returns) double

Description: Compute the quantile function (QF) of the poisson distribution parameterized by lambda.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. lambda Mean and variance parameter.

Returns:

 With $$lambda$$, $$lambda$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X \leq x) = p$$.

Runtime Errors:

• #13110: Raises "invalid parameterization" if $$lambda < 0$$ or any argument is not finite.
• #13111: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.gammaPDF": [x, shape, scale]}
 x double shape double scale double (returns) double

Description: Compute the density (PDF) of the gamma distribution parameterized by shape and scale.

Parameters:

 x Value at which to compute the PDF. shape Shape parameter (a). scale Scale parameter (s).

Returns:

 With $$shape$$, $$scale$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{1}{s^{a} \Gamma(a)} x^{a - 1} \mathrm{e}^{-\frac{x}{s}}$$.

Runtime Errors:

• #13120: Raises "invalid parameterization" if the $$shape < 0$$ OR if $$scale < 0$$ or any argument is not finite.
• #13121: Raises "invalid input" if x is not finite.

{"prob.dist.gammaCDF": [x, shape, scale]}
 x double shape double scale double (returns) double

Description: Compute the distribution function (CDF) of the gamma distribution parameterized by shape and scale.

Parameters:

 x Value at which to compute the CDF. shape Shape parameter. scale Scale parameter.

Returns:

 With $$shape$$, $$scale$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x)~= P(X~\leq~x)$$.

Runtime Errors:

• #13130: Raises "invalid parameterization" if the $$shape < 0$$ OR if $$scale < 0$$ or any argument is not finite.
• #13131: Raises "invalid input" if x is not finite.

{"prob.dist.gammaQF": [p, shape, scale]}
 p double shape double scale double (returns) double

Description: Compute the quantile function (QF) of the gamma distribution parameterized by shape and scale.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. shape Shape parameter. scale Scale parameter.

Returns:

 With $$shape$$, $$scale$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x)~:= P(X~\leq~x)~=~p$$.

Runtime Errors:

• #13140: Raises "invalid parameterization" if the $$shape \leq 0$$ OR if $$scale \leq 0$$ or any argument is not finite.
• #13141: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.betaPDF": [x, a, b]}
 x double a double b double (returns) double

Description: Compute the density (PDF) of the beta distribution parameterized by shape1 and shape2.

Parameters:

 x Value at which to compute the PDF, defined between zero and one. a First shape parameter. b Second shape parameter.

Returns:

 With $$a$$, $$b$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{\Gamma(a + n)}{\Gamma(a)\Gamma(b)} x^{a-1}(1-x)^{b-1}$$.

Runtime Errors:

• #13150: Raises "invalid parameterization" if $$a \leq 0$$ OR if $$b \leq 0$$ or any argument is not finite.
• #13151: Raises "invalid input" if x is not finite.

{"prob.dist.betaCDF": [x, a, b]}
 x double a double b double (returns) double

Description: Compute the distribution function (CDF) of the beta distribution parameterized by shape1 and shape2.

Parameters:

 x Value at which to compute the CDF. a First shape parameter. b Second shape parameter.

Returns:

 With $$a$$, $$b$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13160: Raises "invalid parameterization" if $$a \leq 0$$ OR if $$b \leq 0$$ or any argument is not finite.
• #13161: Raises "invalid input" if x is not finite.

{"prob.dist.betaQF": [p, a, b]}
 p double a double b double (returns) double

Description: Compute the quantile function (QF) of the beta distribution parameterized by shape1 and shape2.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. a First shape parameter. b Second shape parameter.

Returns:

 With $$a$$, $$b$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X \leq x) = p$$.

Runtime Errors:

• #13170: Raises "invalid parameterization" if the $$a \leq 0$$ OR if $$b \leq 0$$ or any argument is not finite.
• #13171: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.cauchyPDF": [x, location, scale]}
 x double location double scale double (returns) double

Description: Compute the density (PDF) of the cauchy distribution parameterized by location and scale.

Parameters:

 x Value at which to compute the PDF. location Location parameter (l). scale Scale parameter (s).

Returns:

 With $$location$$, $$scale$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{1}{(\pi s (1 + (\frac{x - l}{s})^{2})) }$$.

Runtime Errors:

• #13180: Raises "invalid parameterization" if $$scale \leq 0$$ or any argument is not finite.
• #13181: Raises "invalid input" if x is not finite.

{"prob.dist.cauchyCDF": [x, location, scale]}
 x double location double scale double (returns) double

Description: Compute the distribution function (CDF) of the cauchy distribution parameterized by location and scale.

Parameters:

 x Value at which to compute the CDF. location Location parameter. scale Scale parameter.

Returns:

 With $$location$$, $$scale$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13190: Raises "invalid parameterization" if $$scale \leq 0$$ or any argument is not finite.
• #13191: Raises "invalid input" if x is not finite.

{"prob.dist.cauchyQF": [p, location, scale]}
 p double location double scale double (returns) double

Description: Compute the quantile function (QF) of the cauchy distribution parameterized by location and scale.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. location Location parameter. scale Scale parameter.

Returns:

 With $$location$$, $$scale$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X \leq x) = p$$.

Runtime Errors:

• #13200: Raises "invalid parameterization" if $$scale \leq 0$$ or any argument is not finite.
• #13201: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.fPDF": [x, d1, d2]}
 x double d1 int d2 int (returns) double

Description: Compute the density (PDF) of the F distribution parameterized by d1 and d2.

Parameters:

 x Value at which to compute the PDF. d1 Numerator degrees of freedom parameter. d2 Denominator degrees of freedom parameter.

Returns:

 With $$d1$$, $$d2$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{\Gamma(\frac{d1 + d2}{2})}{\Gamma(\frac{d1}{2})\Gamma(\frac{d2}{2})} \frac{d1}{d2}^{\frac{d1}{2}-1}(1 + \frac{d1}{d2} x)^{-\frac{d1 + d2}{2}}$$.

Runtime Errors:

• #13210: Raises "invalid parameterization" if the $$d1 \leq 0$$ OR if $$d2 \leq 0$$ or any argument is not finite.
• #13211: Raises "invalid input" if x is not finite.

{"prob.dist.fCDF": [x, d1, d2]}
 x double d1 int d2 int (returns) double

Description: Compute the distribution function (CDF) of the F distribution parameterized by d1 and d2.

Parameters:

 x Value at which to compute the CDF. d1 Numerator degrees of freedom parameter. d2 Denominator degrees of freedom parameter.

Returns:

 With $$d1$$, $$d2$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13220: Raises "invalid parameterization" if the $$d1 \leq 0$$ OR if $$d2 \leq 0$$ or any argument is not finite.
• #13221: Raises "invalid input" if x is not finite.

{"prob.dist.fQF": [p, d1, d2]}
 p double d1 int d2 int (returns) double

Description: Compute the quantile function (QF) of the F distribution parameterized by d1 and d2.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. d1 Numerator degrees of freedom parameter. d2 Denominator degrees of freedom parameter.

Returns:

 With $$d1$$, $$d2$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X~\leq~x)~=~p$$.

Runtime Errors:

• #13230: Raises "invalid parameterization" if the $$d1 \leq 0$$ OR if $$d2 \leq 0$$ or any argument is not finite.
• #13231: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.lognormalPDF": [x, meanlog, sdlog]}
 x double meanlog double sdlog double (returns) double

Description: Compute the density (PDF) of the lognormal distribution parameterized by meanlog and sdlog.

Parameters:

 x Value at which to compute the PDF. meanlog Mean of the distribution on the log scale ($$\mu$$). sdlog Standard deviation of the distribution on the log scale ($$\sigma$$).

Returns:

 With $$meanlog$$, $$sdlog$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{1}{\sqrt{2 \pi} \sigma x} \mathrm{e}^{-\frac{\mathrm{log}(x) - \mu}{2 \sigma^{2}}}$$.

Runtime Errors:

• #13240: Raises "invalid parameterization" if $$sdlog \leq 0$$ or any argument is not finite.
• #13241: Raises "invalid input" if x is not finite.

{"prob.dist.lognormalCDF": [x, meanlog, sdlog]}
 x double meanlog double sdlog double (returns) double

Description: Compute the distribution function (CDF) of the lognormal distribution parameterized by meanlog and sdlog.

Parameters:

 x Value at which to compute the CDF. meanlog Mean of the distribution on the log scale. sdlog Standard deviation of the distribution on the log scale.

Returns:

 With $$meanlog$$, $$sdlog$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13250: Raises "invalid parameterization" if $$sdlog \leq 0$$ or any argument is not finite.
• #13251: Raises "invalid input" if x is not finite.

{"prob.dist.lognormalQF": [p, meanlog, sdlog]}
 p double meanlog double sdlog double (returns) double

Description: Compute the quantile function (QF) of the lognormal distribution parameterized by meanlog and sdlog.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. meanlog Mean of the distribution on the log scale. sdlog Standard deviation of the distribution on the log scale.

Returns:

 With $$meanlog$$, $$sdlog$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X \leq x) = p$$.

Runtime Errors:

• #13260: Raises "invalid parameterization" if $$sdlog \leq 0$$ or any argument is not finite.
• #13261: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.tPDF": [x, dof]}
 x double dof int (returns) double

Description: Compute the density (PDF) of the student's t distribution parameterized by dof and x2.

Parameters:

 x Value at which to compute the PDF. dof Degrees of freedom parameter.

Returns:

 With $$dof$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{\Gamma(\frac{\mathrm{df}+1}{2})}{\sqrt{\mathrm{df}\pi} \Gamma{\frac{\mathrm{df}}{2}}}(1 + x^{\frac{2}{n}})^{-\frac{\mathrm{df} + 1}{2}}$$.

Runtime Errors:

• #13270: Raises "invalid parameterization" if $$df \leq 0$$ or any argument is not finite.
• #13271: Raises "invalid input" if x is not finite.

{"prob.dist.tCDF": [x, dof]}
 x double dof int (returns) double

Description: Compute the distribution function (CDF) of the student's t distribution parameterized by dof and x2.

Parameters:

 x Value at which to compute the CDF. dof Degrees of freedom parameter.

Returns:

 With $$dof$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13280: Raises "invalid parameterization" if $$df \leq 0$$ or any argument is not finite.
• #13281: Raises "invalid input" if x is not finite.

{"prob.dist.tQF": [p, dof]}
 p double dof int (returns) double

Description: Compute the quantile function (QF) of the student's t distribution parameterized by dof and x2.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. dof Degrees of freedom parameter.

Returns:

 With $$dof$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X \leq x) = p$$.

Runtime Errors:

• #13290: Raises "invalid parameterization" if $$df \leq 0$$ or any argument is not finite.
• #13291: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.binomialPDF": [x, size, prob]}
 x int size int prob double (returns) double

Description: Compute the density (PDF) of the binomial distribution parameterized by size and prob.

Parameters:

 x Value at which to compute the PDF. size The number of trials (n). prob The probability of success in each trial (p).

Returns:

 With $$size$$, $$prob$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\mathrm{choose}(n, x) p^{x} (1 - p)^{n - x}$$.

Runtime Errors:

• #13300: Raises "invalid parameterization" if $$size < 0$$ OR if $$prob < 0$$ OR if $$prob > 1$$ or any argument is not finite.
• #13301: Raises "invalid input" if x is not finite.

{"prob.dist.binomialCDF": [x, size, prob]}
 x double size int prob double (returns) double

Description: Compute the distribution function (CDF) of the binomial distribution parameterized by size and prob.

Parameters:

 x Value at which to compute the CDF. size The number of trials. prob The probability of success in each trial.

Returns:

 With $$size$$, $$prob$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13310: Raises "invalid parameterization" if $$size < 0$$ OR if $$prob < 0$$ OR if $$prob > 1$$ or any argument is not finite.
• #13311: Raises "invalid input" if x is not finite.

{"prob.dist.binomialQF": [p, size, prob]}
 p double size int prob double (returns) double

Description: Compute the quantile function (QF) of the binomial distribution parameterized by size and prob.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. size The number of trials. prob The probability of success in each trial.

Returns:

 With $$size$$, $$prob$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x)~:= P(X~\leq~x)~=~p$$.

Runtime Errors:

• #13320: Raises "invalid parameterization" if $$size < 0$$ OR if $$prob < 0$$ OR if $$prob > 1$$ or any argument is not finite.
• #13321: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.uniformPDF": [x, min, max]}
 x double min double max double (returns) double

Description: Compute the density (PDF) of the uniform distribution parameterized by min and max.

Parameters:

 x Value at which to compute the PDF. min Lower bound. max Upper bound.

Returns:

 With $$min$$, $$max$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{1}{\mathrm{max} - \mathrm{min}}$$.

Runtime Errors:

• #13330: Raises "invalid parameterization" if $$min \geq max$$ or any argument is not finite.
• #13331: Raises "invalid input" if x is not finite.

{"prob.dist.uniformCDF": [x, min, max]}
 x double min double max double (returns) double

Description: Compute the distribution function (CDF) of the uniform distribution parameterized by min and max.

Parameters:

 x Value at which to compute the CDF. min Lower bound. max Upper bound.

Returns:

 With $$min$$, $$max$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13340: Raises "invalid parameterization" if $$min \geq max$$ or any argument is not finite.
• #13341: Raises "invalid input" if x is not finite.

{"prob.dist.uniformQF": [p, min, max]}
 p double min double max double (returns) double

Description: Compute the quantile function (QF) of the uniform distribution parameterized by min and max.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. min Lower bound. max Upper bound.

Returns:

 With $$min$$, $$max$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X~\leq~x)~=~p$$.

Runtime Errors:

• #13350: Raises "invalid parameterization" if $$min \geq max$$ or any argument is not finite.
• #13351: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.geometricPDF": [x, prob]}
 x int prob double (returns) double

Description: Compute the density (PDF) of the geometric distribution parameterized by prob.

Parameters:

 x Value at which to compute the PDF. prob Probability of success of each trial (p).

Returns:

 With $$prob$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$p (1 - p)^{x}$$.

Runtime Errors:

• #13360: Raises "invalid parameterization" if $$\mathrm{prob} \leq 0$$ OR if $$\mathrm{prob} > 1$$ or any argument is not finite.
• #13361: Raises "invalid input" if x is not finite.

{"prob.dist.geometricCDF": [x, prob]}
 x double prob double (returns) double

Description: Compute the distribution function (CDF) of the geometric distribution parameterized by prob.

Parameters:

 x Value at which to compute the CDF. prob Probability of success of each trial.

Returns:

 With $$prob$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13370: Raises "invalid parameterization" if $$\mathrm{prob} \leq 0$$ OR if $$\mathrm{prob} > 1$$ or any argument is not finite.
• #13371: Raises "invalid input" if x is not finite.

{"prob.dist.geometricQF": [p, prob]}
 p double prob double (returns) double

Description: Compute the quantile function (QF) of the geometric distribution parameterized by prob.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. prob Probability of success of each trial.

Returns:

 With $$prob$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X \leq x) = p$$.

Runtime Errors:

• #13380: Raises "invalid parameterization" if $$\mathrm{prob} \leq 0$$ OR if $$\mathrm{prob} > 1$$ or any argument is not finite.
• #13381: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.hypergeometricPDF": [x, m, n, k]}
 x int m int n int k int (returns) double

Description: Compute the density (PDF) of the hypergeometric distribution parameterized by m, n and k.

Parameters:

 x The number of white balls drawn without replacement from the urn. m The number of white balls in the urn. n The number of black balls in the urn. k The number of balls drawn from the urn.

Returns:

 With $$m$$, $$n$$ and $$k$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{\mathrm{choose}(m, x) \mathrm{choose}(n, k-x)}{\mathrm{choose}(m+n, k)}$$.

Runtime Errors:

• #13390: Raises "invalid parameterization" if $$\mathrm{m} + \mathrm{n} < \mathrm{k}$$, $$m < 0$$, $$n < 0$$, $$m + n = 0$$, or $$k < 0$$.

{"prob.dist.hypergeometricCDF": [x, m, n, k]}
 x int m int n int k int (returns) double

Description: Compute the distribution function (CDF) of the hypergeometric distribution parameterized by m, n and k.

Parameters:

 x The number of white balls drawn without replacement. m The number of white balls in the urn. n The number of black balls in the urn. k The number of balls drawn from the urn.

Returns:

 With $$m$$, $$n$$ and $$k$$ at $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13400: Raises "invalid parameterization" if $$\mathrm{m} + \mathrm{n} < \mathrm{k}$$, $$m < 0$$, $$n < 0$$, $$m + n = 0$$, or $$k < 0$$.
• #13401: Raises "invalid input" if x is not finite.

{"prob.dist.hypergeometricQF": [p, m, n, k]}
 p double m int n int k int (returns) double

Description: Compute the quantile function (QF) of the hypergeometric distribution parameterized by m, n and k.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. m The number of white balls in the urn. n The number of black balls in the urn. k The number of balls drawn from the urn.

Returns:

 With $$m$$, $$n$$ and $$k$$ at $$p$$, this function returns the value $$x$$ such that $$F_{X}(x)~:= P(X~\leq~x)~=~p$$.

Runtime Errors:

• #13410: Raises "invalid parameterization" if $$\mathrm{m} + \mathrm{n} < \mathrm{k}$$, $$m < 0$$, $$n < 0$$, $$m + n = 0$$, or $$k < 0$$ or any argument is not finite.
• #13411: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.weibullPDF": [x, shape, scale]}
 x double shape double scale double (returns) double

Description: Compute the density (PDF) of the weibull distribution parameterized by shape and scale.

Parameters:

 x Value at which to compute the PDF. shape Shape parameter (a). scale Scale parameter (b).

Returns:

 With $$shape$$, $$scale$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{a}{b}(\frac{x}{b})^{a - 1}\mathrm{e}^{-(\frac{x}{b})^{a}}$$.

Runtime Errors:

• #13420: Raises "invalid parameterization" if the $$shape \leq 0$$ OR if $$scale \leq 0$$ or any argument is not finite.
• #13421: Raises "invalid input" if x is not finite.

{"prob.dist.weibullCDF": [x, shape, scale]}
 x double shape double scale double (returns) double

Description: Compute the distribution function (CDF) of the weibull distribution parameterized by shape and scale.

Parameters:

 x Value at which to compute the CDF. shape Shape parameter. scale Scale parameter.

Returns:

 With $$shape$$, $$scale$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X~\leq~x)$$.

Runtime Errors:

• #13430: Raises "invalid parameterization" if the $$shape \leq 0$$ OR if $$scale \leq 0$$ or any argument is not finite.
• #13431: Raises "invalid input" if x is not finite.

{"prob.dist.weibullQF": [p, shape, scale]}
 p double shape double scale double (returns) double

Description: Compute the quantile function (QF) of the weibull distribution parameterized by shape and scale.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. shape Shape parameter. scale Scale parameter.

Returns:

 With $$shape$$, $$scale$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X~\leq~x)~=~p$$.

Runtime Errors:

• #13440: Raises "invalid parameterization" if the $$shape \leq 0$$ OR if $$scale \leq 0$$ or any argument is not finite.
• #13441: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

{"prob.dist.negativeBinomialPDF": [x, size, prob]}
 x int size int prob double (returns) double

Description: Compute the density (PDF) of the negative binomial distribution parameterized by size and prob.

Parameters:

 x Value at which to compute the PDF (integer) . size Size parameter (integer). Target number of successful trials (n). prob Probability of success in each trial (p).

Returns:

 With $$size$$, $$prob$$ and $$x$$, this function evaluates the probability density function at $$x$$. The PDF implemented is $$\frac{\Gamma(x+n)}{\Gamma(n) x!} p^{n} (1-p)^{x}$$.

Runtime Errors:

• #13450: Raises "invalid parameterization" if $$\mathrm{prob} < 0$$, if $$\mathrm{prob} > 1$$ or if $$size < 0$$ or any argument is not finite.
• #13451: Raises "invalid input" if x is not finite.

{"prob.dist.negativeBinomialCDF": [x, size, prob]}
 x double size int prob double (returns) double

Description: Compute the distribution function (CDF) of the negative binomial distribution parameterized by size and prob.

Parameters:

 x Value at which to compute the CDF. size Size parameter (integer). Target number of successful trials. prob Probability of success in each trial.

Returns:

 With $$size$$, $$prob$$ and $$x$$, this function returns the value $$p$$ where $$p = F_{X}(x) = P(X \leq x)$$.

Runtime Errors:

• #13460: Raises "invalid parameterization" if $$\mathrm{prob} < 0$$, if $$\mathrm{prob} > 1$$, or if $$size < 0$$ or any argument is not finite.
• #13461: Raises "invalid input" if x is not finite.

{"prob.dist.negativeBinomialQF": [p, size, prob]}
 p double size int prob double (returns) double

Description: Compute the quantile function (QF) of the negative binomial distribution parameterized by size and prob.

Parameters:

 p Value at which to compute the QF. Must be a value between 0 and 1. size Size parameter (integer). Target number of successful trials. prob Probability of success in each trial.

Returns:

 With $$size$$, $$prob$$ and $$p$$, this function returns the value $$x$$ such that $$F_{X}(x) := P(X \leq x) = p$$.

Runtime Errors:

• #13470: Raises "invalid parameterization" if $$\mathrm{prob} < 0$$, if $$\mathrm{prob} > 1$$, or if $$size \leq 0$$, or if $$size$$ or any argument is not finite.
• #13471: Raises "invalid input" if $$p < 0$$ OR if $$p > 1$$.

## stat.test

{"stat.test.kolmogorov": [x, y]}
 x array of double y array of double (returns) double

Description: Compare two datasets using the Kolmogorov-Smirnov test to determine if they might have been drawn from the same parent distribution.

Parameters:

 x A bag of data. y Another bag of data.

Returns:

 Returns a value between 0.0 and 1.0 representing the cumulative probability that x and y were drawn from the same distribution: 1.0 indicates a perfect match.

Details:

• If both datasets (ignoring NaN values) are empty, this function returns 1.0

{"stat.test.residual": [observation, prediciton]}
 observation double prediciton double (returns) double
{"stat.test.residual": [observation, prediciton]}
 observation array of double prediciton array of double (returns) array of double
{"stat.test.residual": [observation, prediciton]}
 observation map of double prediciton map of double (returns) map of double

Description: Compare an observation with its prediction by element-wise subtraction.

Parameters:

 observation Scalar or vector of observations. prediction Scalar or vector of predictions.

Returns:

 Scalar or vector of observation minus prediction.

Runtime Errors:

• #38010: Raises a "misaligned prediction" error if prediction does not have the same indexes or keys as observation.

{"stat.test.pull": [observation, prediciton, uncertainty]}
 observation double prediciton double uncertainty double (returns) double
{"stat.test.pull": [observation, prediciton, uncertainty]}
 observation array of double prediciton array of double uncertainty array of double (returns) array of double
{"stat.test.pull": [observation, prediciton, uncertainty]}
 observation map of double prediciton map of double uncertainty map of double (returns) map of double

Description: Compare an observation with its prediction by element-wise subtraction, weighted by element-wise uncertainties.

Parameters:

 observation Scalar or vector of observations. prediction Scalar or vector of predictions. uncertainty Scalar or vector of predictions.

Returns:

 Scalar or vector of observation minus prediction divided by uncertainty.

Runtime Errors:

• #38020: Raises a "misaligned prediction" error if prediction does not have the same indexes or keys as observation.
• #38021: Raises a "misaligned uncertainty" error if prediction does not have the same indexes or keys as uncertainty.

{"stat.test.mahalanobis": [observation, prediction, covariance]}
 observation array of double prediction array of double covariance array of array of double (returns) double
{"stat.test.mahalanobis": [observation, prediction, covariance]}
 observation map of double prediction map of double covariance map of map of double (returns) double

Description: Compare an observation with its prediction by computing the Mahalanobis distance for a given covariance matrix.

Parameters:

 observation Vector of observations $$\vec{o}$$. prediction Vector of predictions $$\vec{p}$$. covariance Matrix of covariance $$C$$.

Returns:

 Scalar result of a similarity transformation: $$\sqrt{(\vec{o} - \vec{p})^T C^{-1} (\vec{o} - \vec{p})}$$.

Runtime Errors:

• #38030: Raises a "too few rows/cols" error if observation has fewer than one element.
• #38031: Raises a "misaligned prediction" error if prediction does not have the same indexes or keys as observation.
• #38032: Raises a "misaligned covariance" error if covariance does not have the same indexes or keys as observation.

{"stat.test.updateChi2": [pull, state]}
 pull double state any record A with fields {chi2: double, dof: int} (returns) A
{"stat.test.updateChi2": [pull, state]}
 pull array of double state any record A with fields {chi2: double, dof: int} (returns) A
{"stat.test.updateChi2": [pull, state]}
 pull map of double state any record A with fields {chi2: double, dof: int} (returns) A

Description: Update the state of a chi-square calculation.

Parameters:

 pull Observation minus prediction divided by uncertainty. If this is a scalar, it will be squared and added to the chi-square. If a vector, each component will be squared and added to the chi-square. state Record of the previous chi2 and dof.

{"stat.test.reducedChi2": [state]}
 state any record A with fields {chi2: double, dof: int} (returns) double

Description: Return the reduced chi-square, which is chi2/dof.

Parameters:

 state Record of the chi2 and dof.

{"stat.test.chi2Prob": [state]}
 state any record A with fields {chi2: double, dof: int} (returns) double

Description: Return the chi-square probability, which is the CDF of the chi-square function.

Parameters:

 state Record of the chi2 and dof.

Runtime Errors:

• #38060: Raises "invalid parameterization" if dof is less than zero.

## stat.sample

{"stat.sample.update": [x, w, state]}
 x double w double state any record A with fields {count: double} (returns) A

Description: Update the state of a counter, a counter and a mean, or a counter, mean, and variance.

Parameters:

xSample value.
wSample weight; set to 1 for no weights.
stateRecord of the previous count, mean, and/or variance.
 count The sum of weights w. mean The mean of x, weighted by w. This field is optional, but if provided, it must be a double. variance The variance of $$x - \mbox{mean}$$, weighted by w. This field is optional, but if it is provided, it must be a double, and there must be a mean as well. No attempt is made to unbias the estimator, so multiply this by $$\mbox{count}/(\mbox{count} - 1)$$ to correct for the bias due to centering on the mean.

Returns:

 Returns an updated version of state with count incremented by w, mean updated to the current mean of all x, and variance updated to the current variance of all x. If the state has fields other than count, mean, and variance, they are copied unaltered to the output state.

{"stat.sample.updateCovariance": [x, w, state]}
 x array of double w double state any record A with fields {count: double, mean: array of double, covariance: array of array of double} (returns) A
{"stat.sample.updateCovariance": [x, w, state]}
 x map of double w double state any record A with fields {count: map of map of double, mean: map of double, covariance: map of map of double} (returns) A

Description: Update the state of a covariance calculation.

Parameters:

xSample vector, expressed as an array or map; must have at least two components.
wSample weight; set to 1 for no weights.
stateRecord of the previous count, mean, and covariance.
 count The sum of weights w. If x is an array, then count is a single value representing the sum of weights for all records seen so far. If x is a map, then count is a matrix in which entry $$i$$, $$j$$ is the sum of weights for records in which key $$i$$ and key $$j$$ both appear in x. mean The componentwise mean of x, weighted by w. covariance The covariance matrix of all pairs of components of x, weighted by w. If x is an array, this matrix is represented by a list of lists. If x is a map, this matrix is represented by a map of maps.

Returns:

 Returns an updated version of state with count incremented by w, mean updated to the current componentwise mean of all x, and covariance updated to the current covariance matrix of all x. If the state has fields other than count, mean, and covariance, they are copied unaltered to the output state.

Details:

• Like most functions that deal with matrices, this function has an array signature and a map signature. In the array signature, indexes of x correspond to the same indexes of mean and rows and columns of covariance, where a row is an index of covariance and a column is an index of an element of covariance. In the map signature, keys of x correspond to the same keys of mean, as well as rows and columns of count and covariance, where a row is a key of the object and a column is a key of a value of the object. In the array signature, all arrays must have equal length (including the nested arrays within covariance) and all components are updated with each call. In the map signature, a previously unseen key in x creates a new key in mean with value x, a new row and column in count with value w for all key pairs existing in x and zero for key pairs not in x, as well as a new row and column in covariance filled with zeros.
• In the map signature, missing keys in x are equivalent to contributions with zero weight.

Runtime Errors:

• #14011: If x has fewer than 2 components, a "too few components" error is raised.
• #14012: If x, mean, and covariance are arrays with unequal lengths, an "unequal length arrays" error is raised.

{"stat.sample.updateWindow": [x, w, state, windowSize]}
 x double w double state array of any record A with fields {x: double, w: double, count: double} windowSize int (returns) array of A

Description: Update the state of a counter, a counter and a mean, or a counter, mean, and variance, within a window of windowSize recent samples.

Parameters:

xSample value.
wSample weight; set to 1 for no weights.
stateArray of previous count, mean, and/or variance and samples in the window.
 x Sample value, saved so that it can be removed from the running mean and variance when it goes out of scope. w Sample weight, saved for the same reason. count The sum of weights w within the window. mean The mean of x within the window, weighted by w. This field is optional, but if provided, it must be a double. variance The variance of $$x - \mbox{mean}$$ within the window, weighted by w. This field is optional, but if it is provided, it must be a double, and there must be a mean as well. No attempt is made to unbias the estimator, so multiply this by $$\mbox{count}/(\mbox{count} - 1)$$ to correct for the bias due to centering on the mean.
windowSizeSize of the window. When the length of state is less than windowSize, this function is equivalent to stat.sample.update.

Returns:

 If the length of state is zero, this function returns a singleton array with count = w, mean = x, and/or variance = 0. If the length of state is less than windowSize, then it returns a copy of state with the next record added. Otherwise, it is trunctated to windowSize, removing the old values from the running count/mean/variance. In all cases, the a.last item is the latest result.

Runtime Errors:

• #14020: If windowSize is less than 2, a "windowSize must be at least 2" error is raised.
• #14021: If state is empty and the record type has fields other than x, w, count, mean, and variance, then a "cannot initialize unrecognized fields" error is raised. Unrecognized fields are only allowed if an initial record is provided.

{"stat.sample.updateEWMA": [x, alpha, state]}
 x double alpha double state any record A with fields {mean: double} (returns) A

Description: Update the state of an exponentially weighted moving average (EWMA).

Parameters:

xSample value.
alphaWeighting factor (usually a constant) between 0 and 1, inclusive. If alpha is close to 1, recent data are heavily weighted at the expense of old data; if alpha is close to 0, the EWMA approaches a simple mean.
stateRecord of the previous mean and variance.
 mean The exponentially weighted mean of x, weighted by alpha. variance The exponentially weighted variance of x, weighted by alpha. This field is optional, but if provided, it must be a double.

Returns:

 Returns a new record with updated mean and variance. If the input state has fields other than mean and variance, they are copied unaltered to the output state.

Runtime Errors:

• #14030: If alpha is less than 0 or greater than 1, an "alpha out of range" error is raised.

{"stat.sample.updateHoltWinters": [x, alpha, beta, state]}
 x double alpha double beta double state any record A with fields {level: double, trend: double} (returns) A

Description: Update the state of a time series analysis with an exponentially weighted linear fit.

Parameters:

xSample value.
alphaWeighting factor (usually a constant) between 0 and 1, inclusive, that governs the responsiveness of the level. If alpha is close to 1, recent data are heavily weighted at the expense of old data.
betaWeighting factor (usually a constant) between 0 and 1, inclusive, that governs the responsiveness of the trend. If beta is close to 1, recent data are heavily weighted at the expense of old data.
stateRecord of the previous level and trend.
 level The constant term in an exponentially weighted linear fit of recent data, weighted by alpha. trend The linear term in an exponentially weighted linear fit of recent data, weighted by beta.

Returns:

 Returns an updated version of the state.

Details:

• Use stat.sample.forecast1HoltWinters or stat.sample.forecastHoltWinters to make predictions from the state record.
• For $$a_t$$ = the level at a time $$t$$ and $$b_t$$ = the trend at a time $$t$$, $$a_t = \alpha x + (1 - \alpha)(a_{t-1} + b_{t-1})$$ and $$b_t = \beta (a_t - a_{t-1}) + (1 - \beta) b_{t-1}$$.

Runtime Errors:

• #14040: If alpha is less than 0 or greater than 1, an "alpha out of range" error is raised.
• #14041: If beta is less than 0 or greater than 1, an "beta out of range" error is raised.

{"stat.sample.updateHoltWintersPeriodic": [x, alpha, beta, gamma, state]}
 x double alpha double beta double gamma double state any record A with fields {level: double, trend: double, cycle: array of double, multiplicative: boolean} (returns) A

Description: Update the state of a time series analysis with an exponentially weighted periodic-plus-linear fit.

Parameters:

xSample value.
alphaWeighting factor (usually a constant) between 0 and 1, inclusive, that governs the responsiveness of the level. If alpha is close to 1, recent data are heavily weighted at the expense of old data.
betaWeighting factor (usually a constant) between 0 and 1, inclusive, that governs the responsiveness of the trend. If beta is close to 1, recent data are heavily weighted at the expense of old data.
gammaWeighting factor (usually a constant) between 0 and 1, inclusive, that governs the responsiveness of the cycle. If gamma is close to 1, recent data are heavily weighted at the expense of old data.
stateRecord of the previous level, trend, and cycle.
 level The constant term in an exponentially weighted linear fit of recent data, weighted by alpha. trend The linear term in an exponentially weighted linear fit of recent data, weighted by beta. cycle The history of the previous cycle, weighted by gamma. If the length of this array is $$L$$, then the built-in period is $$L$$ time steps long. multiplicative If true, interpret cycle as multiplicative; if false, interpret it as additive.

Returns:

 Returns an updated version of the state.

Details:

• Use stat.sample.forecast1HoltWinters or stat.sample.forecastHoltWinters to make predictions from the state record.
• For $$a_t$$ = the level at a time $$t$$, $$b_t$$ = the trend at a time $$t$$, and $$c_t$$ = the cycle at a time $$t$$ with period $$L$$, $$a_t = \alpha x_t / c_{t-L} + (1 - \alpha)(a_{t-1} + b_{t-1})$$, $$b_t = \beta (a_t - a_{t-1}) + (1 - \beta) b_{t-1}$$, and $$c_t = \gamma x_t / a_t + (1 - \gamma) c_{t-L}$$ for the multiplicative case and $$a_t = \alpha (x_t - c_{t-L}) + (1 - \alpha)(a_{t-1} + b_{t-1})$$, $$b_t = \beta (a_t - a_{t-1}) + (1 - \beta) b_{t-1}$$, and $$c_t = \gamma (x_t - a_t) + (1 - \gamma) c_{t-L}$$ for the additive case.
• In each call to this function, cycle is rotated left, such that the first item is $$c_t$$.

Runtime Errors:

• #14050: If alpha is less than 0 or greater than 1, an "alpha out of range" error is raised.
• #14051: If beta is less than 0 or greater than 1, an "beta out of range" error is raised.
• #14052: If gamma is less than 0 or greater than 1, an "gamma out of range" error is raised.
• #14053: If cycle is empty, an "empty cycle" error is raised.

{"stat.sample.forecast1HoltWinters": [state]}
 state any record A with fields {level: double, trend: double} (returns) double

Description: Forecast one time-step from a state record prepared by stat.state.updateHoltWinters or stat.state.updateHoltWintersPeriodic.

Parameters:

stateRecord of level, trend, and possibly cycle and multiplicative.
 level The constant term in an exponentially weighted linear fit of recent data. trend The linear term in an exponentially weighted linear fit of recent data. cycle The history of the previous cycle. This field is optional, but if provided, it must be an array of double and must be accompanied by multiplicative. multiplicative If true, interpret cycle as multiplicative; if false, interpret it as additive. This field is optional, but if provided, it must be a boolean and must be accompanied by cycle.

Returns:

 Returns a prediction of the next time-step.

Details:

• For $$a_t$$ = the level at a time $$t$$, $$b_t$$ = the trend at a time $$t$$, and $$c_t$$ = the cycle at a time $$t$$ with period $$L$$, this function returns $$a_t + b_t$$ (non-periodic), $$(a_t + b_t) c_{t+1}$$ (multiplicative), or $$a_t + b_t + c_{t+1}$$ (additive) for each $$i$$ from $$0$$ to $$n - 1$$

Runtime Errors:

• #14060: If cycle is empty, an "empty cycle" error is raised.

{"stat.sample.forecastHoltWinters": [n, state]}
 n int state any record A with fields {level: double, trend: double} (returns) array of double

Description: Forecast n time-steps from a state record prepared by stat.state.updateHoltWinters or stat.state.updateHoltWintersPeriodic.

Parameters:

stateRecord of level, trend, and possibly cycle and multiplicative.
 level The constant term in an exponentially weighted linear fit of recent data. trend The linear term in an exponentially weighted linear fit of recent data. cycle The history of the previous cycle. This field is optional, but if provided, it must be a double and must be accompanied by multiplicative. multiplicative If true, interpret cycle as multiplicative; if false, interpret it as additive. This field is optional, but if provided, it must be a boolean and must be accompanied by cycle.

Returns:

 Returns a series of predictions for the next n time-steps.

Details:

• For $$a_t$$ = the level at a time $$t$$, $$b_t$$ = the trend at a time $$t$$, and $$c_t$$ = the cycle at a time $$t$$ with period $$L$$, this function returns $$a_t + i b_t$$ (non-periodic), $$(a_t + i b_t) c_{(t + i) \mbox{mod} n}$$ (multiplicative), or $$a_t + i b_t + c_{(t + i) \mbox{mod} n}$$ (additive) for each $$i$$ from $$1$$ to $$n$$

Runtime Errors:

• #14070: If cycle is empty, an "empty cycle" error is raised.

{"stat.sample.fillHistogram": [x, w, histogram]}
 x double w double histogram any record A with fields {numbins: int, low: double, high: double, values: array of double} (returns) A
{"stat.sample.fillHistogram": [x, w, histogram]}
 x double w double histogram any record A with fields {low: double, binsize: double, values: array of double} (returns) A
{"stat.sample.fillHistogram": [x, w, histogram]}
 x double w double histogram any record A with fields {ranges: array of array of double, values: array of double} (returns) A

Description: Update a histogram by filling it with one value.

Parameters:

xSample value.
wSample weight; set to 1 for no weights.
histogramThe histogram prior to filling. It must have numbins, low, high, and values (fixed bins) xor it must have low, binsize, and values (number of equal-sized bins grows), xor it must have ranges and values (arbitrary interval bins). Only one set of required fields is allowed (semantic error otherwise), and the rest of the fields are optional.
 numbins The fixed number of bins in the histogram. low The low edge of the histogram range (inclusive). high The high edge of the histogram range (exclusive). binsize The size of a bin for a histogram whose number of bins and right edge grows with the data. ranges Pairs of values describing arbitrary interval bins. The first number of each pair is the inclusive left edge and the second number is the exclusive right edge. values Histogram contents, which are updated by this function. underflow If present, this double-valued field counts x values that are less than low or not contained in any ranges. overflow If present, this double-valued field counts x values that are greater than high. nanflow If present, this double-valued field counts x values that are nan. nan values would never enter values, underflow, or overflow. If present, this double-valued field counts x values that are infinite. Infinite values would only enter underflow or overflow if infflow is not present, so that they are not double-counted.

Returns:

 Returns an updated version of histogram: all fields are unchanged except for values, underflow, overflow, nanflow, and infflow.

Details:

• If the histogram is growable (described by low and binsize) and x minus low is greater than or equal to binsize times the length of values, the values will be padded with zeros to reach it.
• If the histogram is growable (described by low and binsize), only finite values can extend the size of the histogram: infinite values are entered into overflow or infflow, depending on whether infflow is present.
• If the histogram is described by ranges and an element of ranges contains two equal values, then x is considered in the interval if it is exactly equal to the value.
• If the histogram is described by ranges and x falls within multiple, overlapping intervals, then all matching counters are updated (values can be double-counted).

Runtime Errors:

• #14080: If the length of values is not equal to numbins or the length of ranges, then a "wrong histogram size" error is raised.
• #14081: If low is greater than or equal to high, then a "bad histogram range" error is raised.
• #14082: If numbins is less than 1 or binsize is less than or equal to 0, then a "bad histogram scale" error is raised.
• #14083: If ranges contains an array of doubles with length not equal to 2 or if the first element is greater than the second element, then a "bad histogram ranges" error is raised.

{"stat.sample.fillHistogram2d": [x, y, w, histogram]}
 x double y double w double histogram any record A with fields {xnumbins: int, xlow: double, xhigh: double, ynumbins: int, ylow: double, yhigh: double, values: array of array of double} (returns) A

Description: Update a two-dimensional histogram by filling it with one value.

Parameters:

xSample x value.
ySample y value.
wSample weight; set to 1 for no weights.
histogramThe histogram prior to filling.
 xnumbins The number of bins in the x dimension. xlow The low edge of the histogram range in the x dimension (inclusive). xhigh The high edge of the histogram range in the x dimension (exclusive). ynumbins The number of bins in the y dimension. ylow The low edge of the histogram range in the y dimension (inclusive). yhigh The high edge of the histogram range in the y dimension (exclusive). values Histogram contents, which are updated by this function. The outer array iterates over x and the inner array iterates over y. underunderflow If present, this double-valued field counts instances in which x is less than xlow and y is less than ylow. undermidflow If present, this double-valued field counts instances in which x is less than xlow and y between ylow (inclusive) and yhigh (exclusive). underoverflow If present, this double-valued field counts instances in which x is less than xlow and y is greater than or equal to yhigh. midunderflow If present, this double-valued field counts instances in which x is between xlow (inclusive) and xhigh (exclusive) and y is less than ylow. midoverflow If present, this double-valued field counts instances in which x is between xlow (inclusive) and xhigh (exclusive) and y is greater than or equal to yhigh. overunderflow If present, this double-valued field counts instances in which x is greater than or equal to xhigh and y is less than ylow. overmidflow If present, this double-valued field counts instances in which x is greater than or equal to xhigh and y between ylow (inclusive) and yhigh (exclusive). overoverflow If present, this double-valued field counts instances in which x is greater than or equal to xhigh and y is greater than or equal to yhigh. nanflow If present, this double-valued field counts instances in which x or y is nan. nan values would never enter any other counter. infflow If present, this double-valued field counts instances in which x or y is infinite. Infinite values would only enter the other under/mid/overflow counters if infflow were not present, so that they are not double-counted.

Returns:

 Returns an updated version of histogram: all fields are unchanged except for values and the under/mid/over/nan/infflow counters.

Details:

• If x is infinite and y is nan or x is nan and y is infinite, the entry is counted as nan, rather than infinite.

Runtime Errors:

• #14090: If the length of values is not equal to xnumbins or the length of any element of values is not equal to ynumbins, then a "wrong histogram size" error is raised.
• #14091: If xlow is greater than or equal to xhigh or if ylow is greater than or equal to yhigh, then a "bad histogram range" error is raised.
• #14092: If xnumbins is less than 1 or ynumbins is less than 1, then a "bad histogram scale" error is raised.

{"stat.sample.fillCounter": [x, w, counter]}
 x string w double counter any record A with fields {values: map of double} (returns) A

Description: Update a counter (sparse histogram) by filling it with one value.

Parameters:

xSample category.
wSample weight; set to 1 for no weights.
histogramThe counter prior to filling.
 values Number of instances seen of each category.

Returns:

 Returns the updated counter.

Details:

• If a category is not present in the initial values, it is added with initial value zero prior to filling.

{"stat.sample.topN": [x, top, n, lessThan]}
 x any A top array of A n int lessThan function of (A, A) → boolean (returns) array of A

Description: Update an array of the top n sorted items by potentially adding x to that array, using lessThan as a comparison function.

Parameters:

 x Sample value. top Array of items to which x might be added. This array is assumed to be sorted according to lessThan. n Maximum number of items to keep. lessThan Comparison function; should return true if its first argument is less than its second argument, false otherwise.

Returns:

 Returns an updated version of top. If x is among the top n values seen, then it is included in the output. Otherwise, the output is top.

Details:

• The x value is inserted after the first element of top that it is greater than or equal to (lessThan applied to that array element and x returns true) and the result is truncated to size n. Thus, the result only represents a top-n list if top is already sorted and equal elements already in the array get precedence.
• The top array is unchanged by this function because all values in PFA are immutable. The updated array is the return value.

## stat.change

{"stat.change.updateTrigger": [predicate, history]}
 predicate boolean history any record A with fields {numEvents: int, numRuns: int, currentRun: int, longestRun: int} (returns) A

Description: Update the state of a trigger that counts the number of times predicate is satisfied (true), as well as the number and lengths of runs of true.

Parameters:

predicateExpression that evaluates to true or false.
historySummary of previous results of the predicate.
 numEvents The number of times predicate evaluated to true. numRuns The number of contiguous intervals in which predicate was true, including the current one. currentRun If predicate is false, currentRun is 0. Otherwise, currentRun is incremented (greater than or equal to 1 if predicate evaluated to true). longestRun The longest run observed so far; may be equal to currentRun.

Returns:

 Returns a new record with updated fields: numEvents is always incremented; numRuns is incremented if predicate is true and currentRun is zero; currentRun is incremented if predicate is true and set to zero if predicate is false; longestRun is set to currentRun if predicate is true and currentRun is longer than longestRun. If the input history has fields other than numEvents, numRuns, currentRun, or longestRun, they are copied unaltered to the output.

Runtime Errors:

• #37000: If any of numEvents, numRuns, currentRun, and longestRun are less than 0, a "counter out of range" error is raised.

{"stat.change.zValue": [x, meanVariance]}
 x double meanVariance any record A with fields {mean: double, variance: double} (returns) double
{"stat.change.zValue": [x, meanVariance, unbiased]}
 x double meanVariance any record A with fields {count: double, mean: double, variance: double} unbiased boolean (returns) double

Description: Calculate the z-value between x and a normal distribution with a given mean and variance.

Parameters:

 x Value to test. meanVariance A record with mean, variance, and possibly count, such as the output of stat.sample.Update. unbiased If true, use count to correct for the bias due to the fact that a variance centered on the mean has one fewer degrees of freedom than the dataset that it was sampled from (Bessel's correction).

Returns:

 If unbiased is false, $$(x - mean)/\sqrt{variance}$$; otherwise $$(x - mean)(1/\sqrt{variance})\sqrt{count/(count - 1)}$$.

{"stat.change.updateCUSUM": [logLikelihoodRatio, last, reset]}
 logLikelihoodRatio double last double reset double (returns) double

Description: Update a cumulative sum (CUSUM) to detect the transition of a dataset from one distribution to another.

Parameters:

 logLikelihoodRatio The logarithm of the ratio of the likelihood of a value for the alterate and baseline distributions: $$\ln(\mbox{alt}_{L}/\mbox{base}_{L})$$, which is $$\mbox{alt}_{LL} - \mbox{base}_{LL}$$ where $$L$$ is likelihood and $$LL$$ is log-likelihood. Consider using something like {"-": [{"prob.dist.gaussianLL": [...]}, {"prob.dist.gaussianLL": [...]}]}. last The previous return value from this function. reset A low value (usually consistent with the baseline hypothesis, such as 0) at which the cumulative sum resets, rather than accumulate very low values and become insensitive to future changes.

Returns:

 An incremented cumulative sum. The output is $$\max\{logLikelihoodRatio + last, reset\}$$.

## model.reg

{"model.reg.linear": [datum, model]}
 datum array of double model any record M with fields {coeff: array of double, const: double} (returns) double
{"model.reg.linear": [datum, model]}
 datum array of double model any record M with fields {coeff: array of array of double, const: array of double} (returns) array of double
{"model.reg.linear": [datum, model]}
 datum map of double model any record M with fields {coeff: map of double, const: double} (returns) double
{"model.reg.linear": [datum, model]}
 datum map of double model any record M with fields {coeff: map of map of double, const: map of double} (returns) map of double

Description: Apply matrix model to independent variables datum to predict the dependent, predicted variables.

Parameters:

datumVector of independent variables with $$d$$ dimensions.
modelParameters of the linear model.
 coeff Vector or matrix of coefficients that multiply the input variables, which has $$p$$ rows and $$d$$ columns. const Scalar or vector of constant offsets, which has $$p$$ dimensions.

Returns:

 Returns a $$p$$ dimensional vector of dependent, predicted variables.

Details:

• The vectors and matrix may be expressed as arrays (indexed by integers) or maps (indexed by strings). In the array signature, the number of rows and/or columns in x must be equal to the number of rows and/or columns of y, respectively (dense matrix). In the map signature, missing row-column combinations are assumed to be zero (sparse matrix).
• The simpler signature is may be used in the $$p = 1$$case.

Runtime Errors:

• #31000: The array signature raises a "misaligned coeff" error if any row of coeff does not have the same indexes as datum.
• #31001: The array signature raises a "misaligned const" error if const does not have the same indexes as coeff.

{"model.reg.linearVariance": [datum, model]}
 datum array of double model any record M with fields {covar: array of array of double} (returns) double
{"model.reg.linearVariance": [datum, model]}
 datum array of double model any record M with fields {covar: array of array of array of double} (returns) array of double
{"model.reg.linearVariance": [datum, model]}
 datum map of double model any record M with fields {covar: map of map of double} (returns) double
{"model.reg.linearVariance": [datum, model]}
 datum map of double model any record M with fields {covar: map of map of map of double} (returns) map of double

Description: Propagate variances from model covar (covariance matrix) to the dependent, predicted variable(s).

Parameters:

datumVector of independent variables $$\vec{o}$$ with $$d$$ dimensions.
modelParameters of the linear model.
 covar Covariance matrix $$C$$ or array/map of covariance matrices, one for each dependent, predicted variable. Each matrix has $$d + 1$$ rows and $$d + 1$$ columns: the last (array) or empty string (map) row and column corresponds to the model's constant term. If there are $$p$$ dependent, predicted variables, the outermost array/map has $$p$$ items.

Returns:

 Propagated variance(s) $$\vec{o}^T C \vec{o}$$ for each dependent, predicted variable.

Details:

• The "error" or "uncertainty" in the predicted variable(s) is the square root of this value/these values.
• The vectors and matrix may be expressed as arrays (indexed by integers) or maps (indexed by strings). In the array signature, the number of rows and/or columns in x must be equal to the number of rows and/or columns of y, respectively (dense matrix). In the map signature, missing row-column combinations are assumed to be zero (sparse matrix).

Runtime Errors:

• #31010: The array signature raises a "misaligned covariance" error if any covariance matrix does not have the same indexes as datum plus the implicit index for a constant (last in array signature).

{"model.reg.gaussianProcess": [x, table, krigingWeight, kernel]}
 x double table array of any record R with fields {x: double, to: double} krigingWeight union of {null, double} kernel function of (array of double, array of double) → double (returns) double
{"model.reg.gaussianProcess": [x, table, krigingWeight, kernel]}
 x double table array of any record R with fields {x: double, to: array of double} krigingWeight union of {null, double} kernel function of (array of double, array of double) → double (returns) array of double
{"model.reg.gaussianProcess": [x, table, krigingWeight, kernel]}
 x array of double table array of any record R with fields {x: array of double, to: double} krigingWeight union of {null, double} kernel function of (array of double, array of double) → double (returns) double
{"model.reg.gaussianProcess": [x, table, krigingWeight, kernel]}
 x array of double table array of any record R with fields {x: array of double, to: array of double} krigingWeight union of {null, double} kernel function of (array of double, array of double) → double (returns) array of double

Description: Fit the training data in table with a Gaussian Process model and predict the value of model at x.

Parameters:

xPosition (scalar or vector) at which to predict the value of the model.
tableTraining data for the Gaussian Process.
 x Independent variable (scalar or vector, but same as x) of a training datum. to Dependent variable (scalar or vector) of a training datum. sigma Optional uncertainty for the datum. If present, it must have the same type as to and is used in the Gaussian Process fit as a nugget.
krigingWeightIf a number, the Gaussian Process is performed with the specified Kriging weight. If null, universal Kriging is performed.
kernelA function to use as a kernel. For instance, m.kernel.rbf (radial basis function) with partially applied gamma is a squared exponential kernel.

Returns:

 Returns a scalar or vector prediction with the same type as to.

Details:

• Nondeterministic: unstable. This function gives the same results every time it is executed, but those results may not be exactly the same on all systems.

Runtime Errors:

• #31080: If table is empty, a "table must have at least 1 entry" error is raised.
• #31081: If x is an empty array, an "x must have at least 1 feature" error is raised.
• #31082: If any x in the table has a different length than the input parameter x, a "table must have the same number of features as x" error is raised.
• #31083: If any to in the table is an empty array, a "table outputs must have at least 1 dimension" error is raised.
• #31084: If the to fields in table do not all have the same dimensions, a "table outputs must all have the same number of dimensions" error is raised.
• #31085: If x or a component of x is not finite, an "x is not finite" error is raised.
• #31086: If any value in the table is not finite, a "table value is not finite" error is raised.
• #31087: If krigingWeight is a number but is not finite, a "krigingWeight is not finite" error is raised.
• #31088: If evaluating kernel on all combinations of table x (with $$1 + (\mbox{sigma}/\mbox{to})^2$$ on the diagonal) yields a non-positive definite matrix, a "matrix of kernel results is not positive definite" error is raised.

{"model.reg.residual": [observation, prediciton]}
 observation double prediciton double (returns) double
Deprecated; exists until PFA 0.9.0: use stat.test.residual instead.
{"model.reg.residual": [observation, prediciton]}
 observation array of double prediciton array of double (returns) array of double
Deprecated; exists until PFA 0.9.0: use stat.test.residual instead.
{"model.reg.residual": [observation, prediciton]}
 observation map of double prediciton map of double (returns) map of double
Deprecated; exists until PFA 0.9.0: use stat.test.residual instead.

Description: Compare an observation with its prediction by element-wise subtraction.

Parameters:

 observation Scalar or vector of observations. prediction Scalar or vector of predictions.

Returns:

 Scalar or vector of observation minus prediction.

Runtime Errors:

• #31020: Raises a "misaligned prediction" error if prediction does not have the same indexes as observation.

{"model.reg.pull": [observation, prediciton, uncertainty]}
 observation double prediciton double uncertainty double (returns) double
Deprecated; exists until PFA 0.9.0: use stat.test.pull instead.
{"model.reg.pull": [observation, prediciton, uncertainty]}
 observation array of double prediciton array of double uncertainty array of double (returns) array of double
Deprecated; exists until PFA 0.9.0: use stat.test.pull instead.
{"model.reg.pull": [observation, prediciton, uncertainty]}
 observation map of double prediciton map of double uncertainty map of double (returns) map of double
Deprecated; exists until PFA 0.9.0: use stat.test.pull instead.

Description: Compare an observation with its prediction by element-wise subtraction, weighted by element-wise uncertainties.

Parameters:

 observation Scalar or vector of observations. prediction Scalar or vector of predictions. uncertainty Scalar or vector of predictions.

Returns:

 Scalar or vector of observation minus prediction divided by uncertainty.

Runtime Errors:

• #31030: Raises a "misaligned prediction" error if prediction does not have the same indexes as observation.
• #31031: Raises a "misaligned uncertainty" error if prediction does not have the same indexes as uncertainty.

{"model.reg.mahalanobis": [observation, prediction, covariance]}
 observation array of double prediction array of double covariance array of array of double (returns) double
Deprecated; exists until PFA 0.9.0: use stat.test.mahalanobis instead.
{"model.reg.mahalanobis": [observation, prediction, covariance]}
 observation map of double prediction map of double covariance map of map of double (returns) double
Deprecated; exists until PFA 0.9.0: use stat.test.mahalanobis instead.

Description: Compare an observation with its prediction by computing the Mahalanobis distance for a given covariance matrix.

Parameters:

 observation Vector of observations $$\vec{o}$$. prediction Vector of predictions $$\vec{p}$$. covariance Matrix of covariance $$C$$.

Returns:

 Scalar result of a similarity transformation: $$\sqrt{(\vec{o} - \vec{p})^T C^{-1} (\vec{o} - \vec{p})}$$.

Runtime Errors:

• #31040: Raises a "too few rows/cols" error if observation has fewer than one element.
• #31041: Raises a "misaligned prediction" error if prediction does not have the same indexes as observation.
• #31042: Raises a "misaligned covariance" error if covariance does not have the same indexes as observation.

{"model.reg.updateChi2": [pull, state]}
 pull double state any record A with fields {chi2: double, DOF: int} (returns) A
Deprecated; exists until PFA 0.9.0: use stat.test.updateChi2 instead.
{"model.reg.updateChi2": [pull, state]}
 pull array of double state any record A with fields {chi2: double, DOF: int} (returns) A
Deprecated; exists until PFA 0.9.0: use stat.test.updateChi2 instead.
{"model.reg.updateChi2": [pull, state]}
 pull map of double state any record A with fields {chi2: double, DOF: int} (returns) A
Deprecated; exists until PFA 0.9.0: use stat.test.updateChi2 instead.

Description: Update the state of a chi-square calculation.

Parameters:

 pull Observation minus prediction divided by uncertainty. If this is a scalar, it will be squared and added to the chi-square. If a vector, each component will be squared and added to the chi-square. state Record of the previous chi2 and DOF.

{"model.reg.reducedChi2": [state]}
 state any record A with fields {chi2: double, DOF: int} (returns) double
Deprecated; exists until PFA 0.9.0: use stat.test.reducedChi2 instead.

Description: Return the reduced chi-square, which is chi2/DOF.

Parameters:

 state Record of the chi2 and DOF.

{"model.reg.chi2Prob": [state]}
 state any record A with fields {chi2: double, DOF: int} (returns) double
Deprecated; exists until PFA 0.9.0: use stat.test.chi2Prob instead.

Description: Return the chi-square probability, which is the CDF of the chi-square function.

Parameters:

 state Record of the chi2 and DOF.

Runtime Errors:

• #31070: Raises "invalid parameterization" if DOF is less than zero.

## model.tree

{"model.tree.simpleTest": [datum, comparison]}
 datum any record D comparison any record T with fields {field: enum F of fields of D, operator: string, value: any V} (returns) boolean

Description: Determine if datum passes a test defined by comparison.

Parameters:

datumSample value to test.
comparisonRecord that describes a test.
 field Field name from datum: the enumeration type must include all fields of D in their declaration order. operator One of the following: "==" (equal), "!=" (not equal), "<" (less than), "<=" (less or equal), ">" (greater than), ">=" (greater or equal), "in" (member of a set), "notIn" (not a member of a set), "alwaysTrue" (ignore value, return true), "alwaysFalse" (ignore value, return false), "isMissing" (ignore value, return true iff the field of datum is null), and "notMissing" (ignore value, return false iff the field of datum is null). value Value to which the field of datum is compared.

Returns:

 Returns true if the field of datum value is true, false otherwise, where is the operator.

Runtime Errors:

• #32000: Raises an "invalid comparison operator" if operator is not one of "==", "!=", "<", "<=", ">", ">=", "in", "notIn", "alwaysTrue", "alwaysFalse", "isMissing", "notMissing".
• #32001: Raises a "bad value type" if the field of datum and V are not both numbers and the field cannot be upcast to V.

{"model.tree.missingTest": [datum, comparison]}
 datum any record D comparison any record T with fields {field: enum F of fields of D, operator: string, value: any V} (returns) union of {null, boolean}

Description: Determine if datum passes a test defined by comparison, allowing for missing values.

Parameters:

datumSample value to test.
comparisonRecord that describes a test.
 field Field name from datum: the enumeration type must include all fields of D in their declaration order. operator One of the following: "==" (equal), "!=" (not equal), "<" (less than), "<=" (less or equal), ">" (greater than), ">=" (greater or equal), "in" (member of a set), "notIn" (not a member of a set), "alwaysTrue" (ignore value, return true), "alwaysFalse" (ignore value, return false). value Value to which the field of datum is compared.

Returns:

 If the field of datum is null, this function returns null (unknown test result). Otherwise, it returns datum field value, where is the operator

Runtime Errors:

• #32010: Raises an "invalid comparison operator" if operator is not one of "==", "!=", "<", "<=", ">", ">=", "in", "notIn", "alwaysTrue", "alwaysFalse".
• #32011: Raises a "bad value type" if the field of datum and V are not both numbers and the field cannot be upcast to V.

{"model.tree.compoundTest": [datum, operator, comparisons, test]}
 datum any record D operator string comparisons array of any record T test function of (D, T) → boolean (returns) boolean

Description: Apply test to an array of comparisons, returning their logical and, or, or xor, depending on operator.

Parameters:

 datum Simple value to test. operator If "and", return true if no false is encountered, if "or", return true if any true is encountered, and if "xor", return true if an odd number of true is encountered among the comparisons. comparisons Array of records that describe the tests. test Test function applied to each item of comparisons until the result is certain.

Returns:

 Logical combination of comparisons.

Details:

• If operator is "and", the test will only be applied until the first false is encountered. If operator is "or", the test will only be applied until the first true is encountered. If operator is "xor", the test will be applied to all items of comparisons.

Runtime Errors:

• #32020: If operator is not "and", "or", or "xor", an "unrecognized logical operator" error is raised.

{"model.tree.surrogateTest": [datum, comparisons, missingTest]}
 datum any record D comparisons array of any record T missingTest function of (D, T) → union of {null, boolean} (returns) boolean

Description: Apply missingTest to an array of comparisons until one yields a non-null result.

Parameters:

 datum Sample value to test. comparisons Array of records that describe the tests. missingTest Test function applied to each item of comparisons until one returns a non-null result.

Returns:

 Returns the value of the first test that returns true or false.

Runtime Errors:

• #32030: If all tests return null, this function raises a "no successful surrogate" error.

{"model.tree.simpleWalk": [datum, treeNode, test]}
 datum any record D treeNode any record T with fields {pass: union of {T, any S}, fail: union of {T, S}} test function of (D, T) → boolean (returns) S

Description: Descend through a tree, testing the fields of datum with the test function using treeNode to define the comparison, continuing to pass or fail until reaching a leaf node of type S (score).

Parameters:

datumSample value to test.
treeNodeNode of the tree, which contains a predicate to be interpreted by test.
 pass Branch to follow if test returns true. fail Branch to follow if test returns false.
testTest function that converts datum and treeNode into true or false.

Returns:

 Leaf node of type S, which must be different from the tree nodes. For a classification tree, S could be a string or an enumeration set. For a regression tree, S would be a numerical type. For a multivariate regression tree, S would be an array of numbers, etc.

{"model.tree.missingWalk": [datum, treeNode, test]}
 datum any record D treeNode any record T with fields {pass: union of {T, any S}, fail: union of {T, S}, missing: union of {T, S}} test function of (D, T) → union of {null, boolean} (returns) S

Description: Descend through a tree, testing the fields of datum with the test function using treeNode to define the comparison, continuing to pass, fail, or missing until reaching a leaf node of type S (score).

Parameters:

datumSample value to test.
treeNodeNode of the tree, which contains a predicate to be interpreted by test.
 pass Branch to follow if test returns true. fail Branch to follow if test returns false. missing Branch to follow if test returns null.
testTest function that converts datum and treeNode into true, false, or null.

Returns:

 Leaf node of type S, which must be different from the tree nodes. For a classification tree, S could be a string or an enumeration set. For a regression tree, S would be a numerical type. For a multivariate regression tree, S would be an array of numbers, etc.

{"model.tree.simpleTree": [datum, treeNode]}
 datum any record D treeNode any record T with fields {field: enum F of fields of D, operator: string, value: any V, pass: union of {T, any S}, fail: union of {T, S}} (returns) S

Description: Descend through a tree, testing datum with field, operator, value, following pass or fail until reaching a leaf node of type S (score).

Parameters:

datumSample value to test.
treeNodeRecord that describes a tree node (predicate test with branches).
 field Field name from datum: the enumeration type must include all fields of D in their declaration order. operator One of the following: "==" (equal), "!=" (not equal), "<" (less than), "<=" (less or equal), ">" (greater than), ">=" (greater or equal), "in" (member of a set), "notIn" (not a member of a set), "alwaysTrue" (ignore value, return true), "alwaysFalse" (ignore value, return false), "isMissing" (ignore value, return true iff the field of datum is null), and "notMissing" (ignore value, return false iff the field of datum is null). value Value to which the field of datum is compared. pass Branch to follow if the comparison is successful. fail Branch to follow if the comparison fails.

Returns:

 Leaf node of type S, which must be different from the tree nodes. For a classification tree, S could be a string or an enumeration set. For a regression tree, S would be a numerical type. For a multivariate regression tree, S would be an array of numbers, etc.

Details:

• This is a convenience function, a combination of model.tree.simpleWalk with model.tree.simpleTest.

Runtime Errors:

• #32060: Raises an "invalid comparison operator" if operator is not one of "==", "!=", "<", "<=", ">", ">=", "in", "notIn", "alwaysTrue", "alwaysFalse", "isMissing", "notMissing".
• #32061: Raises a "bad value type" if the field of datum and V are not both numbers and the field cannot be upcast to V.

## model.cluster

{"model.cluster.closest": [datum, clusters]}
 datum array of double clusters array of any record C with fields {center: array of double} (returns) C
{"model.cluster.closest": [datum, clusters, metric]}
 datum any A clusters array of any record C with fields {center: any B} metric function of (A, B) → double (returns) C

Description: Find the cluster C whose center is closest to the datum, according to the metric.

Parameters:

 datum Sample datum. clusters Set of clusters; the record type C may contain additional identifying information for post-processing. metric Function used to compare each datum with the center of the clusters. (See, for example, metric.euclidean.)

Returns:

 Returns the closest cluster record.

Details:

• If metric is not provided, a Euclidean metric over floating point numbers is assumed.

Runtime Errors:

• #29000: Raises a "no clusters" error if clusters is empty.

{"model.cluster.closestN": [n, datum, clusters]}
 n int datum array of double clusters array of any record C with fields {center: array of double} (returns) array of C
{"model.cluster.closestN": [n, datum, clusters, metric]}
 n int datum any A clusters array of any record C with fields {center: any B} metric function of (A, B) → double (returns) array of C

Description: Find the n clusters C whose centers are closest to the datum, according to the metric.

Parameters:

 n Number of clusters to search for. datum Sample datum. clusters Set of clusters; the record type C may contain additional identifying information for post-processing. metric Function used to compare each datum with the center of the clusters. (See, for example, metric.euclidean.)

Returns:

 An array of the closest cluster records in order from the closest to the farthest. The length of the array is minimum of n and the length of clusters.

Details:

• If metric is not provided, a Euclidean metric over floating point numbers is assumed.

Runtime Errors:

• #29010: If n is negative, an "n must be nonnegative" error will be raised.

{"model.cluster.randomSeeds": [data, k, newCluster]}
 data array of array of any A k int newCluster function of (int, array of A) → any record C with fields {center: array of any B} (returns) array of C

Description: Call newCluster to create k cluster records with random, unique cluster centers drawn from data.

Parameters:

 data Sample data. k Number of times to call newCluster. newCluster Function that creates a cluster record, given an index (ranges from zero up to but not including k) and a random vector from data.

Returns:

 The cluster records created by newCluster.

Details:

• Nondeterministic: pseudorandom. This function intentionally gives different results every time it is executed.

Runtime Errors:

• #29020: Raises a "k must be greater than zero" error if k is less than or equal to zero.
• #29021: Raises a "not enough unique points" error if data has fewer than k unique elements.
• #29022: Raises a "dimensions of vectors do not match" error if the elements of data are not all the same size.

{"model.cluster.kmeansIteration": [data, clusters, metric, update]}
 data array of array of any A clusters array of any record C with fields {center: array of any B} metric function of (array of A, array of B) → double update function of (array of array of A, C) → C (returns) array of C

Description: Update a cluster set by applying one iteration of k-means (Lloyd's algorithm).

Parameters:

 data Sample data. clusters Set of clusters; the record type C may contain additional identifying information for post-processing. metric Function used to compare each datum with the center of the clusters. (See, for example, metric.euclidean.) update Function of matched data and old cluster records that yields new cluster records. (See, for example, model.cluster.updateMean with weight = 0.)

Returns:

 Returns a new cluster set with each of the centers located at the average of all points that match the corresponding cluster in the old cluster set.

Details:

• The update function is only called if the number of matched data points is greater than zero.

Runtime Errors:

• #29030: Raises a "no data" error if data is empty.
• #29031: Raises a "no clusters" error if clusters is empty.

{"model.cluster.updateMean": [data, cluster, weight]}
 data array of array of double cluster any record C with fields {center: array of double} weight double (returns) C

Description: Update a cluster record by computing the mean of the data vectors and weight times the old cluster center.

Details:

• If weight is zero, the new center is equal to the mean of data, ignoring the old center.

Runtime Errors:

• #29040: Raises a "no data" error if data is empty.
• #29041: Raises a "dimensions of vectors do not match" error if all elements of data and the cluster center do not match.

## model.neighbor

{"model.neighbor.mean": [points]}
 points array of array of double (returns) array of double
{"model.neighbor.mean": [points, weight]}
 points array of array of double weight function of (array of double) → double (returns) array of double

Description: Return the vector-wise mean of points, possibly weighted by weight.

Parameters:

 points Points from a codebook, for instance from model.neighbor.nearestK. weight Optional weighting function from each element of points to a value. If these values do not add up to 1.0, they will be internally normalized.

Returns:

 The vector-wise mean, which is by construction within the convex hull of the points.

Runtime Errors:

• #30000: If points is empty, a "not enough points" error will be raised.
• #30001: If the points have different sizes, an "inconsistent dimensionality" error will be raised.

{"model.neighbor.nearestK": [k, datum, codebook]}
 k int datum array of double codebook array of array of double (returns) array of array of double
{"model.neighbor.nearestK": [k, datum, codebook, metric]}
 k int datum any A codebook array of any B metric function of (A, B) → double (returns) array of B

Description: Find the k items in the codebook that are closest to the datum, according to the metric.

Parameters:

 k Number of codebook points to attempt to return. datum Sample datum. codebook Set of training data that is compared to the datum. metric Function used to compare each datum to each element of the codebook. (See, for example, metric.euclidean.)

Returns:

 An array of the closest codebook elements in any order. The length of the array is minimum of k and the length of codebook.

Runtime Errors:

• #30010: If k is negative, an "k must be nonnegative" error will be raised.
• #30011: If arrays in the codebook or the codebook and the datum have different sizes (without a metric), an "inconsistent dimensionality" error will be raised.

{"model.neighbor.ballR": [r, datum, codebook]}
 r double datum array of double codebook array of array of double (returns) array of array of double
{"model.neighbor.ballR": [r, datum, codebook, metric]}
 r double datum any A codebook array of any B metric function of (A, B) → double (returns) array of B

Description: Find the items in codebook that are within r of the datum, according to the metric.

Parameters:

 r Maximum distance (exclusive) of points to return. datum Sample datum. codebook Set of training data that is compared to the datum. metric Function used to compare each datum to each element of the codebook. (See, for example, metric.euclidean.)

Returns:

 An array of the codebook elements within a distance r in any order. The length of the array could be as low as zero or as high as the length of codebook.

## model.naive

{"model.naive.gaussian": [datum, classModel]}
 datum array of double classModel array of any record A with fields {mean: double, variance: double} (returns) double
{"model.naive.gaussian": [datum, classModel]}
 datum map of double classModel map of any record A with fields {mean: double, variance: double} (returns) double

Description: Score datum using a Gaussian Naive Bayes model.

Parameters:

 datum Vector of independent variables with $$d$$ dimensions. classModel Array or map of $$d$$ records, each containing the mean and variance of each of independent variable, for one class.

Returns:

 Returns the unscaled log-likelihood that datum is a member of the class specified by classModel.

Details:

• datum or classModel may be expressed as arrays (indexed by integers), or maps (indexed by strings).

Runtime Errors:

• #10000: Raises a "datum and classModel misaligned" error if datum and classModel have different lengths, of if their keys if using the map signature don't match one to one.
• #10001: Raises a "variance less than or equal to zero" error if a variance inside of classModel is incorrectly specified.

{"model.naive.multinomial": [datum, classModel]}
 datum array of double classModel array of double (returns) double
{"model.naive.multinomial": [datum, classModel]}
 datum map of double classModel map of double (returns) double
{"model.naive.multinomial": [datum, classModel]}
 datum array of double classModel any record C with fields {values: array of double} (returns) double
{"model.naive.multinomial": [datum, classModel]}
 datum map of double classModel any record C with fields {values: map of double} (returns) double

Description: Score datum using a Multinomial Naive Bayes model.

Parameters:

 datum Vector of independent variables with $$d$$ dimensions. classModel Array or map of multinomial ($$d$$ different) likelihoods of each independent variable for this class. The record form is for histograms built by stat.sample.fillHistogram or stat.sample.fillCounter.

Returns:

 Returns the unscaled log-likelihood of datum for this class.

Details:

• datum or classModel may be expressed as arrays (indexed by integers), or maps (indexed by strings).

Runtime Errors:

• #10010: Raises a "datum and classModel misaligned" error if when using the map signature the keys of datum and classModel don't match one to one, of if when using the array signature they are different lengths.
• #10011: Raises a "classModel must be non-empty and strictly positive" error if classModel is empty or any items are less than or equal to zero.

{"model.naive.bernoulli": [datum, classModel]}
 datum array of string classModel map of double (returns) double
{"model.naive.bernoulli": [datum, classModel]}
 datum array of string classModel any record C with fields {values: map of double} (returns) double

Description: Score datum using a Bernoulli Naive Bayes model.

Parameters:

 datum Vector of independent variables with $$d$$ dimensions. The record form is for histograms built by stat.sample.fillCounter. classModel Array or map of $$d$$ likelihoods of the presence of each independent variable for this class.

Returns:

 Returns the unscaled log-likelihood of datum for this class.

Runtime Errors:

• #10020: Raises a "probability in classModel must be strictly between 0 and 1" error if a value in classModel is not strictly between zero and one.

## model.neural

{"model.neural.simpleLayers": [datum, model, activation]}
 datum array of double model array of any record M with fields {weights: array of array of double, bias: array of double} activation function of (double) → double (returns) array of double

Description: Apply a feedforward artificial neural network model to an input datum.

Parameters:

 datum Length d vector of independent variables. model Array containing the parameters of each layer of the feedforward neural network model. activation Function applied at the output of each node, except the last. Usually an "S"-shaped sigmoid or hyperbolic tangent.

Returns:

 Returns an array of network outputs. For a neural network with a single neuron in the last layer (single output), this is an array of length one.

Runtime Errors:

• #11000: Raises a "no layers" error if the length of model is zero.
• #11001: Raises a "weights, bias, or datum misaligned" error if there is any misalignment between inputs and outputs through the layers of the network.

## model.svm

{"model.svm.score": [datum, model, kernel]}
 datum array of double model any record L with fields {const: double, posClass: array of any record M with fields {supVec: array of double, coeff: double}, negClass: array of any record N with fields {supVec: array of double, coeff: double}} kernel function of (array of double, array of double) → double (returns) double

Description: Score an input datum with a two-class support vector machine classifier given a model and a kernel function kernel.

Parameters:

 datum Length d vector of independent variables. model Record containing the support vectors, dual space coefficients and constant needed to score new data. kernel Kernel function used to map data and support vectors into the dual space.

Returns:

 Returns the score. If positive, datum classified as same group as posClass support vectors. If negative, datum classified as same group as negClass support vectors.

Runtime Errors:

• #12000: Raises a "no support vectors" error if the length of negClass and length of posClass is zero.
• #12001: Raises a "support vectors must have same length as datum" error if the length of the support vectors is not the same as the length of datum.