Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To use these functions, the Probabilistic Feature is required.

The probabilistic feature provides arbitrary functions to work with discrete and continuous probabilistic values random variables in a data stream and provides algebraic operator (+, *, -, /) to perform probabilistic addition, subtraction, multiplication, division, and exponentiation.

Code Block
languagesql
titleExample
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75]) + ToProbabilisticDouble([4.0,0.25;5.0,0.75]) FROM Stream
=> (6.0:0.0625;7.0:0.375;8.0:0.5625)
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75]) - ToProbabilisticDouble([4.0,0.25;5.0,0.75]) FROM Stream
=> (-3.0:0.1875;-2.0:0.625;-1.0:0.1875)
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75]) * ToProbabilisticDouble([4.0,0.25;5.0,0.75]) FROM Stream
=> (15.0:0.5625;12.0:0.1875;10.0:0.1875;8.0:0.0625)
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75]) / ToProbabilisticDouble([4.0,0.25;5.0,0.75]) FROM Stream
=> (0.75:0.1875;0.6:0.5625;0.5:0.0625;0.4:0.1875)
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75])^2 FROM Stream
=> (4.0:0.25;9.0:0.75)
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75]) + 2 FROM Stream
=> (4.0:0.25;5.0:0.75)
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75]) - 2 FROM Stream
=> (0.0:0.25;1.0:0.75)
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75]) * 2 FROM Stream
=> (6.0:0.75;4.0:0.25)
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75]) / 2 FROM Stream
=> (1.5:0.75;1.0:0.25)

SQRT(Probabilistic Number)

Computes the probabilistic square root of the given probabilistic value.

sMIn(Probabilistic Number, Probabilistic Number)

Computes the minimum of two probabilistic values.

sMax(Probabilistic Number, Probabilistic Number)

Computes the maximum of two probabilistic values.

ToProbabilisticDouble(Matrix)

Constructs a discrete probabilistic value using the first column of the given matrix for the values and the second column of the matrix for the probabilities for each value.

Code Block
languagesql
titleToProbabilisticDouble Example
SELECT ToProbabilisticDouble([2.0,0.25;3.0,0.75]) FROM Stream
=> (3.0:0.75;2.0:0.25)

DoubleToByte(Probabilistic Number)

Converts the given probabilistic double value to a probabilistic byte value

DoubleToShort(Probabilistic Number)

Converts the given probabilistic double value to a probabilistic short value

DoubleToInteger(Probabilistic Number)

Converts the given probabilistic double value to a probabilistic integer value

DoubleToLong(Probabilistic Value)

Converts the given probabilistic double value to a probabilistic long value

DoubleToFloat(Probabilistic Number)

Converts the given probabilistic double value to a probabilistic float value

...

Int(<ProbabilisticDouble x, Number a, Number b>|<Vector xyz, Vector a, Vector b>)

Estimates the multivariate normal distribution probability with lower and upper integration limit.

as2DVector(

...

ProbabilisticDouble x, ProbabilisticDouble y)

Converts the two object into a 2D vector.

as3DVector(

...

ProbabilisticDouble x, ProbabilisticDouble y, ProbabilisticDouble z)

Similar to the as2DVector function, this function creates a 3D vector with the given objects.

Similarity(

...

ProbabilisticDouble p1, ProbabilisticDouble p2)

Calculates the Bhattacharyya distance between two distributions.

Code Block
languagejavascriptcql
titleExample
SELECT similarity(as2DVector(x1,y1), as2DVector(x2,y2)) FROM stream

Distance(

...

<ProbabilisticDouble p, Number x>|<Vector p, Vector x>)

Calculates the Mahalanobis distance between the distribution and the value. The value can be a scalar value or a vector.

Code Block
languagejavascriptcql
titleExample
SELECT distance(as3DVector(x, y, z), [1.0;2.0;3.0]) FROM stream

KL(<ProbabilisticDouble p1, ProbabilisticDouble p2>|<Vector p1, Vector p2>)

Calculates the Kullback-Leibler divergence of the two given probability distributions.

Code Block
languagecql
titleExample
SELECT kl(as3DVector(x, y, z), as3DVector(a, b, c)) FROM stream

LogLikelihood(Vector points, ProbabilisticDouble p)

Calculates the log Likelihood between the given points and the probability distribution.

Code Block
languagecql
titleExample
SELECT loglikelihood([1.0;2.0;3.0], x) FROM stream