agora inbox for pgsql-bugs@postgresql.org  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: o15611@gmail.com
Subject: BUG #19340: Wrong result from CORR() function
Date: Tue, 02 Dec 2025 07:57:35 +0000
Message-ID: <19340-6fb9f6637f562092@postgresql.org> (raw)

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.



view thread (24+ messages)  latest in thread

Message-ID: <19340-6fb9f6637f562092@postgresql.org>
Permalink:  ../19340-6fb9f6637f562092@postgresql.org/
Also on:    postgresql.org/message-id/19340-6fb9f6637f562092@postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, o15611@gmail.com
  Subject: Re: BUG #19340: Wrong result from CORR() function
  In-Reply-To: <19340-6fb9f6637f562092@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox