Function library

core

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

Description: Add 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:

  • #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]}
xany A of {int, long, float, double}
yA
(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]}
xany A of {int, long, float, double}
yA
(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]}
xdouble
ydouble
(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]}
xany A of {int, long}
yA
(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]}
xany 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]}
kany A of {int, long, float, double}
nA
(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]}
kany A of {int, long, float, double}
nA
(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]}
xany A of {int, long, float, double}
yA
(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]}
xany A
yA
(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]}
xany A
yA
(returns)boolean

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

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

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

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

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

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

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

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

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

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

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

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

Description: Return x if xy, y otherwise.

Details:

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

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

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

Details:

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

{"&&": [x, y]}
xboolean
yboolean
(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]}
xboolean
yboolean
(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]}
xboolean
yboolean
(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]}
xboolean
(returns)boolean

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

{"&&&": [x, y]}
xunion of {boolean, null}
yunion 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]}
xunion of {boolean, null}
yunion 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]}
xunion 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]}
xint
yint
(returns)int
{"&": [x, y]}
xlong
ylong
(returns)long

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

{"|": [x, y]}
xint
yint
(returns)int
{"|": [x, y]}
xlong
ylong
(returns)long

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

{"^": [x, y]}
xint
yint
(returns)int
{"^": [x, y]}
xlong
ylong
(returns)long

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

{"~": [x]}
xint
(returns)int
{"~": [x]}
xlong
(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]}
xany 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]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
ydouble
xdouble
(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]}
xdouble
(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]}
magany A of {int, long, float, double}
signA
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
ydouble
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
baseint
(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]}
xdouble
(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]}
xfloat
(returns)int
{"m.round": [x]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
xdouble
(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]}
nint
kint
(returns)int

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

Parameters:

nTotal number of elements.
kNumer 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]}
adouble
bdouble
(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]}
xdouble
(returns)double

Description: Return the error function of x.

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

Description: Return the complimentary error function of x.

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

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

{"m.link.softmax": [x]}
xarray of double
(returns)array of double
{"m.link.softmax": [x]}
xmap 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.

{"m.link.logit": [x]}
xdouble
(returns)double
{"m.link.logit": [x]}
xarray of double
(returns)array of double
{"m.link.logit": [x]}
xmap 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))\).

{"m.link.probit": [x]}
xdouble
(returns)double
{"m.link.probit": [x]}
xarray of double
(returns)array of double
{"m.link.probit": [x]}
xmap 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\).

{"m.link.cloglog": [x]}
xdouble
(returns)double
{"m.link.cloglog": [x]}
xarray of double
(returns)array of double
{"m.link.cloglog": [x]}
xmap 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))\).

{"m.link.loglog": [x]}
xdouble
(returns)double
{"m.link.loglog": [x]}
xarray of double
(returns)array of double
{"m.link.loglog": [x]}
xmap 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))\).

{"m.link.cauchit": [x]}
xdouble
(returns)double
{"m.link.cauchit": [x]}
xarray of double
(returns)array of double
{"m.link.cauchit": [x]}
xmap 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)\).

{"m.link.softplus": [x]}
xdouble
(returns)double
{"m.link.softplus": [x]}
xarray of double
(returns)array of double
{"m.link.softplus": [x]}
xmap 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))\).

{"m.link.relu": [x]}
xdouble
(returns)double
{"m.link.relu": [x]}
xarray of double
(returns)array of double
{"m.link.relu": [x]}
xmap 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))\).

{"m.link.tanh": [x]}
xdouble
(returns)double
{"m.link.tanh": [x]}
xarray of double
(returns)array of double
{"m.link.tanh": [x]}
xmap 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]}
xarray of double
yarray of double
(returns)double

Description: Linear kernel function.

Parameters:

xLength n vector.
yLength 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]}
xarray of double
yarray of double
gammadouble
(returns)double

Description: Radial Basis Function (RBF) kernel function.

Parameters:

xLength n vector.
yLength n vector.
gammaGamma 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]}
xarray of double
yarray of double
gammadouble
interceptdouble
degreedouble
(returns)double

Description: Polynomial kernel function.

Parameters:

xLength n vector.
yLength n vector.
gammaGamma coefficient.
inteceptIntercept constant.
degreeDegree 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]}
xarray of double
yarray of double
gammadouble
interceptdouble
(returns)double

Description: Sigmoid kernel function.

Parameters:

xLength n vector.
yLength n vector.
gammaGamma coefficient.
inteceptIntercept 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]}
xarray of array of double
fcnfunction of (double) → double
(returns)array of array of double
{"la.map": [x, fcn]}
xmap of map of double
fcnfunction 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]}
xarray of double
alphadouble
(returns)array of double
{"la.scale": [x, alpha]}
xarray of array of double
alphadouble
(returns)array of array of double
{"la.scale": [x, alpha]}
xmap of double
alphadouble
(returns)map of double
{"la.scale": [x, alpha]}
xmap of map of double
alphadouble
(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]}
xarray of array of double
yarray of array of double
fcnfunction of (double, double) → double
(returns)array of array of double
{"la.zipmap": [x, y, fcn]}
xmap of map of double
ymap of map of double
fcnfunction 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.

{"la.add": [x, y]}
xarray of double
yarray of double
(returns)array of double
{"la.add": [x, y]}
xarray of array of double
yarray of array of double
(returns)array of array of double
{"la.add": [x, y]}
xmap of double
ymap of double
(returns)map of double
{"la.add": [x, y]}
xmap of map of double
ymap 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]}
xarray of double
yarray of double
(returns)array of double
{"la.sub": [x, y]}
xarray of array of double
yarray of array of double
(returns)array of array of double
{"la.sub": [x, y]}
xmap of double
ymap of double
(returns)map of double
{"la.sub": [x, y]}
xmap of map of double
ymap 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]}
xarray of array of double
yarray of double
(returns)array of double
{"la.dot": [x, y]}
xmap of map of double
ymap of double
(returns)map of double
{"la.dot": [x, y]}
xarray of array of double
yarray of array of double
(returns)array of array of double
{"la.dot": [x, y]}
xmap of map of double
ymap 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]}
xarray of array of double
(returns)array of array of double
{"la.transpose": [x]}
xmap 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]}
xarray of array of double
(returns)array of array of double
{"la.inverse": [x]}
xmap 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]}
xarray of array of double
(returns)double
{"la.trace": [x]}
xmap 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]}
xarray of array of double
(returns)double
{"la.det": [x]}
xmap 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]}
xarray of array of double
tolerancedouble
(returns)boolean
{"la.symmetric": [x, tolerance]}
xmap of map of double
tolerancedouble
(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]}
xarray of array of double
(returns)array of array of double
{"la.eigenBasis": [x]}
xmap 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]}
xarray of array of double
keepint
(returns)array of array of double
{"la.truncate": [x, keep]}
xmap of map of double
keeparray of string
(returns)map of map of double

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

Parameters:

xThe matrix to truncate.
keepIf 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]}
xarray of double
yarray of double
(returns)double

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

Parameters:

xFirst sample vector.
ySecond 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]}
xdouble
ydouble
(returns)double

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

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

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

{"metric.euclidean": [similarity, x, y]}
similarityfunction of (any A, any B) → double
xarray of union of {null, A}
yarray of union of {null, B}
(returns)double
{"metric.euclidean": [similarity, x, y, missingWeight]}
similarityfunction of (any A, any B) → double
xarray of union of {null, A}
yarray of union of {null, B}
missingWeightarray 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:

similaritySimilarity function (1-dimensional metric) that quantifies the distance between components of x and components of y.
xFirst sample vector, which may have missing values.
ySecond sample vector, which may have missing values. (Must have the same dimension as x.)
missingWeightOptional 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]}
similarityfunction of (double, double) → double
xarray of union of {null, double}
yarray of union of {null, double}
(returns)double
{"metric.squaredEuclidean": [similarity, x, y, missingWeight]}
similarityfunction of (double, double) → double
xarray of union of {null, double}
yarray of union of {null, double}
missingWeightarray of double
(returns)double

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

Parameters:

