Search code examples
iccube

How does Sum Square aggregation work and how to use it for the calculation of the Standard Deviation in icCube


One of the aggregation types in icCube is "Sum Square".

I thought it would calculate the sum of squares as defined in the link, but I get different results.

What exactly is the Sum Square aggregation and how can I use it to calculate the standard deviation in icCube?


Solution

  • You can check how the algo to calculate the Variance and Standard Deviation in this wikipedia article.

    You need count number of rows (n), sum of the rows (Sum) and the sum of squares (SumSq) :

    Var = (SumSq − (Sum × Sum) / n) / (n − 1)
    

    The Std Dev is the root of the variance (sqrt).