Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bbf4fdc

Browse filesBrowse files
author
Neil Conway
committed
Prevent corr() from returning the wrong results for negative correlation
values. The previous coding essentially assumed that x = sqrt(x*x), which does not hold for x < 0. Thanks to Jie Zhang at Greenplum and Gavin Sherry for reporting this issue.
1 parent 4893ead commit bbf4fdc
Copy full SHA for bbf4fdc

File tree

1 file changed

+2
-3
lines changed
Filter options

1 file changed

+2
-3
lines changed

‎src/backend/utils/adt/float.c

Copy file name to clipboardExpand all lines: src/backend/utils/adt/float.c
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.150 2007/06/05 21:31:06 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.151 2007/09/19 22:31:48 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2274,8 +2274,7 @@ float8_corr(PG_FUNCTION_ARGS)
22742274
if (numeratorX <= 0 || numeratorY <= 0)
22752275
PG_RETURN_NULL();
22762276

2277-
PG_RETURN_FLOAT8(sqrt((numeratorXY * numeratorXY) /
2278-
(numeratorX * numeratorY)));
2277+
PG_RETURN_FLOAT8(numeratorXY / sqrt(numeratorX * numeratorY));
22792278
}
22802279

22812280
Datum

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.