similaritySimilarity function (1-dimensional metric) that quantifies the distance between components of x and components of y.
xFirst sample vector, which may have missing values.
ySecond sample vector, which may have missing values. (Must have the same dimension as x.)
missingWeightOptional 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]}
similarityfunction of (double, double) → double
xarray of union of {null, double}
yarray of union of {null, double}
(returns)double
{"metric.chebyshev": [similarity, x, y, missingWeight]}
similarityfunction of (double, double) → double
xarray of union of {null, double}
yarray of union of {null, double}
missingWeightarray 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:

similaritySimilarity function (1-dimensional metric) that quantifies the distance between components of x and components of y.
xFirst sample vector, which may have missing values.
ySecond sample vector, which may have missing values. (Must have the same dimension as x.)
missingWeightOptional 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]}
similarityfunction of (double, double) → double
xarray of union of {null, double}
yarray of union of {null, double}
(returns)double
{"metric.taxicab": [similarity, x, y, missingWeight]}
similarityfunction of (double, double) → double
xarray of union of {null, double}
yarray of union of {null, double}
missingWeightarray 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:

similaritySimilarity function (1-dimensional metric) that quantifies the distance between components of x and components of y.
xFirst sample vector, which may have missing values.
ySecond sample vector, which may have missing values. (Must have the same dimension as x.)
missingWeightOptional 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]}
similarityfunction of (double, double) → double
xarray of union of {null, double}
yarray of union of {null, double}
pdouble
(returns)double
{"metric.minkowski": [similarity, x, y, p, missingWeight]}
similarityfunction of (double, double) → double
xarray of union of {null, double}
yarray of union of {null, double}
pdouble
missingWeightarray of double
(returns)double

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

Parameters:

similaritySimilarity function (1-dimensional metric) that quantifies the distance between components of x and components of y.
xFirst sample vector, which may have missing values.
ySecond sample vector, which may have missing values. (Must have the same dimension as x.)
missingWeightOptional 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]}
xarray of boolean
yarray of boolean
(returns)double

Description: Simple metric on binary vectors.

Parameters:

xFirst sample vector.
ySecond 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]}
xarray of boolean
yarray of boolean
(returns)double

Description: Jaccard similarity of binary vectors.

Parameters:

xFirst sample vector.
ySecond 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]}
xarray of boolean
yarray of boolean
(returns)double

Description: Tanimoto similarity of binary vectors.

Parameters:

xFirst sample vector.
ySecond 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]}
xarray of boolean
yarray of boolean
c00double
c01double
c10double
c11double
d00double
d01double
d10double
d11double
(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:

xFirst sample vector.
ySecond 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]}
lowint
highint
(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]}
lowlong
highlong
(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]}
lowfloat
highfloat
(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]}
lowdouble
highdouble
(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]}
populationarray 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]}
sizeint
populationarray 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]}
sizeint
populationarray 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]}
distributionarray of double
(returns)int
{"rand.histogram": [distribution]}
distributionarray 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]}
sizeint
(returns)string
{"rand.string": [size, population]}
sizeint
populationstring
(returns)string
{"rand.string": [size, low, high]}
sizeint
lowint
highint
(returns)string

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

Parameters:

sizeNumber of characters in the resulting string.
populationBag of characters to choose from. Characters repeated \(N\) times in the population have probability \(N\)/size, but order is irrelevant.
lowMinimum code-point to sample (inclusive).
highMaximum 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]}
sizeint
(returns)bytes
{"rand.bytes": [size, population]}
sizeint
populationbytes
(returns)bytes
{"rand.bytes": [size, low, high]}
sizeint
lowint
highint
(returns)bytes

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

Parameters:

sizeNumber of bytes in the result.
populationBag of bytes to choose from. Bytes repeated \(N\) times in the population have probability \(N\)/size, but order is irrelevant.
lowMinimum byte value to sample (inclusive).
highMaximum 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]}
mudouble
sigmadouble
(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]}
sstring
(returns)int

Description: Return the length of string s.

{"s.substr": [s, start, end]}
sstring
startint
endint
(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]}
sstring
startint
endint
replacementstring
(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]}
haystackstring
needlestring
(returns)boolean

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

{"s.count": [haystack, needle]}
haystackstring
needlestring
(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]}
haystackstring
needlestring
(returns)int

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

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

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

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

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

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

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

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

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

{"s.split": [s, sep]}
sstring
sepstring
(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]}
xlong
(returns)string
{"s.hex": [x, width, zeroPad]}
xlong
widthint
zeroPadboolean
(returns)string

Description: Format an unsigned number as a hexidecimal string.

Parameters:

xThe number.
widthWidth of the string. If negative, left-justify. If omitted, the string will be as wide as it needs to be to provide the precision.
zeroPadIf 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]}
xlong
(returns)string
{"s.int": [x, width, zeroPad]}
xlong
widthint
zeroPadboolean
(returns)string

Description: Format an integer as a decimal string.

Parameters:

xThe integer.
widthWidth of the string. If negative, left-justify. If omitted, the string will be as wide as it needs to be to provide enough precision.
zeroPadIf 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]}
xlong
(returns)string
Deprecated; exists until PFA 0.9.0: use s.int for integers.
{"s.number": [x, width, zeroPad]}
xlong
widthint
zeroPadboolean
(returns)string
Deprecated; exists until PFA 0.9.0: use s.int for integers.
{"s.number": [x, width, precision]}
xdouble
widthunion of {int, null}
precisionunion of {int, null}
(returns)string
{"s.number": [x, width, precision, minNoExp, maxNoExp]}
xdouble
widthunion of {int, null}
precisionunion of {int, null}
minNoExpdouble
maxNoExpdouble
(returns)string

Description: Format a number as a decimal string.

Parameters:

xThe number. Note that different signatures apply to integers and floating point numbers.
widthWidth of the string. If negative, left-justify. If omitted, the string will be as wide as it needs to be to provide the precision.
zeroPadIf true, pad the integer with zeros to fill up to width.
precisionOptional precision with which to represent the number. If omitted, at most six digits after the decimal point will be shown, unless they are zero.
minNoExpMinimum absolute value that is not presented in scientific notation; 0.0001 if omitted.
maxNoExpMaxiumum 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]}
xstring
ystring
(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]}
sstring
nint
(returns)string

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

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

Description: Convert s to lower-case.

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

Description: Convert s to upper-case.

{"s.lstrip": [s, chars]}
sstring
charsstring
(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]}
sstring
charsstring
(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]}
sstring
charsstring
(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]}
sstring
originalstring
replacementstring
(returns)string

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

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

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

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

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

{"s.translate": [s, oldchars, newchars]}
sstring
oldcharsstring
newcharsstring
(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]}
haystackstring
patternstring
(returns)array of int
{"re.index": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)boolean
{"re.contains": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)int
{"re.count": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)array of int
{"re.rindex": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)array of array of int
{"re.groups": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)array of array of int
{"re.indexall": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)array of string
{"re.findall": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)union of {string, null}
{"re.findfirst": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)array of string
{"re.findgroupsfirst": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)array of array of string
{"re.findgroupsall": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
(returns)array of array of array of int
{"re.groupsall": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
replacementstring
(returns)string
{"re.replacefirst": [haystack, pattern, replacement]}
haystackbytes
patternbytes
replacementbytes
(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]}
haystackstring
patternstring
replacementstring
(returns)string
{"re.replacelast": [haystack, pattern, replacement]}
haystackbytes
patternbytes
replacementbytes
(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]}
haystackstring
patternstring
(returns)array of string
{"re.split": [haystack, pattern]}
haystackbytes
patternbytes
(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]}
haystackstring
patternstring
replacementstring
(returns)string
{"re.replaceall": [haystack, pattern, replacement]}
haystackbytes
patternbytes
replacementbytes
(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]}
strstring
baseint
(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]}
strstring
baseint
(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]}
strstring
(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]}
strstring
(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]}
xlong
bitsint
(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]}
xlong
bitsint
(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]}
xint
(returns)int
{"cast.int": [x]}
xlong
(returns)int
{"cast.int": [x]}
xfloat
(returns)int
{"cast.int": [x]}
xdouble
(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]}
xint
(returns)long
{"cast.long": [x]}
xlong
(returns)long
{"cast.long": [x]}
xfloat
(returns)long
{"cast.long": [x]}
xdouble
(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]}
xint
(returns)float
{"cast.float": [x]}
xlong
(returns)float
{"cast.float": [x]}
xfloat
(returns)float
{"cast.float": [x]}
xdouble
(returns)float

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

