abanalyzer 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,6 +48,14 @@ You can get the actual p-value for either a Chi-Square test for independence or
48
48
  puts tester.gtest_p
49
49
 
50
50
 
51
+ You can additionally get the actual score for either a Chi-Square test for independence or a G-Test for independence.
52
+
53
+ ...
54
+ tester = ABAnalyzer::ABTest.new values
55
+ puts tester.chisquare_score
56
+ puts tester.gtest_score
57
+
58
+
51
59
  == Running Tests
52
60
  Testing can be run by using:
53
61
  rake test
@@ -12,25 +12,33 @@ module ABAnalyzer
12
12
  def different?(sig=0.05)
13
13
  gtest_p < sig
14
14
  end
15
-
16
- def chisquare_p
17
- sum = 0
15
+
16
+ def chisquare_score
17
+ sum=0
18
18
  @values.each_cell { |colname, rowname, value|
19
19
  ex = expected(colname, rowname)
20
20
  test_sufficient_data(colname, rowname, ex, value)
21
21
  sum += ((value - ex) ** 2) / ex
22
22
  }
23
- 1 - Statistics2.chi2dist(df, sum)
23
+ return sum
24
24
  end
25
-
26
- def gtest_p
27
- sum = 0
25
+
26
+ def gtest_score
27
+ sum=0
28
28
  @values.each_cell { |colname, rowname, value|
29
29
  ex = expected(colname, rowname)
30
30
  test_sufficient_data(colname, rowname, ex, value)
31
31
  sum += value * Math.log(value / ex)
32
32
  }
33
- 1 - Statistics2.chi2dist(df, 2*sum)
33
+ return sum
34
+ end
35
+
36
+ def chisquare_p
37
+ 1 - Statistics2.chi2dist(df, self.chisquare_score)
38
+ end
39
+
40
+ def gtest_p
41
+ 1 - Statistics2.chi2dist(df, 2*self.gtest_score)
34
42
  end
35
43
 
36
44
  private
@@ -1,3 +1,3 @@
1
1
  module ABAnalyzer
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abanalyzer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Muller
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-29 00:00:00 -04:00
18
+ date: 2011-04-21 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency