-
Notifications
You must be signed in to change notification settings - Fork 1
- sd(values_attribute)
- sd(values_attribute, relation)
The sd function calculates the standard deviation of the values in values_attribute.
When called with a single argument, it calculates the total standard deviation across all elements.
When called with a relation argument, it calculates the standard deviation per group defined by the relation, producing a partitioned result.
The standard deviation is calculated as the square root of the variance:
sd = √(Σ(x - μ)² / n)
where μ is the mean and n is the count of defined values.
Note: This calculates the population standard deviation. For sample standard deviation (dividing by n-1 under the square root), use: sd(x) * sqrt(count(x) / (count(x) - 1)).
- attribute values_attribute with a numeric value type (Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64)
- attribute relation (optional) with a relation to the grouping domain
- The values_attribute must have a numeric value type.
- If specified, relation must define a valid grouping.
- Null values in values_attribute are excluded from the calculation.
- Without relation: a parameter with Float64 value type
- With relation: an attribute with Float64 value type and the domain of the relation's values unit
| aspect | indication |
|---|---|
| time complexity | O(n) where n = number of elements |
| memory | O(1) for total, O(k) for partitioned where k = number of groups |
| parallelization | tiled parallel processing supported |
The calculation uses a numerically stable two-pass algorithm (first for mean, second for variance, then square root).
1.0
unit<uint32> Person: nrofrows = 5
{
attribute<float32> age: [25, 30, 35, 40, 45];
}
parameter<float64> age_stddev := sd(Person/age);
// Result: 7.071... (≈ √50)
unit<uint32> Person: nrofrows = 6
{
attribute<float32> salary: [50000, 55000, 60000, 45000, 48000, 52000];
attribute<Region> region_rel: [0, 0, 0, 1, 1, 1];
}
unit<uint32> Region: nrofrows = 2;
attribute<float64> salary_sd_per_region (Region) := sd(Person/salary, Person/region_rel);
// Result: [4082.48, 2867.44] (standard deviation per region)
- var - variance (square of standard deviation)
- [standard deviance(sd)|standard deviance(sd)] - alternative documentation page
- mean - arithmetic mean
- covariance - covariance between two attributes
GeoDMS ©Object Vision BV. Source code distributed under GNU GPL-3. Documentation distributed under CC BY-SA 4.0.
GeoDMS ©Object Vision BV. Source code distributed under GNU GPL-3. Documentation distributed under CC BY-SA 4.0.