logo-header

 
 

rth_element

 syntax

  • rth_element(a, b
  • rth_element(a, b, partioning)

 defintion

  1. rth_element(a, b) results in a parameter with the b * nth element of the ascending sorted data item a (n = number of elements).
  2. 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.
The values unit of the resulting data item should match with regard to value type and metric with the values unit of attribute a.

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
Table CityDomain, nr of rows = 7

rth_elementNrInhRegion
550
512
300
200
null
Table RegionDomain, nr of rows = 5

see also


OBJECT VISION BV
Vrije Universiteit
De Boelelaan 1085
1081 HV Amsterdam
The Netherlands

tel: +31 (0)20 598 9083
fax:+31 (0)20 598 9904



Recent Wiki Changes