{"cast.double": [x]}
xint
(returns)double
{"cast.double": [x]}
xlong
(returns)double
{"cast.double": [x]}
xfloat
(returns)double
{"cast.double": [x]}
xdouble
(returns)double

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

{"cast.fanoutBoolean": [x]}
xany enum A
(returns)array of boolean
{"cast.fanoutBoolean": [x, dictionary, outOfRange]}
xstring
dictionaryarray of string
outOfRangeboolean
(returns)array of boolean
{"cast.fanoutBoolean": [x, minimum, maximum, outOfRange]}
xint
minimumint
maximumint
outOfRangeboolean
(returns)array of boolean

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

Parameters:

xCategorical datum
dictionaryPossible values of x, which is needed if x is an arbitrary string.
minimumInclusive minimum value of x.
maximumExcluded maximum value of x.
outOfRangeIf 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]}
xany enum A
(returns)array of int
{"cast.fanoutInt": [x, dictionary, outOfRange]}
xstring
dictionaryarray of string
outOfRangeboolean
(returns)array of int
{"cast.fanoutInt": [x, minimum, maximum, outOfRange]}
xint
minimumint
maximumint
outOfRangeboolean
(returns)array of int

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

Parameters:

xCategorical datum
dictionaryPossible values of x, which is needed if x is an arbitrary string.
minimumInclusive minimum value of x.
maximumExcluded maximum value of x.
outOfRangeIf 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]}
xany enum A
(returns)array of long
{"cast.fanoutLong": [x, dictionary, outOfRange]}
xstring
dictionaryarray of string
outOfRangeboolean
(returns)array of long
{"cast.fanoutLong": [x, minimum, maximum, outOfRange]}
xint
minimumint
maximumint
outOfRangeboolean
(returns)array of long

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

Parameters:

xCategorical datum
dictionaryPossible values of x, which is needed if x is an arbitrary string.
minimumInclusive minimum value of x.
maximumExcluded maximum value of x.
outOfRangeIf 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]}
xany enum A
(returns)array of float
{"cast.fanoutFloat": [x, dictionary, outOfRange]}
xstring
dictionaryarray of string
outOfRangeboolean
(returns)array of float
{"cast.fanoutFloat": [x, minimum, maximum, outOfRange]}
xint
minimumint
maximumint
outOfRangeboolean
(returns)array of float

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

Parameters:

xCategorical datum
dictionaryPossible values of x, which is needed if x is an arbitrary string.
minimumInclusive minimum value of x.
maximumExcluded maximum value of x.
outOfRangeIf 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]}
xany enum A
(returns)array of double
{"cast.fanoutDouble": [x, dictionary, outOfRange]}
xstring
dictionaryarray of string
outOfRangeboolean
(returns)array of double
{"cast.fanoutDouble": [x, minimum, maximum, outOfRange]}
xint
minimumint
maximumint
outOfRangeboolean
(returns)array of double

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

Parameters:

xCategorical datum
dictionaryPossible values of x, which is needed if x is an arbitrary string.
minimumInclusive minimum value of x.
maximumExcluded maximum value of x.
outOfRangeIf 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]}
xany 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]}
xany 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]}
aarray of any A
(returns)int

Description: Return the length of array a.

{"a.subseq": [a, start, end]}
aarray of any A
startint
endint
(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.head": [a]}
aarray 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]}
aarray 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]}
aarray 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]}
aarray 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]}
aarray of any A
startint
endint
replacementarray 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]}
haystackarray of any A
needlearray of A
(returns)boolean
{"a.contains": [haystack, needle]}
haystackarray of any A
needleA
(returns)boolean
{"a.contains": [haystack, needle]}
haystackarray of any A
needlefunction 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]}
haystackarray of any A
needlearray of A
(returns)int
{"a.count": [haystack, needle]}
haystackarray of any A
needleA
(returns)int
{"a.count": [haystack, needle]}
haystackarray of any A
needlefunction 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]}
haystackarray of any A
needlearray of A
(returns)int
{"a.index": [haystack, needle]}
haystackarray of any A
needleA
(returns)int
{"a.index": [haystack, needle]}
haystackarray of any A
needlefunction 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]}
haystackarray of any A
needlearray of A
(returns)int
{"a.rindex": [haystack, needle]}
haystackarray of any A
needleA
(returns)int
{"a.rindex": [haystack, needle]}
haystackarray of any A
needlefunction 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]}
haystackarray of any A
needlearray of A
(returns)boolean
{"a.startswith": [haystack, needle]}
haystackarray of any A
needleA
(returns)boolean

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

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

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

{"a.concat": [a, b]}
aarray of any A
barray 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]}
aarray of any A
itemA
(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]}
aarray of any A
itemA
maxLengthint
(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]}
aarray of any A
indexint
itemA
(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]}
aarray of any A
indexint
itemA
(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]}
aarray of any A
startint
endint
(returns)array of A
{"a.remove": [a, index]}
aarray of any A
indexint
(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]}
aarray of any A
stepsint
(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]}
aarray 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]}
aarray of any A
lessThanfunction 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]}
aarray 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]}
aarray of any A
(returns)array of A

Description: Return the elements of a in reversed order.

{"a.max": [a]}
aarray 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]}
aarray 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]}
aarray of any A
lessThanfunction 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]}
aarray of any A
lessThanfunction 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]}
aarray of any A
nint
(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]}
aarray of any A
nint
(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]}
aarray of any A
nint
lessThanfunction 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]}
aarray of any A
nint
lessThanfunction 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]}
aarray 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]}
aarray 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]}
aarray of any A
lessThanfunction 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]}
aarray of any A
lessThanfunction 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]}
aarray of any A
nint
(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]}
aarray of any A
nint
(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]}
aarray of any A
nint
lessThanfunction 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]}
aarray of any A
nint
lessThanfunction 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]}
aarray 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]}
aarray 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]}
aarray 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]}
aarray of double
(returns)double

Description: Return the arithmetic mean of numbers in a.

Details:

  • Returns NaN if the array is empty.

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

Description: Return the geometric mean of numbers in a.

Details:

  • Returns NaN if the array is empty.

{"a.median": [a]}
aarray 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]}
aarray of any A
pdouble
(returns)A

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

Parameters:

aArray of objects to be take the percentile of.
pA 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]}
aarray 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]}
aarray 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]}
aarray 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]}
aarray of any A
barray of A
(returns)boolean

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

{"a.union": [a, b]}
aarray of any A
barray 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]}
aarray of any A
barray 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]}
aarray of any A
barray 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]}
aarray of any A
barray 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]}
littlearray of any A
bigarray of A
(returns)boolean

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

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

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

{"a.map": [a, fcn]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
barray of any B
fcnfunction of (A, B) → any Z
(returns)array of Z
{"a.zipmap": [a, b, c, fcn]}
aarray of any A
barray of any B
carray of any C
fcnfunction of (A, B, C) → any Z
(returns)array of Z
{"a.zipmap": [a, b, c, d, fcn]}
aarray of any A
barray of any B
carray of any C
darray of any D
fcnfunction 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]}
aarray of any A
barray of any B
fcnfunction of (int, A, B) → any Z
(returns)array of Z
{"a.zipmapWithIndex": [a, b, c, fcn]}
aarray of any A
barray of any B
carray of any C
fcnfunction of (int, A, B, C) → any Z
(returns)array of Z
{"a.zipmapWithIndex": [a, b, c, d, fcn]}
aarray of any A
barray of any B
carray of any C
darray of any D
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
zeroany B
fcnfunction 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]}
aarray of any A
zeroany B
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
fcnfunction 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]}
aarray of any A
barray of any B
fcnfunction 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]}
aarray of any A
barray of any B
fcnfunction 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]}
aarray of any A
sizeint
stepint
(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]}
aarray of any A
sizeint
(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]}
aarray 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]}
aarray of array of any A
(returns)array of A

