mariadb/BitKeeper/etc
unknown 82bd9b6b61 Bug#22555: STDDEV yields positive result for groups with only one row
When only one row was present, the subtraction of nearly the same number 
resulted in catastropic cancellation, introducing an error in the 
VARIANCE calculation near 1e-15.  That was sqrt()ed to get STDDEV, the 
error was escallated to near 1e-8.  

The simple fix of testing for a row count of 1 and forcing that to yield 
0.0 is insufficient, as two rows of the same value should also have a
variance of 0.0, yet the error would be about the same.

So, this patch changes the formula that computes the VARIANCE to be one
that is not subject to catastrophic cancellation.

In addition, it now uses only (faster-than-decimal) floating point numbers
to calculate, and renders that to other types on demand.


mysql-test/r/func_group.result:
  Test that the bug is fixed, and that no unexpected behavior arises from the 
  changes.
mysql-test/t/func_group.test:
  Test that the bug is fixed, and that no unexpected behavior arises from the 
  changes.
sql/item_sum.cc:
  Serg's suggestion: Force all VARIANCE calculations to be done with floating-
  point types.  It's faster, and the SQL standard says we may implement these
  functions any way we want.
  
  Additionally, use a form of variance calculation that is not subject to 
  catastrophic cancellation.   
  http://static.flickr.com/108/311308512_5c4e1c0c3d_b.jpg
sql/item_sum.h:
  Remove unused members and add a comment describing the recurrence relation.
2006-12-22 15:37:37 -05:00
..
collapsed Bug#22555: STDDEV yields positive result for groups with only one row 2006-12-22 15:37:37 -05:00
config Speed up "bk citool" for msvensson: 2006-09-08 11:25:08 +02:00
gone Merge bk-internal.mysql.com:/data0/bk/mysql-4.1 2005-05-24 00:31:28 +02:00
logging_ok merge 2005-06-14 00:05:27 +02:00
notify notify BitKeeper file /home/bk/mysql/BitKeeper/etc/notify 2000-08-02 01:45:37 +02:00
RESYNC_TREE Merge mysql.com:/home/alexi/dev/mysql-4.1-0 2005-09-06 23:49:54 +04:00
skipkeys BK automatic LOD removal. 2002-11-07 11:20:17 +04:00