BUG #19340: Wrong result from CORR() function - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19340: Wrong result from CORR() function
Date
Msg-id 19340-6fb9f6637f562092@postgresql.org
Whole thread Raw
Responses Re: BUG #19340: Wrong result from CORR() function
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      19340
Logged by:          Oleg Ivanov
Email address:      o15611@gmail.com
PostgreSQL version: 18.1
Operating system:   all
Description:

postgres=# SELECT corr( 0.09 , 0.09000001 ) FROM generate_series(1,24) ;
 corr
------

(1 row)

postgres=# SELECT corr( 0.09 , 0.09000001 ) FROM generate_series(1,25) ;
        corr
---------------------
 -0.1877294297321991
(1 row)

postgres=# SELECT corr( 0.09 , 0.09000001 ) FROM generate_series(1,31) ;
         corr
----------------------
 -0.03366532289960463
(1 row)

postgres=# SELECT corr( 0.09 , 0.09000001 ) FROM generate_series(1,32) ;
         corr
----------------------
 0.037939234274452456
(1 row)

Another example:

postgres=# SELECT corr( 0.9 , 0.91 ) FROM generate_series(1,36) ;
 corr
------

(1 row)

postgres=# SELECT corr( 0.9 , 0.91 ) FROM generate_series(1,37) ;
        corr
---------------------
 0.37167954745944803
(1 row)

postgres=# SELECT corr( 0.9 , 0.91 ) FROM generate_series(1,113) ;
         corr
----------------------
 0.022884787550167176
(1 row)

postgres=# SELECT corr( 0.9 , 0.91 ) FROM generate_series(1,114) ;
         corr
-----------------------
 -0.004981175111303341
(1 row)

In the Oracle Database:
SQL> select corr( 0.09 , 0.09000001 ) FROM (select rownum as id from dual
connect by level <=330);

CORR(0.09,0.09000001)
---------------------

If argument is the constant, function CORR() must give a 0 or NaN.
Consequences of this bug: statistic functions are used to make business
descision. Wrong and completely different results can lead to make mistakes.


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19339: odbc_fdw extension, Not able to read data from foreign tables
Next
From: PG Bug reporting form
Date:
Subject: BUG #19341: REPLACE() fails to match final character when using nondeterministic ICU collation