Description: Concatenate the arrays in a.

{"a.groupby": [a, fcn]}
aarray of any A
fcnfunction 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]}
mmap of any A
(returns)int

Description: Return the length of a map.

{"map.keys": [m]}
mmap 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]}
mmap 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]}
mmap of any A
keystring
(returns)boolean
{"map.containsKey": [m, fcn]}
mmap of any A
fcnfunction 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]}
mmap of any A
valueA
(returns)boolean
{"map.containsValue": [m, fcn]}
mmap of any A
fcnfunction 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.

{"map.add": [m, key, value]}
mmap of any A
keystring
valueA
(returns)map of A
{"map.add": [m, item]}
mmap of any A
itemA
(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]}
mmap of any A
keystring
(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]}
mmap of any A
keysarray 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]}
mmap of any A
keysarray 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]}
basemap of any A
overlaymap 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]}
mmap 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]}
aarray 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]}
mmap 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]}
mmap 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]}
mmap of any A
lessThanfunction 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]}
mmap of any A
lessThanfunction 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]}
mmap of any A
nint
(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]}
mmap of any A
nint
(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]}
mmap of any A
nint
lessThanfunction 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]}
mmap of any A
nint
lessThanfunction 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]}
aarray 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]}
smap 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]}
smap of any A
xA
(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]}
amap of any A
bmap 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]}
amap of any A
bmap 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]}
amap of any A
bmap 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]}
amap of any A
bmap 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]}
littlemap of any A
bigmap 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]}
amap of any A
bmap 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]}
mmap of any A
fcnfunction 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]}
mmap of any A
fcnfunction 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]}
mmap of any A
fcnfunction 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]}
mmap of any A
fcnfunction 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]}
mmap of any A
fcnfunction 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]}
mmap of any A
fcnfunction 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]}
mmap of any A
fcnfunction 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]}
mmap of any A
fcnfunction 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]}
amap of any A
bmap of any B
fcnfunction of (A, B) → any Z
(returns)map of Z
{"map.zipmap": [a, b, c, fcn]}
amap of any A
bmap of any B
cmap of any C
fcnfunction of (A, B, C) → any Z
(returns)map of Z
{"map.zipmap": [a, b, c, d, fcn]}
amap of any A
bmap of any B
cmap of any C
dmap of any D
fcnfunction 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]}
amap of any A
bmap of any B
fcnfunction of (string, A, B) → any Z
(returns)map of Z
{"map.zipmapWithKey": [a, b, c, fcn]}
amap of any A
bmap of any B
cmap of any C
fcnfunction of (string, A, B, C) → any Z
(returns)map of Z
{"map.zipmapWithKey": [a, b, c, d, fcn]}
amap of any A
bmap of any B
cmap of any C
dmap of any D
fcnfunction 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]}
amap of any A
bmap of any B
fcnfunction 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]}
amap of any A
bmap of any B
fcnfunction 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]}
xbytes
(returns)int

Description: Return the length of byte array x.

{"bytes.subseq": [x, start, end]}
xbytes
startint
endint
(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]}
xbytes
startint
endint
replacementbytes
(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]}
xbytes
(returns)boolean
{"bytes.isAscii": [x]}
xstring
(returns)boolean

Description: Returns true if x is valid ASCII; false otherwise.

{"bytes.isLatin1": [x]}
xbytes
(returns)boolean
{"bytes.isLatin1": [x]}
xstring
(returns)boolean

Description: Returns true if x is valid latin-1 (ISO-8859-1); false otherwise.

{"bytes.isUtf8": [x]}
xbytes
(returns)boolean
{"bytes.isUtf8": [x]}
xstring
(returns)boolean

Description: Returns true if x is valid utf-8; false otherwise.

{"bytes.isUtf16": [x]}
xbytes
(returns)boolean
{"bytes.isUtf16": [x]}
xstring
(returns)boolean

Description: Returns true if x is valid utf-16 (byte order identified by optional byte-order mark); false otherwise.

{"bytes.isUtf16be": [x]}
xbytes
(returns)boolean
{"bytes.isUtf16be": [x]}
xstring
(returns)boolean

Description: Returns true if x is valid big endian utf-16; false otherwise.

{"bytes.isUtf16le": [x]}
xbytes
(returns)boolean
{"bytes.isUtf16le": [x]}
xstring
(returns)boolean

Description: Returns true if x is valid little endian utf-16; false otherwise.

{"bytes.decodeAscii": [x]}
xbytes
(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]}
xbytes
(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]}
xbytes
(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]}
xbytes
(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]}
xbytes
(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]}
xbytes
(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]}
sstring
(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]}
sstring
(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]}
sstring
(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]}
sstring
(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]}
sstring
(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]}
sstring
(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]}
xbytes
(returns)string

Description: Convert an arbitrary bytes object to a base64-encoded string.

{"bytes.fromBase64": [s]}
sstring
(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]}
xany fixed A
(returns)bytes

Description: Convert fixed-length, named bytes into arbitrary-length, anonymous bytes.

{"fixed.fromBytes": [original, replacement]}
originalany fixed A
replacementbytes
(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]}
xany enum A
(returns)string

Description: Return the string representation of an enum.

{"enum.toInt": [x]}
xany enum A
(returns)int

Description: Return the integer representation of an enum.

{"enum.numSymbols": [x]}
xany enum A
(returns)int

Description: Return the number of symbols associated with this enum (a constant).

time

{"time.year": [ts, zone]}
tsdouble
zonestring
(returns)int

Description: Get the four-digit year that the timestamp falls within.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
tsdouble
zonestring
(returns)int

Description: Get the month that the timestamp falls within, with 1 being January and 12 being December.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
tsdouble
zonestring
(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:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
tsdouble
zonestring
(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:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
tsdouble
zonestring
(returns)int

Description: Get the day of the week that the timestamp falls within, with 0 being Monday and 6 being Sunday.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
tsdouble
zonestring
(returns)int

Description: Get the hour of the day that the timestamp falls within, from 0 to 23 inclusive.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
tsdouble
zonestring
(returns)int

Description: Get the minute of the hour that the timestamp falls within, from 0 to 59 inclusive.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
tsdouble
zonestring
(returns)int

Description: Get the second of the minute that the timestamp falls within, from 0 to 59 inclusive.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
yearint
monthint
dayint
hourint
minuteint
secondint
millisecondint
zonestring
(returns)double

Description: Given the date and time that this time occurs in, return the timestamp.

Parameters:

yearThe four-digit year, from 1 to 9999 inclusive.
monthThe month of the year, from 1 to 12 inclusive.
dayThe day of the month, from 1 to 28, 29, 30, or 31 inclusive, depending on month.
hourThe hour of the day, from 0 to 23 inclusive.
minuteThe minute of the hour, from 0 to 59 inclusive.
secondThe second of the minute, from 0 to 59 inclusive.
millisecondThe millisecond of the second, from 0 to 999 inclusive.
zoneTimezone 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]}
tsdouble
zonestring
lowdouble
highdouble
(returns)boolean

Description: Determines if a timestamp falls within a specified number of seconds in any minute.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone name from the Olson timezone database, version 2015f (UTC if blank).
lowMinimum number of seconds (inclusive).
highMaximum 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]}
tsdouble
zonestring
lowdouble
highdouble
(returns)boolean

Description: Determines if a timestamp falls within a specified number of minutes in any hour.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone name from the Olson timezone database, version 2015f (UTC if blank).
lowMinimum number of minutes (inclusive)
highMaximum 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]}
tsdouble
zonestring
lowdouble
highdouble
(returns)boolean

Description: Determines if a timestamp falls within a specified number of hours in any day.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone name from the Olson timezone database, version 2015f (UTC if blank).
lowMinimum number of hours (inclusive).
highMaximum 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]}
tsdouble
zonestring
lowdouble
highdouble
(returns)boolean

Description: Determines if a timestamp falls within a specified day of week range, with 0 being Monday and 6 being Sunday.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone name from the Olson timezone database, version 2015f (UTC if blank).
lowMinimum day of the week (inclusive).
highMaximum 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]}
tsdouble
zonestring
lowdouble
highdouble
(returns)boolean

Description: Determines if a timestamp falls within a specified day of month range, with 1 being the first of the month..

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone name from the Olson timezone database, version 2015f (UTC if blank).
lowMinimum day of the month (inclusive).
highMaximum 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]}
tsdouble
zonestring
lowdouble
highdouble
(returns)boolean

Description: Determines if a timestamp falls within a specified month of year range, with 1 being January and 12 being December.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone name from the Olson timezone database, version 2015f (UTC if blank).
lowMinimum month of the year (inclusive).
highMaximum 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]}
tsdouble
zonestring
lowdouble
highdouble
(returns)boolean

Description: Determines if a timestamp falls within a specified day of year range, with 1 being the first of the year.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone name from the Olson timezone database, version 2015f (UTC if blank).
lowMinimum day of year (inclusive).
highMaximum 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]}
tsdouble
zonestring
(returns)boolean

Description: Returns true if the timestamp falls on a Saturday or Sunday, false otherwise.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
tsdouble
zonestring
(returns)boolean

Description: Returns true if the timestamp falls between 9 am (inclusive) and 5 pm (exclusive) on Monday through Friday, otherwise false.

Parameters:

tsNumber of seconds since the beginning (just after midnight) of Jan 1, 1970 C.E. in UTC.
zoneTimezone 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]}
xunion 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]}
xunion of {any A, null}
defaultA
(returns)A

Description: Replace null values in x with default.

{"impute.isnan": [x]}
xfloat
(returns)boolean
{"impute.isnan": [x]}
xdouble
(returns)boolean

Description: Return true if x is nan, false otherwise.

{"impute.isinf": [x]}
xfloat
(returns)boolean
{"impute.isinf": [x]}
xdouble
(returns)boolean

Description: Return true if x is positive or negative infinity, false otherwise.

{"impute.isnum": [x]}
xfloat
(returns)boolean
{"impute.isnum": [x]}
xdouble
(returns)boolean

Description: Return true if x is neither nan nor infinite, false otherwise.

{"impute.errorOnNonNum": [x]}
xfloat
(returns)float
{"impute.errorOnNonNum": [x]}
xdouble
(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]}
xfloat
defaultfloat
(returns)float
{"impute.defaultOnNonNum": [x, default]}
xdouble
defaultdouble
(returns)double

Description: Pass through x if it is neither nan nor infinite, and return default otherwise.

interp

{"interp.bin": [x, numbins, low, high]}
xdouble
numbinsint
lowdouble
highdouble
(returns)int
{"interp.bin": [x, origin, width]}
xdouble
origindouble
widthdouble
(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]}
xdouble
tablearray of any record R with fields {x: double, to: any T}
(returns)T
{"interp.nearest": [x, table]}
xarray of double
tablearray of any record R with fields {x: array of double, to: any T}
(returns)T
{"interp.nearest": [x, table, metric]}
xany X1
tablearray of any record R with fields {x: any X2, to: any T}
metricfunction 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]}
xdouble
tablearray of any record R with fields {x: double, to: double}
(returns)double
{"interp.linear": [x, table]}
xdouble
tablearray 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]}
xdouble
tablearray of any record R with fields {x: double, to: double}
(returns)double
{"interp.linearFlat": [x, table]}
xdouble
tablearray 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]}
xdouble
tablearray of any record R with fields {x: double, to: double}
(returns)union of {null, double}
{"interp.linearMissing": [x, table]}
xdouble
tablearray 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]}
xdouble
mudouble
sigmadouble
(returns)double
{"prob.dist.gaussianLL": [x, params]}
xdouble
paramsany 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:

xValue at which to compute the log-likelihood.
muCentroid of the distribution (same as mean).
sigmaWidth of the distribution (same as the square root of variance).
paramsAlternate 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]}
xdouble
mudouble
sigmadouble
(returns)double
{"prob.dist.gaussianCDF": [x, params]}
xdouble
paramsany 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:

xValue at which to compute the CDF.
muCentroid of the distribution (same as mean).
sigmaWidth of the distribution (same as the square root of variance).
paramsAlternate 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]}
pdouble
mudouble
sigmadouble
(returns)double
{"prob.dist.gaussianQF": [p, params]}
pdouble
paramsany 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:

pProbability at which to compute the QF. Must be a value between 0 and 1.
muCentroid of the distribution (same as mean).
sigmaWidth of the distribution (same as the square root of variance).
paramsAlternate 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]}
xdouble
lambdadouble
(returns)double

Description: Compute the density (PDF) of the exponential distribution parameterized by lambda.

Parameters:

xValue at which to compute the PDF.
lambdaRate 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]}
xdouble
lambdadouble
(returns)double

Description: Compute the distribution function (CDF) of the exponential distribution parameterized by lambda.

Parameters:

xValue at which to compute the CDF.
lambdaRate 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]}
pdouble
lambdadouble
(returns)double

Description: Compute the quantile function (QF) of the exponential distribution parameterized by lambda.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
lambdaRate 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]}
xdouble
dofint
(returns)double

Description: Compute the density (PDF) of the Chi-squared distribution parameterized by its degrees of freedom dof.

Parameters:

xValue at which to compute the PDF.
dofDegrees 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]}
xdouble
dofint
(returns)double

Description: Compute the distribution function (CDF) of the Chi-squared distribution parameterized by its degrees of freedom dof.

Parameters:

xValue at which to compute the CDF.
dofDegrees 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]}
pdouble
dofint
(returns)double

Description: Compute the quantile function (QF) of the Chi-squared distribution parameterized by its degrees of freedom dof.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
dofDegrees 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]}
xint
lambdadouble
(returns)double

Description: Compute the density (PDF) of the poisson distribution parameterized by lambda.

Parameters:

xValue at which to compute the PDF.
lambdaMean 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]}
xint
lambdadouble
(returns)double

Description: Compute the distribution function (CDF) of the poisson distribution parameterized by lambda.

Parameters:

xValue at which to compute the CDF.
lambdaMean 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]}
pdouble
lambdadouble
(returns)double

Description: Compute the quantile function (QF) of the poisson distribution parameterized by lambda.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
lambdaMean 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]}
xdouble
shapedouble
scaledouble
(returns)double

Description: Compute the density (PDF) of the gamma distribution parameterized by shape and scale.

Parameters:

xValue at which to compute the PDF.
shapeShape parameter (a).
scaleScale 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]}
xdouble
shapedouble
scaledouble
(returns)double

Description: Compute the distribution function (CDF) of the gamma distribution parameterized by shape and scale.

Parameters:

xValue at which to compute the CDF.
shapeShape parameter.
scaleScale 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]}
pdouble
shapedouble
scaledouble
(returns)double

Description: Compute the quantile function (QF) of the gamma distribution parameterized by shape and scale.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
shapeShape parameter.
scaleScale 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]}
xdouble
adouble
bdouble
(returns)double

Description: Compute the density (PDF) of the beta distribution parameterized by shape1 and shape2.

Parameters:

xValue at which to compute the PDF, defined between zero and one.
aFirst shape parameter.
bSecond 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]}
xdouble
adouble
bdouble
(returns)double

Description: Compute the distribution function (CDF) of the beta distribution parameterized by shape1 and shape2.

Parameters:

xValue at which to compute the CDF.
aFirst shape parameter.
bSecond 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]}
pdouble
adouble
bdouble
(returns)double

Description: Compute the quantile function (QF) of the beta distribution parameterized by shape1 and shape2.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
aFirst shape parameter.
bSecond 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]}
xdouble
locationdouble
scaledouble
(returns)double

Description: Compute the density (PDF) of the cauchy distribution parameterized by location and scale.

Parameters:

xValue at which to compute the PDF.
locationLocation parameter (l).
scaleScale 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]}
xdouble
locationdouble
scaledouble
(returns)double

Description: Compute the distribution function (CDF) of the cauchy distribution parameterized by location and scale.

