projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bug in ROC parsing long string variables
[pspp-builds.git]
/
src
/
math
/
correlation.c
diff --git
a/src/math/correlation.c
b/src/math/correlation.c
index 303b48bcfaccb89098fabaa426f628d50323a2a3..47762747340974f815207389fb48b71a59bf3605 100644
(file)
--- a/
src/math/correlation.c
+++ b/
src/math/correlation.c
@@
-29,7
+29,12
@@
double
significance_of_correlation (double rho, double w)
{
double t = w - 2;
significance_of_correlation (double rho, double w)
{
double t = w - 2;
+
+ /* |rho| will mathematically always be in the range [0, 1.0]. Inaccurate
+ calculations sometimes cause it to be slightly greater than 1.0, so
+ force it into the correct range to avoid NaN from sqrt(). */
t /= 1 - MIN (1, pow2 (rho));
t /= 1 - MIN (1, pow2 (rho));
+
t = sqrt (t);
t *= rho;
t = sqrt (t);
t *= rho;