projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ONEWAY: Fix printf format specifier.
[pspp]
/
src
/
math
/
correlation.c
diff --git
a/src/math/correlation.c
b/src/math/correlation.c
index 303b48bcfaccb89098fabaa426f628d50323a2a3..e7ebd1f52dbc94ac8469af1c23b68eefe715547d 100644
(file)
--- a/
src/math/correlation.c
+++ b/
src/math/correlation.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009
, 2011
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-16,20
+16,27
@@
#include <config.h>
#include <config.h>
-#include "correlation.h"
+#include "
math/
correlation.h"
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_cdf.h>
#include <math.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_cdf.h>
#include <math.h>
-#include <libpspp/misc.h>
-#include "minmax.h"
+
+#include "libpspp/misc.h"
+
+#include "gl/minmax.h"
double
significance_of_correlation (double rho, double w)
{
double t = w - 2;
double
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;