Parameters:

xValue at which to compute the CDF.
locationLocation parameter.
scaleScale 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]}
pdouble
locationdouble
scaledouble
(returns)double

Description: Compute the quantile function (QF) of the cauchy distribution parameterized by location and scale.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
locationLocation parameter.
scaleScale 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]}
xdouble
d1int
d2int
(returns)double

Description: Compute the density (PDF) of the F distribution parameterized by d1 and d2.

Parameters:

xValue at which to compute the PDF.
d1Numerator degrees of freedom parameter.
d2Denominator 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]}
xdouble
d1int
d2int
(returns)double

Description: Compute the distribution function (CDF) of the F distribution parameterized by d1 and d2.

Parameters:

xValue at which to compute the CDF.
d1Numerator degrees of freedom parameter.
d2Denominator 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]}
pdouble
d1int
d2int
(returns)double

Description: Compute the quantile function (QF) of the F distribution parameterized by d1 and d2.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
d1Numerator degrees of freedom parameter.
d2Denominator 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]}
xdouble
meanlogdouble
sdlogdouble
(returns)double

Description: Compute the density (PDF) of the lognormal distribution parameterized by meanlog and sdlog.

Parameters:

xValue at which to compute the PDF.
meanlogMean of the distribution on the log scale (\(\mu\)).
sdlogStandard 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]}
xdouble
meanlogdouble
sdlogdouble
(returns)double

Description: Compute the distribution function (CDF) of the lognormal distribution parameterized by meanlog and sdlog.

Parameters:

xValue at which to compute the CDF.
meanlogMean of the distribution on the log scale.
sdlogStandard 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]}
pdouble
meanlogdouble
sdlogdouble
(returns)double

Description: Compute the quantile function (QF) of the lognormal distribution parameterized by meanlog and sdlog.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
meanlogMean of the distribution on the log scale.
sdlogStandard 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]}
xdouble
dofint
(returns)double

Description: Compute the density (PDF) of the student's t distribution parameterized by dof and x2.

Parameters:

xValue at which to compute the PDF.
dofDegrees 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]}
xdouble
dofint
(returns)double

Description: Compute the distribution function (CDF) of the student's t distribution parameterized by dof and x2.

Parameters:

xValue at which to compute the CDF.
dofDegrees 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]}
pdouble
dofint
(returns)double

Description: Compute the quantile function (QF) of the student's t distribution parameterized by dof and x2.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
dofDegrees 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]}
xint
sizeint
probdouble
(returns)double

Description: Compute the density (PDF) of the binomial distribution parameterized by size and prob.

Parameters:

xValue at which to compute the PDF.
sizeThe number of trials (n).
probThe 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]}
xdouble
sizeint
probdouble
(returns)double

Description: Compute the distribution function (CDF) of the binomial distribution parameterized by size and prob.

Parameters:

xValue at which to compute the CDF.
sizeThe number of trials.
probThe 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]}
pdouble
sizeint
probdouble
(returns)double

Description: Compute the quantile function (QF) of the binomial distribution parameterized by size and prob.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
sizeThe number of trials.
probThe 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]}
xdouble
mindouble
maxdouble
(returns)double

Description: Compute the density (PDF) of the uniform distribution parameterized by min and max.

Parameters:

xValue at which to compute the PDF.
minLower bound.
maxUpper 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]}
xdouble
mindouble
maxdouble
(returns)double

Description: Compute the distribution function (CDF) of the uniform distribution parameterized by min and max.

Parameters:

xValue at which to compute the CDF.
minLower bound.
maxUpper 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]}
pdouble
mindouble
maxdouble
(returns)double

Description: Compute the quantile function (QF) of the uniform distribution parameterized by min and max.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
minLower bound.
maxUpper 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]}
xint
probdouble
(returns)double

Description: Compute the density (PDF) of the geometric distribution parameterized by prob.

Parameters:

xValue at which to compute the PDF.
probProbability 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]}
xdouble
probdouble
(returns)double

Description: Compute the distribution function (CDF) of the geometric distribution parameterized by prob.

Parameters:

xValue at which to compute the CDF.
probProbability 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]}
pdouble
probdouble
(returns)double

Description: Compute the quantile function (QF) of the geometric distribution parameterized by prob.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
probProbability 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]}
xint
mint
nint
kint
(returns)double

Description: Compute the density (PDF) of the hypergeometric distribution parameterized by m, n and k.

Parameters:

xThe number of white balls drawn without replacement from the urn.
mThe number of white balls in the urn.
nThe number of black balls in the urn.
kThe 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]}
xint
mint
nint
kint
(returns)double

Description: Compute the distribution function (CDF) of the hypergeometric distribution parameterized by m, n and k.

Parameters:

xThe number of white balls drawn without replacement.
mThe number of white balls in the urn.
nThe number of black balls in the urn.
kThe 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]}
pdouble
mint
nint
kint
(returns)double

Description: Compute the quantile function (QF) of the hypergeometric distribution parameterized by m, n and k.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
mThe number of white balls in the urn.
nThe number of black balls in the urn.
kThe 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]}
xdouble
shapedouble
scaledouble
(returns)double

Description: Compute the density (PDF) of the weibull distribution parameterized by shape and scale.

Parameters:

xValue at which to compute the PDF.
shapeShape parameter (a).
scaleScale 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]}
xdouble
shapedouble
scaledouble
(returns)double

Description: Compute the distribution function (CDF) of the weibull distribution parameterized by shape and scale.

Parameters:

xValue at which to compute the CDF.
shapeShape parameter.
scaleScale 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]}
pdouble
shapedouble
scaledouble
(returns)double

Description: Compute the quantile function (QF) of the weibull distribution parameterized by shape and scale.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
shapeShape parameter.
scaleScale 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]}
xint
sizeint
probdouble
(returns)double

Description: Compute the density (PDF) of the negative binomial distribution parameterized by size and prob.

Parameters:

xValue at which to compute the PDF (integer) .
sizeSize parameter (integer). Target number of successful trials (n).
probProbability 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]}
xdouble
sizeint
probdouble
(returns)double

Description: Compute the distribution function (CDF) of the negative binomial distribution parameterized by size and prob.

Parameters:

xValue at which to compute the CDF.
sizeSize parameter (integer). Target number of successful trials.
probProbability 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]}
pdouble
sizeint
probdouble
(returns)double

Description: Compute the quantile function (QF) of the negative binomial distribution parameterized by size and prob.

Parameters:

pValue at which to compute the QF. Must be a value between 0 and 1.
sizeSize parameter (integer). Target number of successful trials.
probProbability 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]}
xarray of double
yarray 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:

xA bag of data.
yAnother 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]}
observationdouble
predicitondouble
(returns)double
{"stat.test.residual": [observation, prediciton]}
observationarray of double
predicitonarray of double
(returns)array of double
{"stat.test.residual": [observation, prediciton]}
observationmap of double
predicitonmap of double
(returns)map of double

Description: Compare an observation with its prediction by element-wise subtraction.

Parameters:

observationScalar or vector of observations.
predictionScalar 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]}
observationdouble
predicitondouble
uncertaintydouble
(returns)double
{"stat.test.pull": [observation, prediciton, uncertainty]}
observationarray of double
predicitonarray of double
uncertaintyarray of double
(returns)array of double
{"stat.test.pull": [observation, prediciton, uncertainty]}
observationmap of double
predicitonmap of double
uncertaintymap of double
(returns)map of double

Description: Compare an observation with its prediction by element-wise subtraction, weighted by element-wise uncertainties.

Parameters:

observationScalar or vector of observations.
predictionScalar or vector of predictions.
uncertaintyScalar 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]}
observationarray of double
predictionarray of double
covariancearray of array of double
(returns)double
{"stat.test.mahalanobis": [observation, prediction, covariance]}
observationmap of double
predictionmap of double
covariancemap of map of double
(returns)double

Description: Compare an observation with its prediction by computing the Mahalanobis distance for a given covariance matrix.

Parameters:

