rth_element
- Details
- Last Updated on Friday, 18 January 2013 21:55
syntax
- rth_element(a, b)
- rth_element(a, b, partioning)
defintion
- rth_element(a, b) results in a parameter with the b * nth element of the ascending sorted data item a (n = number of elements).
- rth_element(a, b, partioning) results in an attribute the b * nth elements of the ascending sorted data item a, grouped by the partioning attribute (n = number of elements). The domain unit of the resulting attribute is the values unit of the partioning attribute.
description
If attribute a has an even number of elements, item b * n does not refer to a unique value. In these cases the mean of the two nearest values is calculated.
If for argument b the value 0.5 is chosen, the function results in the median of attribute a.
applies to
attribute a with value types:
- group: Numeric
- uint2
- uint4
- bool
parameter b with value type:
- float32
conditions
Attributes a, b and partioning need to match with regard to their domain unit (for this reason the const function is used in the second expression).since version
5.61
example
1.parameter<uint32> rth_elementNrInh: expr =
"rth_element(City/NrInhabitants, float32(0.5))";
result = 400
2.attribute<float32> rth_elementNrInhRegion (RegionDomain):
expr =
"rth_element("
" City/NrInhabitants"
",const(float32(0.5), City)"
",City/RegionNr"
")";
| City/NrInhabitants | City/RegionNr |
| 550 | 0 |
| 525 | 1 |
| 300 | 2 |
| 500 | 1 |
| 200 | 3 |
| 175 | null |
| null | 3 |
| rth_elementNrInhRegion |
| 550 |
| 512 |
| 300 |
| 200 |
| null |