Variance - ObjectVision/GeoDMS GitHub Wiki
Aggregation functions variance
- var(a)
- var(a, relation)
- var(a) results in a parameter with the variance of the non null values of attribute a.
- var(a, relation) results in an attribute with the variance of the non null values of attribute a, grouped by relation. The domain unit of the resulting attribute is the values unit of the relation].
The variance is calculated as the square of the sum of the differences of each value and the mean value of the distribution. This square is divided by the number of values (n).
This way of calculating the variance is different from e.g. the ms Excel VAR function, which divides the sum of the differences by n-1.
- attribute a with Numeric value type
- relation with value type of the group CanBeDomainUnit
- The value type of argument a and the resulting data item must match.
- The domain of arguments a and relation must match.
- Without relation: O(n) where n = number of elements in the domain of a. Single pass calculating sum of values and sum of squared values.
- With relation: O(n) where n = number of elements in the domain of a. Accumulates sums per group during a single pass.
1. parameter<float32> varNrInh := var(float32(City/NrInhabitants)); result = 24166.67
2. attribute<float32> varNrInhRegion (Region) := var(float32(City/NrInhabitants), City/Region_rel);
| City/NrInhabitants | City/Region_rel |
|---|---|
| 550 | 0 |
| 525 | 1 |
| 300 | 2 |
| 500 | 1 |
| 200 | 3 |
| 175 | null |
| null | 3 |
domain City, nr of rows = 7
| varNrInhRegion |
|---|
| 0 |
| 156.25 |
| 0 |
| 0 |
| null |
domain Region, nr of rows = 5