observationVector of observations \(\vec{o}\).
predictionVector of predictions \(\vec{p}\).
covarianceMatrix 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]}
pulldouble
stateany record A with fields {chi2: double, dof: int}
(returns)A
{"stat.test.updateChi2": [pull, state]}
pullarray of double
stateany record A with fields {chi2: double, dof: int}
(returns)A
{"stat.test.updateChi2": [pull, state]}
pullmap of double
stateany record A with fields {chi2: double, dof: int}
(returns)A

Description: Update the state of a chi-square calculation.

Parameters:

pullObservation 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.
stateRecord of the previous chi2 and dof.

{"stat.test.reducedChi2": [state]}
stateany record A with fields {chi2: double, dof: int}
(returns)double

Description: Return the reduced chi-square, which is chi2/dof.

Parameters:

stateRecord of the chi2 and dof.

{"stat.test.chi2Prob": [state]}
stateany 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:

stateRecord 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]}
xdouble
wdouble
stateany 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.
countThe sum of weights w.
meanThe mean of x, weighted by w. This field is optional, but if provided, it must be a double.
varianceThe 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]}
xarray of double
wdouble
stateany record A with fields {count: double, mean: array of double, covariance: array of array of double}
(returns)A
{"stat.sample.updateCovariance": [x, w, state]}
xmap of double
wdouble
stateany 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.
countThe 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.
meanThe componentwise mean of x, weighted by w.
covarianceThe 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]}
xdouble
wdouble
statearray of any record A with fields {x: double, w: double, count: double}
windowSizeint
(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.
xSample value, saved so that it can be removed from the running mean and variance when it goes out of scope.
wSample weight, saved for the same reason.
countThe sum of weights w within the window.
meanThe mean of x within the window, weighted by w. This field is optional, but if provided, it must be a double.
varianceThe 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]}
xdouble
alphadouble
stateany 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.
meanThe exponentially weighted mean of x, weighted by alpha.
varianceThe 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]}
xdouble
alphadouble
betadouble
stateany 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.
levelThe constant term in an exponentially weighted linear fit of recent data, weighted by alpha.
trendThe 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]}
xdouble
alphadouble
betadouble
gammadouble
stateany 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.
levelThe constant term in an exponentially weighted linear fit of recent data, weighted by alpha.
trendThe linear term in an exponentially weighted linear fit of recent data, weighted by beta.
cycleThe 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.
multiplicativeIf 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]}
stateany 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.
levelThe constant term in an exponentially weighted linear fit of recent data.
trendThe linear term in an exponentially weighted linear fit of recent data.
cycleThe 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.
multiplicativeIf 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]}
nint
stateany 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.
levelThe constant term in an exponentially weighted linear fit of recent data.
trendThe linear term in an exponentially weighted linear fit of recent data.
cycleThe history of the previous cycle. This field is optional, but if provided, it must be a double and must be accompanied by multiplicative.
multiplicativeIf 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]}
xdouble
wdouble
histogramany record A with fields {numbins: int, low: double, high: double, values: array of double}
(returns)A
{"stat.sample.fillHistogram": [x, w, histogram]}
xdouble
wdouble
histogramany record A with fields {low: double, binsize: double, values: array of double}
(returns)A
{"stat.sample.fillHistogram": [x, w, histogram]}
xdouble
wdouble
histogramany 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.
numbinsThe fixed number of bins in the histogram.
lowThe low edge of the histogram range (inclusive).
highThe high edge of the histogram range (exclusive).
binsizeThe size of a bin for a histogram whose number of bins and right edge grows with the data.
rangesPairs 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.
valuesHistogram contents, which are updated by this function.
underflowIf present, this double-valued field counts x values that are less than low or not contained in any ranges.
overflowIf present, this double-valued field counts x values that are greater than high.
nanflowIf 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]}
xdouble
ydouble
wdouble
histogramany 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.
xnumbinsThe number of bins in the x dimension.
xlowThe low edge of the histogram range in the x dimension (inclusive).
xhighThe high edge of the histogram range in the x dimension (exclusive).
ynumbinsThe number of bins in the y dimension.
ylowThe low edge of the histogram range in the y dimension (inclusive).
yhighThe high edge of the histogram range in the y dimension (exclusive).
valuesHistogram contents, which are updated by this function. The outer array iterates over x and the inner array iterates over y.
underunderflowIf present, this double-valued field counts instances in which x is less than xlow and y is less than ylow.
undermidflowIf present, this double-valued field counts instances in which x is less than xlow and y between ylow (inclusive) and yhigh (exclusive).
underoverflowIf present, this double-valued field counts instances in which x is less than xlow and y is greater than or equal to yhigh.
midunderflowIf present, this double-valued field counts instances in which x is between xlow (inclusive) and xhigh (exclusive) and y is less than ylow.
midoverflowIf 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.
overunderflowIf present, this double-valued field counts instances in which x is greater than or equal to xhigh and y is less than ylow.
overmidflowIf 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).
overoverflowIf 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.
nanflowIf present, this double-valued field counts instances in which x or y is nan. nan values would never enter any other counter.
infflowIf 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]}
xstring
wdouble
counterany 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.
valuesNumber 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]}
xany A
toparray of A
nint
lessThanfunction 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:

xSample value.
topArray of items to which x might be added. This array is assumed to be sorted according to lessThan.
nMaximum number of items to keep.
lessThanComparison 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]}
predicateboolean
historyany 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.
numEventsThe number of times predicate evaluated to true.
numRunsThe number of contiguous intervals in which predicate was true, including the current one.
currentRunIf predicate is false, currentRun is 0. Otherwise, currentRun is incremented (greater than or equal to 1 if predicate evaluated to true).
longestRunThe 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]}
xdouble
meanVarianceany record A with fields {mean: double, variance: double}
(returns)double
{"stat.change.zValue": [x, meanVariance, unbiased]}
xdouble
meanVarianceany record A with fields {count: double, mean: double, variance: double}
unbiasedboolean
(returns)double

Description: Calculate the z-value between x and a normal distribution with a given mean and variance.

Parameters:

xValue to test.
meanVarianceA record with mean, variance, and possibly count, such as the output of stat.sample.Update.
unbiasedIf 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]}
logLikelihoodRatiodouble
lastdouble
resetdouble
(returns)double

Description: Update a cumulative sum (CUSUM) to detect the transition of a dataset from one distribution to another.

Parameters:

logLikelihoodRatioThe 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": [...]}]}.
lastThe previous return value from this function.
resetA 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]}
datumarray of double
modelany record M with fields {coeff: array of double, const: double}
(returns)double
{"model.reg.linear": [datum, model]}
datumarray of double
modelany record M with fields {coeff: array of array of double, const: array of double}
(returns)array of double
{"model.reg.linear": [datum, model]}
datummap of double
modelany record M with fields {coeff: map of double, const: double}
(returns)double
{"model.reg.linear": [datum, model]}
datummap of double
modelany 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.
coeffVector or matrix of coefficients that multiply the input variables, which has \(p\) rows and \(d\) columns.
constScalar 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]}
datumarray of double
modelany record M with fields {covar: array of array of double}
(returns)double
{"model.reg.linearVariance": [datum, model]}
datumarray of double
modelany record M with fields {covar: array of array of array of double}
(returns)array of double
{"model.reg.linearVariance": [datum, model]}
datummap of double
modelany record M with fields {covar: map of map of double}
(returns)double
{"model.reg.linearVariance": [datum, model]}
datummap of double
modelany 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.
covarCovariance 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]}
xdouble
tablearray of any record R with fields {x: double, to: double}
krigingWeightunion of {null, double}
kernelfunction of (array of double, array of double) → double
(returns)double
{"model.reg.gaussianProcess": [x, table, krigingWeight, kernel]}
xdouble
tablearray of any record R with fields {x: double, to: array of double}
krigingWeightunion of {null, double}
kernelfunction of (array of double, array of double) → double
(returns)array of double
{"model.reg.gaussianProcess": [x, table, krigingWeight, kernel]}
xarray of double
tablearray of any record R with fields {x: array of double, to: double}
krigingWeightunion of {null, double}
kernelfunction of (array of double, array of double) → double
(returns)double
{"model.reg.gaussianProcess": [x, table, krigingWeight, kernel]}
xarray of double
tablearray of any record R with fields {x: array of double, to: array of double}
krigingWeightunion of {null, double}
kernelfunction 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.
xIndependent variable (scalar or vector, but same as x) of a training datum.
toDependent variable (scalar or vector) of a training datum.
sigmaOptional 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]}
observationdouble
predicitondouble
(returns)double
Deprecated; exists until PFA 0.9.0: use stat.test.residual instead.
{"model.reg.residual": [observation, prediciton]}
observationarray of double
predicitonarray of double
(returns)array of double
Deprecated; exists until PFA 0.9.0: use stat.test.residual instead.
{"model.reg.residual": [observation, prediciton]}
observationmap of double
predicitonmap 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:

