Stream Evaluator Reference
Stream evaluators are different from stream sources or stream decorators. Both stream sources and stream decorators return streams of tuples. Stream evaluators are more like a traditional function that evaluates its parameters and returns a result. That result can be a single value, array, map or other structure.
Stream evaluators can be nested so that the output of an evaluator becomes the input for another evaluator.
Stream evaluators can be called in different contexts. For example a stream evaluator can be called on its own or it can be called within the context of a streaming expression.
abs
The abs
function will return the absolute value of the provided single parameter.
The abs
function will fail to execute if the value is non-numeric.
If a null value is found then null will be returned as the result.
abs Syntax
The expressions below show the various ways in which you can use the abs
evaluator.
Only one parameter is accepted.
Returns a numeric value.
abs(1) // 1, not really a good use case for it
abs(-1) // 1, not really a good use case for it
abs(add(fieldA,fieldB)) // absolute value of fieldA + fieldB
abs(fieldA) // absolute value of fieldA
add
The add
function will take 2 or more numeric values and add them together.
The add
function will fail to execute if any of the values are non-numeric.
If a null value is found then null will be returned as the result.
add Parameters
-
Field Name | Raw Number | Number Evaluator
-
Field Name | Raw Number | Number Evaluator
-
……
-
Field Name | Raw Number | Number Evaluator
add Syntax
The expressions below show the various ways in which you can use the add
evaluator.
The number and order of these parameters do not matter and is not limited except that at least two parameters are required.
Returns a numeric value.
add(1,2,3,4) // 1 + 2 + 3 + 4 == 10
add(1,fieldA) // 1 + value of fieldA
add(fieldA,1.4) // value of fieldA + 1.4
add(fieldA,fieldB,fieldC) // value of fieldA + value of fieldB + value of fieldC
add(fieldA,div(fieldA,fieldB)) // value of fieldA + (value of fieldA / value of fieldB)
add(fieldA,if(gt(fieldA,fieldB),fieldA,fieldB)) // if fieldA > fieldB then fieldA + fieldA, else fieldA + fieldB
analyze
The analyze
function analyzes text using an available analyzer and returns a list of tokens emitted by the analyzer.
The analyze
function can be called on its own or within the select
and cartesianProduct
streaming expressions.
analyze Parameters
-
Field Name
|Raw Text
: Either the field in a tuple or the raw text to be analyzed. -
Analyzer Field Name
: The field name of the analyzer to use to analyze the text.
analyze Syntax
The expressions below show the various ways in which you can use the analyze
evaluator.
-
Analyze the raw text:
analyze("hello world", analyzerField)
-
Analyze a text field within a
select
expression. This will annotate tuples with the output of the analyzer:select(expr, analyze(textField, analyzerField) as outField)
-
Analyze a text field with a
cartesianProduct
expression. This will stream each token emitted by the analyzer in its own tuple:cartesianProduct(expr, analyze(textField, analyzer) as outField)
and
The and
function will return the logical AND of at least 2 boolean parameters.
The function will fail to execute if any parameters are non-boolean or null.
Returns a boolean value.
and Parameters
-
Field Name | Raw Boolean | Boolean Evaluator
-
Field Name | Raw Boolean | Boolean Evaluator
-
……
-
Field Name | Raw Boolean | Boolean Evaluator
and Syntax
The expressions below show the various ways in which you can use the and
evaluator.
At least two parameters are required, but there is no limit to how many you can use.
and(true,fieldA) // true && fieldA
and(fieldA,fieldB) // fieldA && fieldB
and(or(fieldA,fieldB),fieldC) // (fieldA || fieldB) && fieldC
and(fieldA,fieldB,fieldC,or(fieldD,fieldE),fieldF)
anova
The anova
function calculates the analysis of variance for two or more numeric arrays.
betaDistribution
The betaDistribution
function returns a beta probability distribution based on its parameters.
This function is part of the probability distribution framework and is designed to work with the sample
, kolmogorovSmirnov
and cumulativeProbability
functions.
binomialCoefficient
The binomialCoefficient
function returns a Binomial Coefficient, the number of k-element subsets that can be selected from an n-element set.
binomialDistribution
The binomialDistribution
function returns a binomial probability distribution based on its parameters.
This function is part of the probability distribution framework and is designed to work with the sample
, probability
and cumulativeProbability
functions.
ceil
The ceil
function rounds a decimal value to the next highest whole number.
ceil Syntax
The expressions below show the various ways in which you can use the ceil
evaluator.
ceil(100.4) // returns 101.
ceil(fieldA) // returns the next highest whole number for fieldA.
if(gt(fieldA,fieldB),ceil(fieldA),ceil(fieldB)) // if fieldA > fieldB then return the ceil of fieldA, else return the ceil of fieldB.
constantDistribution
The constantDistribution
function returns a constant probability distribution based on its parameter.
This function is part of the probability distribution framework and is designed to work with the sample
and cumulativeProbability
functions.
When sampled the constant distribution always returns its constant value.
conv
The conv
function returns the convolution of two numeric arrays.
corr
The corr
function returns the correlation of two numeric arrays or the correlation matrix for a matrix.
The corr
function support Pearson’s, Kendall’s and Spearman’s correlations.
corr Positional Parameters
-
numeric array
: The first numeric array -
numeric array
: The second numeric array
OR
-
matrix
: The matrix to compute the correlation matrix for. Note that correlation is computed between thecolumns
in the matrix.
corr Named Parameters
-
type
: (Optional) The type of correlation. Possible values arepearsons
,kendalls
, orspearmans
. The default ispearsons
.
corr Syntax
corr(numericArray1, numericArray2) // Compute the Pearsons correlation for two numeric arrays
corr(numericArray1, numericArray2, type=kendalls) // Compute the Kendalls correlation for two numeric arrays
corr(matrix) // Compute the Pearsons correlation matrix for a matrix
corr(matrix, type=spearmans) // Compute the Spearmans correlation matrix for a matrix
cos
cosineSimilarity
The cosineSimilarity
function returns the cosine similarity of two numeric arrays.
cov
The cov
function returns the covariance of two numeric array or the covariance matrix for matrix.
cov Parameters
-
numeric array
: The first numeric array -
numeric array
: The second numeric array
OR
-
matrix
: The matrix to compute the covariance matrix from. Note that covariance is computed between thecolumns
in the matrix.
cumulativeProbability
The cumulativeProbability
function returns the cumulative probability of a random variable within a probability distribution.
The cumulative probability is the total probability of all random variables less than or equal to a random variable.
derivative
The derivative
function returns the derivative of a function.
The derivative function can compute the derivative of the spline function and the loess function.
The derivative can also take the derivative of a derivative.
diff
The diff
functions performs time series differencing.
Time series differencing is often used to make a time series stationary before further analysis.
distance
The distance
function computes the distance of two numeric arrays or the distance matrix for a matrix.
distance Positional Parameters
-
numeric array
: The first numeric array -
numeric array
: The second numeric array
OR
-
matrix
: The matrix to compute the distance matrix for. Note that distance is computed between thecolumns
in the matrix.
distance Named Parameters
-
type
: (Optional) The distance type. Possible values areeuclidean
,manhattan
,canberra
, orearthMovers
. The default iseuclidean
.
distance Syntax
distance(numericArray1, numericArray2) // Computes the euclidean distance for two numeric arrays.
distance(numericArray1, numericArray2, type=manhattan) // Computes the manhattan distance for two numeric arrays.
distance(matrix) // Computes the euclidean distance matrix for a matrix.
distance(matrix, type=canberra) // Computes the canberra distance matrix for a matrix.
div
The div
function will take two numeric values and divide them.
The function will fail to execute if any of the values are non-numeric or null, or the 2nd value is 0.
Returns a numeric value.
div Parameters
-
Field Name | Raw Number | Number Evaluator
-
Field Name | Raw Number | Number Evaluator
div Syntax
The expressions below show the various ways in which you can use the div
evaluator.
The first value will be divided by the second and as such the second cannot be 0.
div(1,2) // 1 / 2
div(1,fieldA) // 1 / fieldA
div(fieldA,1.4) // fieldA / 1.4
div(fieldA,add(fieldA,fieldB)) // fieldA / (fieldA + fieldB)
dotProduct
The dotProduct
function returns the dotproduct of two numeric arrays.
empiricalDistribution
The empiricalDistribution
function returns empirical distribution function, a continuous probability distribution function based on an actual data set.
This function is part of the probability distribution framework and is designed to work with the sample
, kolmogorovSmirnov
and cumulativeProbability
functions.
This function is designed to work with continuous data.
To build a distribution from
a discrete data set use the enumeratedDistribution
.
enumeratedDistribution
The enumeratedDistribution
function returns a discrete probability distribution function based on an actual data set or a pre-defined set of data and probabilities.
This function is part of the probability distribution framework and is designed to work with the sample
, probability
and cumulativeProbability
functions.
The enumeratedDistribution can be called in two different scenarios:
-
Single array of discrete values. This works like an empirical distribution for discrete data.
-
An array of singleton discrete values and an array of double values representing the probabilities of the discrete values.
This function is designed to work with discrete data.
To build a distribution from a continuous data set use the empiricalDistribution
.
enumeratedDistribution Parameters
-
integer array
: discrete observations or singleton discrete values. -
double array
: (Optional) values representing the probabilities of the singleton discrete values.
enumeratedDistribution Syntax
enumeratedDistribution(integerArray) // This creates an enumerated distribution from the observations in the numeric array.
enumeratedDistribution(array(1,2,3,4), array(.25,.25,.25,.25)) // This creates an enumerated distribution with four discrete values (1,2,3,4) each with a probability of .25.
eor
The eor
function will return the logical exclusive or of at least two boolean parameters.
The function will fail to execute if any parameters are non-boolean or null.
Returns a boolean value.
eor Parameters
-
Field Name | Raw Boolean | Boolean Evaluator
-
Field Name | Raw Boolean | Boolean Evaluator
-
……
-
Field Name | Raw Boolean | Boolean Evaluator
eor Syntax
The expressions below show the various ways in which you can use the eor
evaluator.
At least two parameters are required, but there is no limit to how many you can use.
eor(true,fieldA) // true iff fieldA is false
eor(fieldA,fieldB) // true iff either fieldA or fieldB is true but not both
eor(eq(fieldA,fieldB),eq(fieldC,fieldD)) // true iff either fieldA == fieldB or fieldC == fieldD but not both
eq
The eq
function will return whether all the parameters are equal, as per Java’s standard equals(…)
function.
The function accepts parameters of any type, but will fail to execute if all the parameters are not of the same type.
That is, all are Boolean, all are String, or all are Numeric.
If any parameters are null and there is at least one parameter that is not null then false will be returned.
Returns a boolean value.
expMovingAge
The expMovingAverage
function computes an exponential moving average for a numeric array.
expMovingAge Parameters
-
numeric array
: The array to compute the exponential moving average from. -
integer
: window size
factorial
The factorial
function returns the factorial of its parameter.
floor
The floor
function rounds a decimal value to the next lowest whole number.
floor Syntax
The expressions below show the various ways in which you can use the floor
evaluator.
floor(100.4) // returns 100.
ceil(fieldA) // returns the next lowestt whole number for fieldA.
if(gt(fieldA,fieldB),floor(fieldA),floor(fieldB)) // if fieldA > fieldB then return the floor of fieldA, else return the floor of fieldB.
freqTable
The freqTable
function returns a frequency distribution from an array of discrete values.
This function is designed to work with discrete values.
To work with continuous data use the hist
function.
gammaDistribution
The gammaDistribution
function returns a gamma probability distribution based on its parameters.
This function is part of the probability distribution framework and is designed to work with the sample
, kolmogorovSmirnov
and cumulativeProbability
functions.
geometricDistribution
The geometricDistribution
function returns a geometric probability distribution based on its parameters.
This function is part of the probability distribution framework and is designed to work with the sample, probability and cumulativeProbability functions.
getAttribute
The getAttribute
function returns an attribute from a matrix
by its key.
Any function that returns a matrix
can also set attributes on the matrix
with additional information.
The setAttribute
function can also be used to set attributes on a matrix
.
The key to an attribute is always a string.
The value of attribute can be any object including numerics, arrays, maps, matrixes, etc.
getAttributes
The getAttributes
function returns the attribute map from matrix.
See the getAttribute
function for more details on attributes.
getColumnLabels
The getColumnLabels
function returns the columns labels of a matrix.
The column labels can be optionally set by any function that returns a matrix.
The column labels can also be set via the setColumnLabels
function.
getRowLabels
The getRowLabels
function returns the row labels of a matrix.
The row labels can be optionally set by any function that returns a matrix.
The row labels can also be set via the setRowLabels
function.
getValue
gt
The gt
function will return whether the first parameter is greater than the second parameter.
The function accepts numeric or string parameters, but will fail to execute if all the parameters are not of the same type.
That is, all are String or all are Numeric.
If any parameters are null then an error will be raised.
Returns a boolean value.
gteq
The gteq
function will return whether the first parameter is greater than or equal to the second parameter.
The function accepts numeric and string parameters, but will fail to execute if all the parameters are not of the same type.
That is, all are String or all are Numeric.
If any parameters are null then an error will be raised.
Returns a boolean value.
hist
hsin
if
The if
function works like a standard conditional if/then statement.
If the first parameter is true, then the second parameter will be returned, else the third parameter will be returned.
The function accepts a boolean as the first parameter and anything as the second and third parameters.
An error will occur if the first parameter is not a boolean or is null.
if Parameters
-
Field Name | Raw Value | Boolean Evaluator
-
Field Name | Raw Value | Evaluator
-
Field Name | Raw Value | Evaluator
if Syntax
The expressions below show the various ways in which you can use the if
evaluator.
if(fieldA,fieldB,fieldC) // if fieldA is true then fieldB else fieldC
if(gt(fieldA,5), fieldA, 5) // if fieldA > 5 then fieldA else 5
if(eq(fieldB,null), null, div(fieldA,fieldB)) // if fieldB is null then null else fieldA / fieldB
indexOf
integrate
loess
The leoss
function is a smoothing curve fitter which uses a local regression algorithm.
Unlike the spline function which touches each control point, the loess
function puts a smooth curve through the control points without having to touch the control points.
The loess
result can be used by the derivative function to produce smooth derivatives from data that is not smooth.
loess Positional Parameters
-
numeric array
: (Optional) x values. If omitted a sequence will be created for the x values. -
numeric array
: y values
loess Named Parameters
-
bandwidth
: (Optional) The percent of the data points to use when drawing the local regression line, defaults to .25. Decreasing the bandwidth increases the number of curves that loess can fit. -
robustIterations
: (Optional) The number of iterations used to smooth outliers, defaults to 2.
loess Syntax
loess(yValues) // This creates the xValues automatically and fits a smooth curve through the data points.
loess(xValues, yValues) // This will fit a smooth curve through the data points.
loess(xValues, yValues, bandwidth=.15) // This will fit a smooth curve through the data points using 15 percent of the data points for each local regression line.
log
The log
function will return the natural log of the provided single parameter.
The log
function will fail to execute if the value is non-numeric.
If a null value is found, then null will be returned as the result.
logNormalDistribution
The logNormalDistribution
function returns a log normal probability distribution based on its parameters.
This function is part of the probability distribution framework and is designed to work with the sample
, kolmogorovSmirnov
and cumulativeProbability
functions.
kolmogorovSmirnov
The kolmogorovSmirnov
function performs a Kolmogorov Smirnov test, between a reference continuous probability distribution and a sample set.
The supported distribution functions are: empiricalDistribution
, normalDistribution
, logNormalDistribution
, weibullDistribution
, gammaDistribution
, and betaDistribution
.
kolmogorovSmirnov Parameters
-
continuous probability distribution
: Reference distribution -
numeric array
: sample set
lt
The lt
function will return whether the first parameter is less than the second parameter.
The function accepts numeric or string parameters, but will fail to execute if all the parameters are not of the same type.
That is, all are String or all are Numeric.
If any parameters are null then an error will be raised.
Returns a boolean value.
lteq
The lteq
function will return whether the first parameter is less than or equal to the second parameter.
The function accepts numeric and string parameters, but will fail to execute if all the parameters are not of the same type.
That is, all are String or all are Numeric.
If any parameters are null then an error will be raised.
Returns a boolean value.
markovChain
The markovChain
function can be used to perform Markov Chain simulations.
The markovChain
function takes as its parameter a transition matrix and returns a mathematical model that can be sampled using the sample function.
Each sample taken from the Markov Chain represents the current state of system.
markovChain Syntax
sample(markovChain(transitionMatrix), 5) // This creates a Markov Chain given a specific transition matrix.
The sample function takes 5 samples from the Markov Chain, representing the next five states of the system.
markovChain Returns
Markov Chain model: The Markoff Chain model can be used with sample function.
matrix
The matrix function returns a matrix which can be operated on by functions that support matrix operations.
minMaxScale
The minMaxScale
function scales numeric arrays within a minimum and maximum value.
By default minMaxScale
scales between 0 and 1.
The minMaxScale
function can operate on both numeric arrays and matrices.
When operating on a matrix the minMaxScale
function operates on each row of the matrix.
minMaxScale Parameters
-
numeric array
|matrix
: The array or matrix to scale -
double
: (Optional) The min value. Defaults to 0. -
double
: (Optional) The max value. Defaults to 1.
minMaxScale Syntax
minMaxScale(numericArray) // scale a numeric array between 0 and 1
minMaxScale(numericArray, 0, 100) // scale a numeric array between 1 and 100
minMaxScale(matrix) // Scale each row in a matrix between 0 and 1
minMaxScale(matrix, 0, 100) // Scale each row in a matrix between 0 and 100
mod
The mod
function returns the remainder (modulo) of the first parameter divided by the second parameter.
mod Parameters
-
Field Name | Raw Number | Number Evaluator
: Parameter 1 -
Field Name | Raw Number | Number Evaluator
: Parameter 2
mod Syntax
The expressions below show the various ways in which you can use the mod
evaluator.
mod(100,3) // returns the remainder of 100 / 3 .
mod(100,fieldA) // returns the remainder of 100 divided by the value of fieldA.
mod(fieldA,1.4) // returns the remainder of fieldA divided by 1.4.
if(gt(fieldA,fieldB),mod(fieldA,fieldB),mod(fieldB,fieldA)) // if fieldA > fieldB then return the remainder of fieldA/fieldB, else return the remainder of fieldB/fieldA.
monteCarlo
The monteCarlo
function performs a Monte Carlo simulation based on its parameters.
The monteCarlo
function runs another function a specified number of times and returns the results.
The function being run typically has one or more variables that are drawn from probability distributions on each run.
The sample
function is used in the function to draw the samples.
The simulation’s result array can then be treated as an empirical distribution to understand the probabilities of the simulation results.
monteCarlo Parameters
-
numeric function
: The function being run by the simulation, which must return a numeric value. -
integer
: The number of times to run the function.
monteCarlo Syntax
let(a=uniformIntegerDistribution(1, 6),
b=uniformIntegerDistribution(1, 6),
c=monteCarlo(add(sample(a), sample(b)), 1000))
In the expression above the monteCarlo
function is running the function add(sample(a), sample(b))
1000 times and returning the result.
Each time the function is run samples are drawn from the probability distributions stored in variables a
and b
.
movingAvg
The movingAvg
function calculates a moving average over an array of numbers.
movingMedian
mult
The mult
function will take two or more numeric values and multiply them together.
The mult
function will fail to execute if any of the values are non-numeric.
If a null value is found then null will be returned as the result.
mult Parameters
-
Field Name | Raw Number | Number Evaluator
-
Field Name | Raw Number | Number Evaluator
-
……
-
Field Name | Raw Number | Number Evaluator
mult Syntax
The expressions below show the various ways in which you can use the mult
evaluator.
The number and order of these parameters do not matter and is not limited except that at least two parameters are required.
Returns a numeric value.
mult(1,2,3,4) // 1 * 2 * 3 * 4
mult(1,fieldA) // 1 * value of fieldA
mult(fieldA,1.4) // value of fieldA * 1.4
mult(fieldA,fieldB,fieldC) // value of fieldA * value of fieldB * value of fieldC
mult(fieldA,div(fieldA,fieldB)) // value of fieldA * (value of fieldA / value of fieldB)
mult(fieldA,if(gt(fieldA,fieldB),fieldA,fieldB)) // if fieldA > fieldB then fieldA * fieldA, else fieldA * fieldB
normalDistribution
The normalDistribution
function returns a normal probability distribution
based on its parameters.
This function is part of the probability distribution framework and is designed to work with the sample
, kolmogorovSmirnov
and cumulativeProbability
functions.
normalizeSum
The normalizeSum
function scales numeric arrays so that they sum to 1.
The normalizeSum
function can operate on both numeric arrays and matrices.
When operating on a matrix the normalizeSum
function operates on each row of the matrix.
not
The not
function will return the logical NOT of a single boolean parameter.
The function will fail to execute if the parameter is non-boolean or null.
Returns a boolean value.
olsRegress
The olsRegress
function performs ordinary least squares, multivariate, linear regression.
The olsRegress
function returns a single tuple containing the regression model with estimated regression parameters, RSquared and regression diagnostics.
The output of olsRegress
can be used with the predict function to predict values based on the regression model.
olsRegress Parameters
-
matrix
: The regressor observation matrix. Each row in the matrix represents a single multi-variate regressor observation. Note that there is no need to add an initial unitary column (column of 1’s) when specifying a model including an intercept term, this column will be added automatically. -
numeric array
: The outcomes array which matches up with each row in the regressor observation matrix.
or
The or
function will return the logical OR of at least 2 boolean parameters.
The function will fail to execute if any parameters are non-boolean or null.
Returns a boolean value.
or Parameters
-
Field Name | Raw Boolean | Boolean Evaluator
-
Field Name | Raw Boolean | Boolean Evaluator
-
……
-
Field Name | Raw Boolean | Boolean Evaluator
or Syntax
The expressions below show the various ways in which you can use the or
evaluator.
At least two parameters are required, but there is no limit to how many you can use.
or(true,fieldA) // true || fieldA
or(fieldA,fieldB) // fieldA || fieldB
or(and(fieldA,fieldB),fieldC) // (fieldA && fieldB) || fieldC
or(fieldA,fieldB,fieldC,and(fieldD,fieldE),fieldF)
poissonDistribution
The poissonDistribution
function returns a poisson probability distribution
based on its parameter.
This function is part of the probability distribution framework and is designed to work with the sample
, probability
and cumulativeProbability
functions.
polyFit
The polyFit
function performs polynomial curve fitting.
polyFit Parameters
-
numeric array
: (Optional) x values. If omitted a sequence will be created for the x values. -
numeric array
: y values -
integer
: (Optional) polynomial degree. Defaults to 3.
polyFit Syntax
polyFit(yValues) // This creates the xValues automatically and fits a curve through the data points using the default 3 degree polynomial.
polyFit(yValues, 5) // This creates the xValues automatically and fits a curve through the data points using a 5 degree polynomial.
polyFit(xValues, yValues, 5) // This will fit a curve through the data points using a 5 degree polynomial.
pow
The pow
function returns the value of its first parameter raised to the power of its second parameter.
pow Parameters
-
Field Name
|Raw Number
|Number Evaluator
: Parameter 1 -
Field Name
|Raw Number
|Number Evaluator
: Parameter 2
pow Syntax
The expressions below show the various ways in which you can use the pow
evaluator.
pow(2,3) // returns 2 raised to the 3rd power.
pow(4,fieldA) // returns 4 raised by the value of fieldA.
pow(fieldA,1.4) // returns the value of fieldA raised by 1.4.
if(gt(fieldA,fieldB),pow(fieldA,fieldB),pow(fieldB,fieldA)) // if fieldA > fieldB then raise fieldA by fieldB, else raise fieldB by fieldA.
predict
The predict
function predicts the value of dependent variables based on regression models or functions.
The predict
function can predict values based on the output of the following functions: spline, loess, regress, olsRegress.
predict Parameters
-
regression model
|function
: The model or function used for the prediction -
number
|numeric array
|matrix
: Depending on the regression model or function used, the predictor variable can be a number, numeric array or matrix.
predict Syntax
predict(regressModel, number) // predict using the output of the <<regress>> function and single numeric predictor. This will return a single numeric prediction.
predict(regressModel, numericArray) // predict using the output of the <<regress>> function and a numeric array of predictors. This will return a numeric array of predictions.
predict(splineFunc, number) // predict using the output of the <<spline>> function and single numeric predictor. This will return a single numeric prediction.
predict(splineFunc, numericArray) // predict using the output of the <<spline>> function and a numeric array of predictors. This will return a numeric array of predictions.
predict(olsRegressModel, numericArray) // predict using the output of the <<olsRegress>> function and a numeric array containing one multi-variate predictor. This will return a single numeric prediction.
predict(olsRegressModel, matrix) // predict using the output of the <<olsRegress>> function and a matrix containing rows of multi-variate predictor arrays. This will return a numeric array of predictions.
primes
probability
The probability
function returns the probability of a random variable within a probability distribution.
The probability
function computes the probability between random variable ranges for both continuous and
discrete probability distributions.
The probability
function can compute probabilities for a specific random variable for
discrete probability distributions only.
The supported continuous distribution functions are: normalDistribution, logNormalDistribution, betaDistribution, gammaDistribution, empiricalDistribution, triangularDistribution, weibullDistribution, uniformDistribution, constantDistribution
The supported discreet distributions are: poissonDistribution, binomialDistribution, enumeratedDistribution, zipFDistribution, geometricDistribution, uniformIntegerDistribution
probability Parameters
-
probability distribution
: the probability distribution to compute the probability from. -
number
: low value of the range. -
number
: (Optional for discrete probability distributions) high value of the range. If the high range is omitted then the probability function will compute a probability for the low range value.
probability Syntax
probability(poissonDistribution(10), 7) // Returns the probability of a random sample of 7 in a poisson distribution with a mean of 10.
probability(normalDistribution(10, 2), 7.5, 8.5) // Returns the probability between the range of 7.5 to 8.5 for a normal distribution with a mean of 10 and standard deviation of 2.
raw
The raw
function will return whatever raw value is the parameter.
This is useful for cases where you want to use a string as part of another evaluator.
raw Syntax
The expressions below show the various ways in which you can use the raw
evaluator.
Whatever is inside will be returned as-is.
Internal evaluators are considered strings and are not evaluated.
raw(foo) // "foo"
raw(count(*)) // "count(*)"
raw(45) // 45
raw(true) // "true" (note: this returns the string "true" and not the boolean true)
eq(raw(fieldA), fieldA) // true if the value of fieldA equals the string "fieldA"
regress
The regress
function performs a simple regression of two numeric arrays.
The result of this expression is also used by the predict
function.
round
sample
The sample
function can be used to draw random samples from a probability distribution or Markov Chain.
sample Parameters
-
probability distribution
|Markov Chain
: The distribution or Markov Chain to sample. -
integer
: (Optional) Sample size. Defaults to 1.
sample Returns
Either a single numeric random sample, or a numeric array depending on the sample size parameter.
sample Syntax
sample(poissonDistribution(5)) // Returns a single random sample from a poissonDistribution with mean of 5.
sample(poissonDistribution(5), 1000) // Returns 1000 random samples from poissonDistribution with a mean of 5.
sample(markovChain(transitionMatrix), 1000) // Returns 1000 random samples from a Markov Chain.
scalarAdd
The scalarAdd
function adds a scalar value to every value in a numeric array or matrix.
When working with numeric arrays, scalarAdd
returns a new array with the new values.
When working with a matrix, scalarAdd
returns a new matrix with new values.
scalarAdd Parameters
number
: value to add
numeric array
| matrix
: the numeric array or matrix to add the value to.
scalarDivide
The scalarDivide
function divides each number in numeric array or matrix by a scalar value.
When working with numeric arrays, scalarDivide
returns a new array with the new values.
When working with a matrix, scalarDivide
returns a new matrix with new values.
scalarDivide Parameters
number
: value to divide by
numeric array
| matrix
: the numeric array or matrix to divide by the value to.
scalarMultiply
The scalarMultiply
function multiplies each element in a numeric array or matrix by a
scalar value.
When working with numeric arrays, scalarMultiply
returns a new array with the new values.
When working with a matrix, scalarMultiply
returns a new matrix with new values.
scalarMultiply Parameters
number
: value to divide by
numeric array
| matrix
: the numeric array or matrix to divide by the value to.
scalarSubtract
The scalarSubtract
function subtracts a scalar value from every value in a numeric array or matrix.
When working with numeric arrays, scalarSubtract
returns a new array with the new values.
When working with a matrix, scalarSubtract
returns a new matrix with new values.
scalarSubtract Parameters
number
: value to add
numeric array
| matrix
: the numeric array or matrix to subtract the value from.
setColumnLabels
spline
The spline
function performs a cubic spline interpolation (https://en.wikiversity.org/wiki/Cubic_Spline_Interpolation) of a curve given a set of x,y coordinates.
The return value of the spline function is an interpolation function which can be used to predict values along the curve and generate a derivative of
the curve.
spline Parameters
-
numeric array
: (Optional) x values. If omitted a sequence will be created for the x values. -
numeric array
: y values
sub
The sub
function will take 2 or more numeric values and subtract them, from left to right.
The sub
function will fail to execute if any of the values are non-numeric.
If a null value is found then null
will be returned as the result.
sub Parameters
-
Field Name | Raw Number | Number Evaluator
-
Field Name | Raw Number | Number Evaluator
-
……
-
Field Name | Raw Number | Number Evaluator
sub Syntax
The expressions below show the various ways in which you can use the sub
evaluator.
The number of these parameters does not matter and is not limited except that at least two parameters are required.
Returns a numeric value.
sub(1,2,3,4) // 1 - 2 - 3 - 4
sub(1,fieldA) // 1 - value of fieldA
sub(fieldA,1.4) // value of fieldA - 1.4
sub(fieldA,fieldB,fieldC) // value of fieldA - value of fieldB - value of fieldC
sub(fieldA,div(fieldA,fieldB)) // value of fieldA - (value of fieldA / value of fieldB)
if(gt(fieldA,fieldB),sub(fieldA,fieldB),sub(fieldB,fieldA)) // if fieldA > fieldB then fieldA - fieldB, else fieldB - field
transpose
The transpose
function transposes a matrix.
triangularDistribution
The triangularDistribution
function returns a triangular probability distribution based on its parameters.
This function is part of the probability distribution framework and is designed to work with the sample
, probability
and cumulativeProbability
functions.
uniformDistribution
The uniformDistribution
function returns a continuous uniform probability distribution
based on its parameters.
See the uniformIntegerDistribution
to work with discrete uniform distributions.
This function is part of the probability distribution framework and is designed to work with the sample
and cumulativeProbability
functions.
uniformIntegerDistribution
The uniformIntegerDistribution
function returns a discrete uniform probability distribution
based on its parameters.
See the uniformDistribution
to work with continuous uniform distributions.
This function is part of the probability distribution framework and is designed to work with the sample
, probability
and cumulativeProbability
functions.
unitize
The unitize
function scales numeric arrays to a magnitude of 1, often called unit vectors.
The unitize function can operate on both numeric arrays and matrices.
When operating on a matrix the unitize function unitizes each row of the matrix.
weibullDistribution
The weibullDistribution
function returns a Weibull probability distribution
based on its parameters.
This function is part of the probability distribution framework and is designed to work with the sample
, kolmogorovSmirnov
and cumulativeProbability
functions.
zipFDistribution
The zipFDistribution
function returns a ZipF distribution
based on its parameters.
This function is part of the probability distribution framework and is designed to work with the sample
, probability
and cumulativeProbability
functions.