X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Ft-test.q;h=ba7e9388a95274560589d30605ce2be3e0720718;hb=46a7a7b189e2df740043496c16d9f7c665b7a828;hp=c69a6cdb5bc5adb552afedbc209030d6ada3b12b;hpb=8801412c9d32e74bdf21aee0bb3b29f8e877acef;p=pspp diff --git a/src/language/stats/t-test.q b/src/language/stats/t-test.q index c69a6cdb5b..ba7e9388a9 100644 --- a/src/language/stats/t-test.q +++ b/src/language/stats/t-test.q @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2009 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 @@ -1432,9 +1432,13 @@ pscbox (const struct dictionary *dict) double df = pairs[i].n -2; + /* corr2 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(). */ + double corr2 = MIN (1.0, pow2 (pairs[i].correlation)); double correlation_t = pairs[i].correlation * sqrt (df) / - sqrt (1 - pow2 (pairs[i].correlation)); + sqrt (1 - corr2); /* row headings */