[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: t-test gets NaN instead of 0 for significance on x86-64
From: |
John Darrington |
Subject: |
Re: t-test gets NaN instead of 0 for significance on x86-64 |
Date: |
Sat, 5 Sep 2009 00:23:51 +0800 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
It looks good to me now. (I haven't tested it).
J'
On Fri, Sep 04, 2009 at 09:06:47AM -0700, Ben Pfaff wrote:
John Darrington <address@hidden> writes:
> On Thu, Sep 03, 2009 at 08:10:31PM -0700, Ben Pfaff wrote:
> John Darrington <address@hidden> writes:
>
> > As a short term solution, the best I can suggest is that we
> > clamp pow2(correlation) to 1.0.
>
> Thanks. I pushed out this stopgap fix.
>
> Isn't there still a problem when pairs[i].correlation is less than
> -1 ? For example -1.00000001
You are right, of course.
Could you check that this re-fix looks correct?
commit 46912334775c83a23902bd5c7d72cd4ad8d23c95
Author: Ben Pfaff <address@hidden>
Date: Fri Sep 4 09:05:08 2009 -0700
T-TEST: Also fix the case where the correlation is slightly less than
-1.0.
Thanks to John Darrington for pointing out the omission.
diff --git a/src/language/stats/t-test.q b/src/language/stats/t-test.q
index dd40de9..ba7e938 100644
*** a/src/language/stats/t-test.q
--- b/src/language/stats/t-test.q
***************
*** 1432,1447 ****
double df = pairs[i].n -2;
! /* pairs[i].correlation is a correlation, so mathematically it will
! always be in the range [-1.0, 1.0]. Inaccurate calculations
sometimes
! cause it to be slightly greater than 1.0, however, which makes
the
! sqrt() below to come out as NaN instead of 0. So force it to
be 1.0
! or less. */
! double corr = MIN (1.0, pairs[i].correlation);
!
double correlation_t =
pairs[i].correlation * sqrt (df) /
! sqrt (1 - pow2 (corr));
/* row headings */
--- 1432,1444 ----
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 - corr2);
/* row headings */
--
Ben Pfaff
http://benpfaff.org
_______________________________________________
pspp-dev mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/pspp-dev
--
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.
signature.asc
Description: Digital signature