projects
/
users
/
bernd
/
postgres.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a3d3b40
)
Prevent corr() from returning the wrong results for negative correlation
author
Neil Conway
<neilc@samurai.com>
Wed, 19 Sep 2007 22:31:51 +0000
(22:31 +0000)
committer
Neil Conway
<neilc@samurai.com>
Wed, 19 Sep 2007 22:31:51 +0000
(22:31 +0000)
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.
src/backend/utils/adt/float.c
patch
|
blob
|
blame
|
history
diff --git
a/src/backend/utils/adt/float.c
b/src/backend/utils/adt/float.c
index 9b734c0ec681e0e130126cf89dd23b5cfc233eeb..0782fdceb45fcf9573f9dc9732998ed1a9f5882e 100644
(file)
--- a/
src/backend/utils/adt/float.c
+++ b/
src/backend/utils/adt/float.c
@@
-2274,8
+2274,7
@@
float8_corr(PG_FUNCTION_ARGS)
if (numeratorX <= 0 || numeratorY <= 0)
PG_RETURN_NULL();
- PG_RETURN_FLOAT8(sqrt((numeratorXY * numeratorXY) /
- (numeratorX * numeratorY)));
+ PG_RETURN_FLOAT8(numeratorXY / sqrt(numeratorX * numeratorY));
}
Datum