Last change
on this file since 98 was
98,
checked in by Peter, 19 years ago
|
tScore added
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
902 bytes
|
Line | |
---|
1 | // $Id: tScore.cc 98 2004-06-10 15:24:05Z peter $ |
---|
2 | |
---|
3 | // System includes |
---|
4 | #include <cmath> |
---|
5 | |
---|
6 | // Thep C++ Tools |
---|
7 | #include "tScore.h" |
---|
8 | #include "vector.h" |
---|
9 | #include "Averager.h" |
---|
10 | |
---|
11 | namespace theplu { |
---|
12 | namespace cpptools { |
---|
13 | |
---|
14 | tScore::tScore( const gslapi::vector& target, |
---|
15 | const gslapi::vector& value) |
---|
16 | : Score(), value_(value), target_(target) |
---|
17 | |
---|
18 | { |
---|
19 | } |
---|
20 | |
---|
21 | double tScore::score() |
---|
22 | { |
---|
23 | Averager positive; |
---|
24 | Averager negative; |
---|
25 | for(size_t i=0; i<target_.size(); i++){ |
---|
26 | if (target_[i]==1) |
---|
27 | positive.add(value_[i]); |
---|
28 | else |
---|
29 | negative.add(value_[i]); |
---|
30 | } |
---|
31 | double diff = positive.mean() - negative.mean(); |
---|
32 | double s=sqrt((positive.sum_xsqr()+negative.sum_xsqr()) |
---|
33 | /(positive.n()-1+negative.n()-1)); |
---|
34 | return diff/s; |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | double tScore::p_value(void) |
---|
39 | { |
---|
40 | double t = score(); |
---|
41 | double dof = target_.size()-2; |
---|
42 | double p = gsl_cdf_tdist_Q(t, dof); |
---|
43 | return dof > 0 ? p : 1; |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | }} // of namespace cpptools and namespace theplu |
---|
Note: See
TracBrowser
for help on using the repository browser.