postgresql weighted average?
Posted
by milovanderlinden
on Stack Overflow
See other posts from Stack Overflow
or by milovanderlinden
Published on 2010-05-29T08:41:56Z
Indexed on
2010/05/29
8:52 UTC
Read the original article
Hit count: 343
say I have a postgresql table with the following values:
id | value
----------
1 | 4
2 | 8
3 | 100
4 | 5
5 | 7
If I use postgresql to calculate the average, it gives me an average of 24.8 because the high value of 100 has great impact on the calculation. While in fact I would like to find an average somewhere around 6 and eliminate the extreme(s).
I am looking for a way to eliminate extremes and want to do this "statistically correct". The extreme's cannot be fixed. I cannot say; If a value is over X, it has to be eliminated.
I have been bending my head on the postgresql aggregate functions but cannot put my finger on what is right for me to use. Any suggestions?
© Stack Overflow or respective owner