Re: Add min and max execute statement time in pg_stat_statement - Mailing list pgsql-hackers

From Arne Scheffer
Subject Re: Add min and max execute statement time in pg_stat_statement
Date
Msg-id permail-20150121142703fe5316b60000277f-scheffa@message-id.uni-muenster.de
Whole thread Raw
In response to Re: Add min and max execute statement time in pg_stat_statement  (Arne Scheffer <arne.scheffer@uni-muenster.de>)
Responses Re: Add min and max execute statement time in pg_stat_statement
List pgsql-hackers
Sorry, corrected second try because of copy&paste mistakes:
VlG-Arne

> Comments appreciated.

> Definition var_samp = Sum of squared differences /n-1
> Definition stddev_samp = sqrt(var_samp)

> Example N=4

> 1.) Sum of squared differences
>   1_4Sum(Xi-XM4)²
> =
> 2.) adding nothing
>   1_4Sum(Xi-XM4)²
>  +0
>  +0
>  +0
> =
> 3.) nothing changed
>  1_4Sum(Xi-XM4)²
>  +(-1_3Sum(Xi-XM3)²+1_3Sum(Xi-XM3)²)
>  +(-1_2Sum(Xi-XM2)²+1_2Sum(Xi-XM2)²)
>  +(-1_1Sum(Xi-XM1)²+1_1Sum(Xi-XM1)²)

> =
> 4.) parts reordered
>   (1_4Sum(Xi-XM4)²-1_3Sum(Xi-XM3)²)
>  +(1_3Sum(Xi-XM3)²-1_2Sum(Xi-XM2)²)
>  +(1_2Sum(Xi-XM2)²-1_1Sum(Xi-XM1)²)
>  +1_1Sum(X1-XM1)²
> =
> 5.)
>   (X4-XM4)(X4-XM3)
> + (X3-XM3)(X3-XM2)
> + (X2-XM2)(X2-XM1)
> + (X1-XM1)²
> =
> 6.) XM1=X1 => There it is - The iteration part of Welfords Algorithm
> (in
> reverse order)
>   (X4-XM4)(X4-XM3)
> + (X3-XM3)(X3-XM2)
> + (X2-XM2)(X2-X1)
> + 0

> The missing piece is 4.) to 5.)
> it's algebra, look at e.g.:
> http://jonisalonen.com/2013/deriving-welfords-method-for-computing-variance/





pgsql-hackers by date:

Previous
From: Arne Scheffer
Date:
Subject: Re: Add min and max execute statement time in pg_stat_statement
Next
From: Andrew Dunstan
Date:
Subject: Re: Add min and max execute statement time in pg_stat_statement