postgresql/src
Dean Rasheed e954a727f0 Improve the accuracy of floating point statistical aggregates.
When computing statistical aggregates like variance, the common
schoolbook algorithm which computes the sum of the squares of the
values and subtracts the square of the mean can lead to a large loss
of precision when using floating point arithmetic, because the
difference between the two terms is often very small relative to the
terms themselves.

To avoid this, re-work these aggregates to use the Youngs-Cramer
algorithm, which is a proven, numerically stable algorithm that
directly aggregates the sum of the squares of the differences of the
values from the mean in a single pass over the data.

While at it, improve the test coverage to test the aggregate combine
functions used during parallel aggregation.

Per report and suggested algorithm from Erich Schubert.

Patch by me, reviewed by Madeleine Thompson.

Discussion: https://postgr.es/m/153313051300.1397.9594490737341194671@wrigleys.postgresql.org
2018-10-06 11:20:09 +01:00
..
backend Improve the accuracy of floating point statistical aggregates. 2018-10-06 11:20:09 +01:00
bin Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:29 -04:00
common Add application_name to connection authorized msg 2018-09-28 19:04:50 -04:00
fe_utils Fix lexing of standard multi-character operators in edge cases. 2018-08-23 21:42:40 +01:00
include Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:29 -04:00
interfaces Tweak MSVC build system to match changes in 7143b3e82. 2018-09-28 15:17:07 -04:00
makefiles Refactor installation of extension headers. 2018-09-07 14:19:14 +01:00
pl Ensure that PLPGSQL_DTYPE_ROW variables have valid refname fields. 2018-10-05 12:45:37 -04:00
port Replace uint64 use introduced in 4868e44685 in light of 595a0eab7f. 2018-10-03 13:28:14 -07:00
template Make some fixes to allow building Postgres on macOS 10.14 ("Mojave"). 2018-09-25 13:23:29 -04:00
test Improve the accuracy of floating point statistical aggregates. 2018-10-06 11:20:09 +01:00
timezone Update time zone data files to tzdata release 2018e. 2018-05-09 13:56:22 -04:00
tools Tweak MSVC build system to match changes in 7143b3e82. 2018-09-28 15:49:05 -04:00
tutorial Deduplicate "invalid input syntax" messages for various types. 2018-07-22 14:58:01 -07:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Build src/common files as a library with -fPIC. 2018-09-28 14:28:19 -04:00
Makefile.shlib Don't build static libraries on Cygwin 2018-10-02 16:46:57 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00