Custom Aggregate Functions
Descriptions and examples of custom CGE aggregate functions.
CGE supports the following custom aggregate functions:
- variance
- standard deviation
- geometric mean
- mode
- median
| Function | Purpose |
|---|---|
| variance | Returns the variance of an expression. |
| standard deviation | Calculates the standard deviation of a set of numeric values. Requires at least two values. |
| geometric mean | Calculates the nth root of the product of the numbers, where n is the count of numbers. |
| mode | Returns the most frequently occurring number in a group of supplied arguments. |
| median | Calculate the median, which is the value separating the higher half of a data sample, a population, or a probability distribution, from the lower half. |
Examples
- variance
SELECT ?p (AGG<http://www.dotnetrdf.org/leviathan#variance>(?o) AS ?RESULT) WHERE { ?s ?p ?o} GROUP BY ?p - geometric mean
SELECT ?p (AGG<http://www.dotnetrdf.org/leviathan#geometric_mean>(?o) AS ?RESULT) WHERE { ?s ?p ?o} GROUP BY ?p - standard deviation
SELECT ?p (AGG<http://www.dotnetrdf.org/leviathan#standard_deviation>(?o) AS ?RESULT) WHERE { ?s ?p ?o} GROUP BY ?p - mode
SELECT ?p (AGG<http://www.dotnetrdf.org/leviathan#mode>(?o) AS ?RESULT) WHERE { ?s ?p ?o} GROUP BY ?p - median
SELECT ?p (AGG<http://www.dotnetrdf.org/leviathan#median>(?o) AS ?RESULT) WHERE { ?s ?p ?o} GROUP BY ?p
- SUM
- MIN
- MAX
- SAMPLE
- AVG
- GROUPCONCAT
SELECT ?p
(AGG<http://www.dotnetrdf.org/leviathan#variance>(?o) AS ?RESULT1)
(SUM (?o) AS ?RESULT2)
(AGG<http://www.dotnetrdf.org/leviathan#median>(?o) AS ?RESULT3)CAUTION: The DISTINCT flavors of custom aggregates are currently not supported.