observationScalar or vector of observations.
predictionScalar 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]}
observationdouble
predicitondouble
uncertaintydouble
(returns)double
Deprecated; exists until PFA 0.9.0: use stat.test.pull instead.
{"model.reg.pull": [observation, prediciton, uncertainty]}
observationarray of double
predicitonarray of double
uncertaintyarray of double
(returns)array of double
Deprecated; exists until PFA 0.9.0: use stat.test.pull instead.
{"model.reg.pull": [observation, prediciton, uncertainty]}
observationmap of double
predicitonmap of double
uncertaintymap 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:

observationScalar or vector of observations.
predictionScalar or vector of predictions.
uncertaintyScalar 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]}
observationarray of double
predictionarray of double
covariancearray of array of double
(returns)double
Deprecated; exists until PFA 0.9.0: use stat.test.mahalanobis instead.
{"model.reg.mahalanobis": [observation, prediction, covariance]}
observationmap of double
predictionmap of double
covariancemap 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:

observationVector of observations \(\vec{o}\).
predictionVector of predictions \(\vec{p}\).
covarianceMatrix 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]}
pulldouble
stateany 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]}
pullarray of double
stateany 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]}
pullmap of double
stateany 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:

pullObservation 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.
stateRecord of the previous chi2 and DOF.

{"model.reg.reducedChi2": [state]}
stateany 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:

stateRecord of the chi2 and DOF.

{"model.reg.chi2Prob": [state]}
stateany 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:

stateRecord of the chi2 and DOF.

Runtime Errors:

  • #31070: Raises "invalid parameterization" if DOF is less than zero.

model.tree

{"model.tree.simpleTest": [datum, comparison]}
datumany record D
comparisonany 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.
fieldField name from datum: the enumeration type must include all fields of D in their declaration order.
operatorOne 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).
valueValue to which the field of datum is compared.

Returns:

Returns true if the field of datum <op> value is true, false otherwise, where <op> 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]}
datumany record D
comparisonany 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.
fieldField name from datum: the enumeration type must include all fields of D in their declaration order.
operatorOne 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).
valueValue 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 <op> value, where <op> 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]}
datumany record D
operatorstring
comparisonsarray of any record T
testfunction 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:

datumSimple value to test.
operatorIf "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.
comparisonsArray of records that describe the tests.
testTest 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]}
datumany record D
comparisonsarray of any record T
missingTestfunction 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:

datumSample value to test.
comparisonsArray of records that describe the tests.
missingTestTest 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]}
datumany record D
treeNodeany record T with fields {pass: union of {T, any S}, fail: union of {T, S}}
testfunction 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.
passBranch to follow if test returns true.
failBranch 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]}
datumany record D
treeNodeany record T with fields {pass: union of {T, any S}, fail: union of {T, S}, missing: union of {T, S}}
testfunction 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.
passBranch to follow if test returns true.
failBranch to follow if test returns false.
missingBranch 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]}
datumany record D
treeNodeany 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).
fieldField name from datum: the enumeration type must include all fields of D in their declaration order.
operatorOne 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).
valueValue to which the field of datum is compared.
passBranch to follow if the comparison is successful.
failBranch 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]}
datumarray of double
clustersarray of any record C with fields {center: array of double}
(returns)C
{"model.cluster.closest": [datum, clusters, metric]}
datumany A
clustersarray of any record C with fields {center: any B}
metricfunction of (A, B) → double
(returns)C

Description: Find the cluster C whose center is closest to the datum, according to the metric.

Parameters:

datumSample datum.
clustersSet of clusters; the record type C may contain additional identifying information for post-processing.
metricFunction 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]}
nint
datumarray of double
clustersarray of any record C with fields {center: array of double}
(returns)array of C
{"model.cluster.closestN": [n, datum, clusters, metric]}
nint
datumany A
clustersarray of any record C with fields {center: any B}
metricfunction 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:

nNumber of clusters to search for.
datumSample datum.
clustersSet of clusters; the record type C may contain additional identifying information for post-processing.
metricFunction 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]}
dataarray of array of any A
kint
newClusterfunction 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:

dataSample data.
kNumber of times to call newCluster.
newClusterFunction 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]}
dataarray of array of any A
clustersarray of any record C with fields {center: array of any B}
metricfunction of (array of A, array of B) → double
updatefunction 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:

dataSample data.
clustersSet of clusters; the record type C may contain additional identifying information for post-processing.
metricFunction used to compare each datum with the center of the clusters. (See, for example, metric.euclidean.)
updateFunction 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]}
dataarray of array of double
clusterany record C with fields {center: array of double}
weightdouble
(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]}
pointsarray of array of double
(returns)array of double
{"model.neighbor.mean": [points, weight]}
pointsarray of array of double
weightfunction of (array of double) → double
(returns)array of double

Description: Return the vector-wise mean of points, possibly weighted by weight.

Parameters:

pointsPoints from a codebook, for instance from model.neighbor.nearestK.
weightOptional 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]}
kint
datumarray of double
codebookarray of array of double
(returns)array of array of double
{"model.neighbor.nearestK": [k, datum, codebook, metric]}
kint
datumany A
codebookarray of any B
metricfunction 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:

kNumber of codebook points to attempt to return.
datumSample datum.
codebookSet of training data that is compared to the datum.
metricFunction 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]}
rdouble
datumarray of double
codebookarray of array of double
(returns)array of array of double
{"model.neighbor.ballR": [r, datum, codebook, metric]}
rdouble
datumany A
codebookarray of any B
metricfunction 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:

rMaximum distance (exclusive) of points to return.
datumSample datum.
codebookSet of training data that is compared to the datum.
metricFunction 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]}
datumarray of double
classModelarray of any record A with fields {mean: double, variance: double}
(returns)double
{"model.naive.gaussian": [datum, classModel]}
datummap of double
classModelmap 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]}
datumarray of double
classModelarray of double
(returns)double
{"model.naive.multinomial": [datum, classModel]}
datummap of double
classModelmap of double
(returns)double
{"model.naive.multinomial": [datum, classModel]}
datumarray of double
classModelany record C with fields {values: array of double}
(returns)double
{"model.naive.multinomial": [datum, classModel]}
datummap of double
classModelany record C with fields {values: map of double}
(returns)double

Description: Score datum using a Multinomial Naive Bayes model.

Parameters:

datumVector of independent variables with \(d\) dimensions.
classModelArray 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]}
datumarray of string
classModelmap of double
(returns)double
{"model.naive.bernoulli": [datum, classModel]}
datumarray of string
classModelany record C with fields {values: map of double}
(returns)double

Description: Score datum using a Bernoulli Naive Bayes model.

Parameters:

datumVector of independent variables with \(d\) dimensions. The record form is for histograms built by stat.sample.fillCounter.
classModelArray 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]}
datumarray of double
modelarray of any record M with fields {weights: array of array of double, bias: array of double}
activationfunction of (double) → double
(returns)array of double

Description: Apply a feedforward artificial neural network model to an input datum.

Parameters:

datumLength d vector of independent variables.
modelArray containing the parameters of each layer of the feedforward neural network model.
activationFunction 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]}
datumarray of double
modelany 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}}
kernelfunction 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:

datumLength d vector of independent variables.
modelRecord containing the support vectors, dual space coefficients and constant needed to score new data.
kernelKernel 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.