Scalesum
rescale-functions scalesum
syntax
- scalesum(proxy, a)
- scalesum(proxy, relation, a)
definition
- scalesum(proxy, a) disaggregates the values of parameter a, according to the distribution of the proxy attribute. The function results in a new attribute with the values-unit of argument a and the domain-unit of argument proxy.
- scalesum(proxy, relation, a) disaggregates the values of attribute a, according to the distribution of the proxy attribute, grouped by relation. The function results in a new attribute with the values unit of argument a and the domain unit of arguments proxy and relation.
description
To avoid rounding off errors within the scalesum calculation, use a float32 of float64 value-type for arguments proxy and a.
The sum of the result will equal the given quantity a, provided that the quantity can be related to any element of the disaggregated domain with a positive proxy value.
To avoid loosing parts of the quantity, check that for each partition the total proxy value is positive (unless the quantity is zero).
conditions
- The domain units of arguments proxy and relation must match.
- The value type of arguments proxy and a must match.
example
1. attribute<float32> ssum_NrInh (CityDomain) :=
scalesum(
City/Area // proxy variable for distribution
,550f // amount to be distributed
);
2. attribute<uint32> ssum_NrInh_per_region (CityDomain) :=
uint32(
scalesum(
City/Area
,City/Region_rel // relation from city to region
,float32(Region/NrInhabitants)
)
);
City/Area | City/NrInhabitants | City/Region_rel | ssum_NrInh | ssum_NrInh_per_region |
---|---|---|---|---|
2 | 550 | 0 | 120.55 | 550 |
0 | 525 | 1 | 100.69 | 531 |
1 | 300 | 2 | 49.31 | 300 |
0 | 500 | 1 | 89.04 | 493 |
1 | 200 | 3 | 27.40 | 111 |
1 | 175 | null | null | null |
null | null | 3 | null | 88 |
domain City, nr of rows = 7
Region/NrInhabitants |
---|
550 |
1025 |
300 |
200 |
0 |
domain Region, nr of rows = 5