Covariance

Aggregation functions co-variance

syntax

  • cov(a, b)
  • cov(a, b, relation)

definition

  • cov(a, b) results in a parameter with the co-variance of attributes a and b.
  • cov(a, b, relation) results in an attribute with the co-variance of attributes a and b, grouped by relation. The Domain unit of the resulting attribute is the Values unit of the relation.

The Value type of the resulting Data item is float32 or float64.

applies to

  • attribute a and b with Numeric value type
  • relation with value type of the group CanBeDomainUnit

conditions

  1. The value type of the arguments a and b must match.
  2. The domain of arguments a, b and relation must match.

Since GeoDMS 20.23.1 condition 2 is also checked for cov(a, b) without relation, as it already was with one: a configuration that pairs attributes of two different domain units now stops with an error. Before, b was read element by element along a, beyond its end when its domain was smaller, and the result was meaningless. The same holds for Correlation and Modus_weighted.

example

1. parameter<float32> covNrInhabitantsTemp                := 
   cov(float32(City/NrInhabitants), City/avgDailyTemperature); result = -156.25
2. attribute<float32> covNrInhabitantsTempRegion (Region) :=
   cov(
       float32(City/NrInhabitants)
     , City/avgDailyTemperature
     , City/RegionNr
  );
City/NrInhabitants City/avgDailyTemperature City/Region_rel
550 12 0
525 11 1
300 null 2
500 11 1
200 14 3
175 null null
null 14 3

domain City, nr of rows = 7

covNrInhabitantsTempRegion
0
0
null
0
null

domain Region, nr of rows = 5