line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Statistics::DependantTTest; |
2
|
1
|
|
|
1
|
|
31287
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
3
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
102
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
49
|
|
5
|
1
|
|
|
1
|
|
848
|
use Statistics::PointEstimation; |
|
1
|
|
|
|
|
58469
|
|
|
1
|
|
|
|
|
44
|
|
6
|
1
|
|
|
1
|
|
13
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
885
|
|
7
|
|
|
|
|
|
|
$VERSION='0.03'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
############## |
10
|
|
|
|
|
|
|
sub new |
11
|
|
|
|
|
|
|
{ |
12
|
1
|
|
|
1
|
0
|
14
|
my $proto = shift; |
13
|
1
|
|
33
|
|
|
8
|
my $class = ref($proto) || $proto; |
14
|
1
|
|
|
|
|
4
|
my $self= {}; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
3
|
$self->{sample_data} = undef; |
17
|
1
|
|
|
|
|
3
|
$self->{s} = undef; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
4
|
bless($self,$class); |
22
|
1
|
|
|
|
|
8
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
############## |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
############## |
27
|
|
|
|
|
|
|
sub load_data { |
28
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
29
|
2
|
|
|
|
|
5
|
my $sample_name = shift; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
9
|
my (@sample_data)=@_; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
14
|
my $s= new Statistics::PointEstimation; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
258
|
$s->add_data(\@sample_data); |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
836
|
$self->{sample_data}->{$sample_name}=\@sample_data; |
38
|
2
|
|
|
|
|
6
|
$self->{s}->{$sample_name}=$s; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
8
|
return $self; |
41
|
|
|
|
|
|
|
} # end sub load_data |
42
|
|
|
|
|
|
|
############## |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
############## |
45
|
|
|
|
|
|
|
sub perform_t_test { |
46
|
1
|
|
|
1
|
0
|
2
|
my $self=shift; |
47
|
1
|
|
|
|
|
3
|
my $first_sample_name = shift; |
48
|
1
|
|
|
|
|
2
|
my $second_sample_name = shift; |
49
|
1
|
|
|
|
|
4
|
my $s1=$self->{s}->{$first_sample_name}; |
50
|
1
|
|
|
|
|
4
|
my $s2=$self->{s}->{$second_sample_name}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
1
|
50
|
|
|
|
2
|
if(@{$self->{sample_data}->{$first_sample_name}} != @{$self->{sample_data}->{$second_sample_name}}) |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
|
|
0
|
croak "The two results sets are of different length.\n For the paired T-test, the two results must be from two identical sets of subjects tested in a reference and test condition.\n"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
5
|
my $s = new Statistics::PointEstimation; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
198
|
my @sample_difference; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
2
|
my $count=0; |
63
|
1
|
|
|
|
|
3
|
while ($count < @{$self->{sample_data}->{$first_sample_name}}) |
|
6
|
|
|
|
|
21
|
|
64
|
|
|
|
|
|
|
{ |
65
|
5
|
|
|
|
|
7
|
$sample_difference[$count] = ${$self->{sample_data}->{$first_sample_name}}[$count] - ${$self->{sample_data}->{$second_sample_name}}[$count]; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
12
|
|
66
|
5
|
|
|
|
|
9
|
$count++; |
67
|
|
|
|
|
|
|
} # end while |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
18
|
$s->add_data(\@sample_difference); |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
304
|
my $t_value = $s->t_statistic(); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
26
|
my $deg_freedom = scalar @{$self->{sample_data}->{$first_sample_name}} - 1; |
|
1
|
|
|
|
|
5
|
|
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
20
|
return ($t_value, $deg_freedom ); |
76
|
|
|
|
|
|
|
} # end sub perform_t_test |
77
|
|
|
|
|
|
|
############## |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
__END__ |