abanalyzer 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +7 -0
- data/README.rdoc +4 -6
- data/Rakefile +7 -10
- data/abanalyzer.gemspec +20 -0
- data/lib/abanalyzer/version.rb +1 -1
- data/test/abtest_test.rb +34 -0
- data/test/helper.rb +6 -0
- data/test/matrix_test.rb +21 -0
- metadata +60 -44
- data/Gemfile.lock +0 -16
- data/docs/ABAnalyzer.html +0 -336
- data/docs/ABAnalyzer/ABTest.html +0 -559
- data/docs/ABAnalyzer/InsufficientDataError.html +0 -152
- data/docs/ABAnalyzer/Matrix.html +0 -547
- data/docs/ABAnalyzer/MatrixFormatError.html +0 -152
- data/docs/README_rdoc.html +0 -237
- data/docs/created.rid +0 -8
- data/docs/index.html +0 -108
- data/docs/lib/abanalyzer/abtest_rb.html +0 -54
- data/docs/lib/abanalyzer/exceptions_rb.html +0 -52
- data/docs/lib/abanalyzer/matrix_rb.html +0 -52
- data/docs/lib/abanalyzer/sample_rb.html +0 -54
- data/docs/lib/abanalyzer/version_rb.html +0 -52
- data/docs/lib/abanalyzer_rb.html +0 -62
- data/docs/rdoc.css +0 -706
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f300363efbaf45233112dd30f6092192dcda30d9
|
4
|
+
data.tar.gz: 3ac739cdcac5e47cc38a1a1009591f023c95a36b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e5d78e898a261f4cb50a3db03431fc262428718e17e2b6922b9fecd71fbed9ed38b6be7a8ec307c831a7930fd2bb5ac3d4620f0fa8779257860ade9aa1fb2965
|
7
|
+
data.tar.gz: e8daaacde12cdc610de4726889678f077527ee73d9f0137fcb8aa359d91915b65d9bf86203baf267c51bfe40dfe0de368feb43511b1905fa0b29013eedff5d2f
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/README.rdoc
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
= ABAnalyzer
|
2
|
+
{<img src="https://secure.travis-ci.org/bmuller/abanalyzer.png?branch=master" alt="Build Status" />}[https://travis-ci.org/bmuller/abanalyzer]
|
3
|
+
{<img src="https://gemnasium.com/bmuller/abanalyzer.png" alt="Dependency Status" />}[https://gemnasium.com/bmuller/abanalyzer]
|
2
4
|
|
3
|
-
ABAnalyzer is a Ruby library that will perform testing to determine if there is a statistical difference in categorical data (typically called an A/B Test). By default, it uses a G-Test for independence, but a Chi-Square test for independence can also be used.
|
4
|
-
* http://en.wikipedia.org/wiki/G-test
|
5
|
-
* http://en.wikipedia.org/wiki/Pearson%27s_chi-square_test
|
5
|
+
ABAnalyzer is a Ruby library that will perform testing to determine if there is a statistical difference in categorical data (typically called an A/B Test). By default, it uses a {G-Test for independence}[http://en.wikipedia.org/wiki/G-test], but a {Chi-Square test for independence}[http://en.wikipedia.org/wiki/Pearson%27s_chi-square_test] can also be used.
|
6
6
|
|
7
7
|
== Installation
|
8
8
|
Simply run:
|
@@ -11,7 +11,6 @@ Simply run:
|
|
11
11
|
== Basic Usage
|
12
12
|
The simplest test (which uses a gtest):
|
13
13
|
|
14
|
-
require 'rubygems'
|
15
14
|
require 'abanalyzer'
|
16
15
|
|
17
16
|
values = {}
|
@@ -26,7 +25,6 @@ The simplest test (which uses a gtest):
|
|
26
25
|
== Multiple Categories
|
27
26
|
You can use the ABAnalyzer module to test for differences in more than two categories. For instance, to test accross three:
|
28
27
|
|
29
|
-
require 'rubygems'
|
30
28
|
require 'abanalyzer'
|
31
29
|
|
32
30
|
values = {}
|
@@ -86,4 +84,4 @@ This means (roughly) that if you ran this experiment over and over, 95% of the t
|
|
86
84
|
|
87
85
|
== Running Tests
|
88
86
|
Testing can be run by using:
|
89
|
-
rake
|
87
|
+
bundle exec rake
|
data/Rakefile
CHANGED
@@ -1,11 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require 'bundler'
|
3
|
-
require 'rake/testtask'
|
1
|
+
require 'bundler/gem_tasks'
|
4
2
|
require 'rdoc/task'
|
5
3
|
|
6
|
-
Bundler::GemHelper.install_tasks
|
7
|
-
|
8
|
-
desc "Create documentation"
|
9
4
|
RDoc::Task.new("doc") { |rdoc|
|
10
5
|
rdoc.title = "ABAnalyzer - A/B test analysis library for Ruby"
|
11
6
|
rdoc.rdoc_dir = 'docs'
|
@@ -13,9 +8,11 @@ RDoc::Task.new("doc") { |rdoc|
|
|
13
8
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
14
9
|
}
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
require 'rake/testtask'
|
12
|
+
|
13
|
+
Rake::TestTask.new do |t|
|
19
14
|
t.test_files = FileList['test/*_test.rb']
|
20
15
|
t.verbose = true
|
21
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => :test
|
data/abanalyzer.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "abanalyzer/version"
|
3
|
+
require "date"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "abanalyzer"
|
7
|
+
s.version = ABAnalyzer::VERSION
|
8
|
+
s.authors = ["Brian Muller"]
|
9
|
+
s.date = Date.today.to_s
|
10
|
+
s.description = "A/B test analysis library for Ruby"
|
11
|
+
s.summary = "A/B test analysis library for Ruby"
|
12
|
+
s.email = "bamuller@gmail.com"
|
13
|
+
s.files = `git ls-files`.split($/)
|
14
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
15
|
+
s.homepage = "https://github.com/bmuller/abanalyzer"
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.add_development_dependency("rake")
|
18
|
+
s.add_development_dependency("rdoc")
|
19
|
+
s.add_dependency('statistics2', '>= 0.54')
|
20
|
+
end
|
data/lib/abanalyzer/version.rb
CHANGED
data/test/abtest_test.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
class ABTestTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@values = { :rep => { :male => 200, :female => 250 }, :dem => { :male => 150, :female => 300}, :ind => { :male => 50, :female => 50 }}
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_test_creation
|
9
|
+
assert_raise ABAnalyzer::InsufficientDataError do
|
10
|
+
m = ABAnalyzer::ABTest.new({ :one => { :a => 10, :b => 20 }, :two => { :a => 5, :b => 0 } })
|
11
|
+
p = m.gtest_p
|
12
|
+
end
|
13
|
+
|
14
|
+
assert_raise ABAnalyzer::InsufficientDataError do
|
15
|
+
m = ABAnalyzer::ABTest.new({ :one => { :a => 10, :b => 20 }, :two => { :a => 5, :b => -6 } })
|
16
|
+
p = m.gtest_p
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_raise ABAnalyzer::InsufficientDataError do
|
20
|
+
m = ABAnalyzer::ABTest.new({ :one => { :a => 1, :b => 1 }, :two => { :a => 1, :b => 1 } })
|
21
|
+
p = m.gtest_p
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_results
|
26
|
+
abt = ABAnalyzer::ABTest.new @values
|
27
|
+
|
28
|
+
chisquare = 1 - Statistics2.chi2dist(2, 16.2037037037037)
|
29
|
+
assert_equal abt.chisquare_p, chisquare
|
30
|
+
|
31
|
+
gtest = 1 - Statistics2.chi2dist(2, 2*8.13286375180066)
|
32
|
+
assert_equal abt.gtest_p, gtest
|
33
|
+
end
|
34
|
+
end
|
data/test/helper.rb
ADDED
data/test/matrix_test.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
class MatrixTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@values = { :rep => { :male => 200, :female => 250 }, :dem => { :male => 150, :female => 300}, :ind => { :male => 50, :female => 50 }}
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_matrix_creation
|
9
|
+
assert_raise ABAnalyzer::MatrixFormatError do
|
10
|
+
ABAnalyzer::Matrix.new({ :one => { :a => 10, :b => 20 }, :two => { :a => 5 } })
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_matrix_functions
|
15
|
+
m = ABAnalyzer::Matrix.new @values
|
16
|
+
assert_equal m.get(:rep, :male), 200
|
17
|
+
assert_equal m.column_sum(:rep), 450
|
18
|
+
assert_equal m.row_sum(:male), 400
|
19
|
+
assert_equal m.total_sum, 1000
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,87 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abanalyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brian Muller
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-06-28 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
14
41
|
- !ruby/object:Gem::Dependency
|
15
42
|
name: statistics2
|
16
|
-
requirement:
|
17
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
18
44
|
requirements:
|
19
|
-
- -
|
45
|
+
- - '>='
|
20
46
|
- !ruby/object:Gem::Version
|
21
47
|
version: '0.54'
|
22
48
|
type: :runtime
|
23
49
|
prerelease: false
|
24
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.54'
|
25
55
|
description: A/B test analysis library for Ruby
|
26
|
-
email:
|
56
|
+
email: bamuller@gmail.com
|
27
57
|
executables: []
|
28
58
|
extensions: []
|
29
59
|
extra_rdoc_files: []
|
30
60
|
files:
|
61
|
+
- .gitignore
|
62
|
+
- .travis.yml
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE
|
65
|
+
- README.rdoc
|
66
|
+
- Rakefile
|
67
|
+
- abanalyzer.gemspec
|
68
|
+
- lib/abanalyzer.rb
|
31
69
|
- lib/abanalyzer/abtest.rb
|
32
70
|
- lib/abanalyzer/exceptions.rb
|
33
71
|
- lib/abanalyzer/matrix.rb
|
34
72
|
- lib/abanalyzer/sample.rb
|
35
73
|
- lib/abanalyzer/version.rb
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
|
40
|
-
- Rakefile
|
41
|
-
- README.rdoc
|
42
|
-
- docs/ABAnalyzer/ABTest.html
|
43
|
-
- docs/ABAnalyzer/InsufficientDataError.html
|
44
|
-
- docs/ABAnalyzer/Matrix.html
|
45
|
-
- docs/ABAnalyzer/MatrixFormatError.html
|
46
|
-
- docs/ABAnalyzer.html
|
47
|
-
- docs/created.rid
|
48
|
-
- docs/index.html
|
49
|
-
- docs/lib/abanalyzer/abtest_rb.html
|
50
|
-
- docs/lib/abanalyzer/exceptions_rb.html
|
51
|
-
- docs/lib/abanalyzer/matrix_rb.html
|
52
|
-
- docs/lib/abanalyzer/sample_rb.html
|
53
|
-
- docs/lib/abanalyzer/version_rb.html
|
54
|
-
- docs/lib/abanalyzer_rb.html
|
55
|
-
- docs/rdoc.css
|
56
|
-
- docs/README_rdoc.html
|
57
|
-
homepage: https://github.com/livingsocial/abanalyzer
|
74
|
+
- test/abtest_test.rb
|
75
|
+
- test/helper.rb
|
76
|
+
- test/matrix_test.rb
|
77
|
+
homepage: https://github.com/bmuller/abanalyzer
|
58
78
|
licenses: []
|
79
|
+
metadata: {}
|
59
80
|
post_install_message:
|
60
81
|
rdoc_options: []
|
61
82
|
require_paths:
|
62
83
|
- lib
|
63
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
85
|
requirements:
|
66
|
-
- -
|
86
|
+
- - '>='
|
67
87
|
- !ruby/object:Gem::Version
|
68
88
|
version: '0'
|
69
|
-
segments:
|
70
|
-
- 0
|
71
|
-
hash: -4408374484081118835
|
72
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
90
|
requirements:
|
75
|
-
- -
|
91
|
+
- - '>='
|
76
92
|
- !ruby/object:Gem::Version
|
77
93
|
version: '0'
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
hash: -4408374484081118835
|
81
94
|
requirements: []
|
82
|
-
rubyforge_project:
|
83
|
-
rubygems_version:
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.2
|
84
97
|
signing_key:
|
85
|
-
specification_version:
|
98
|
+
specification_version: 4
|
86
99
|
summary: A/B test analysis library for Ruby
|
87
|
-
test_files:
|
100
|
+
test_files:
|
101
|
+
- test/abtest_test.rb
|
102
|
+
- test/helper.rb
|
103
|
+
- test/matrix_test.rb
|
data/Gemfile.lock
DELETED
data/docs/ABAnalyzer.html
DELETED
@@ -1,336 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
-
<head>
|
6
|
-
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
-
|
8
|
-
<title>Module: ABAnalyzer</title>
|
9
|
-
|
10
|
-
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
-
|
12
|
-
<script src="./js/jquery.js" type="text/javascript"
|
13
|
-
charset="utf-8"></script>
|
14
|
-
<script src="./js/thickbox-compressed.js" type="text/javascript"
|
15
|
-
charset="utf-8"></script>
|
16
|
-
<script src="./js/quicksearch.js" type="text/javascript"
|
17
|
-
charset="utf-8"></script>
|
18
|
-
<script src="./js/darkfish.js" type="text/javascript"
|
19
|
-
charset="utf-8"></script>
|
20
|
-
|
21
|
-
</head>
|
22
|
-
<body class="module">
|
23
|
-
|
24
|
-
<div id="metadata">
|
25
|
-
<div id="home-metadata">
|
26
|
-
<div id="home-section" class="section">
|
27
|
-
<h3 class="section-header">
|
28
|
-
<a href="./index.html">Home</a>
|
29
|
-
<a href="./index.html#classes">Classes</a>
|
30
|
-
<a href="./index.html#methods">Methods</a>
|
31
|
-
</h3>
|
32
|
-
</div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="file-metadata">
|
36
|
-
<div id="file-list-section" class="section">
|
37
|
-
<h3 class="section-header">In Files</h3>
|
38
|
-
<div class="section-body">
|
39
|
-
<ul>
|
40
|
-
|
41
|
-
<li><a href="./lib/abanalyzer/abtest_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
-
class="thickbox" title="lib/abanalyzer/abtest.rb">lib/abanalyzer/abtest.rb</a></li>
|
43
|
-
|
44
|
-
<li><a href="./lib/abanalyzer/exceptions_rb.html?TB_iframe=true&height=550&width=785"
|
45
|
-
class="thickbox" title="lib/abanalyzer/exceptions.rb">lib/abanalyzer/exceptions.rb</a></li>
|
46
|
-
|
47
|
-
<li><a href="./lib/abanalyzer/matrix_rb.html?TB_iframe=true&height=550&width=785"
|
48
|
-
class="thickbox" title="lib/abanalyzer/matrix.rb">lib/abanalyzer/matrix.rb</a></li>
|
49
|
-
|
50
|
-
<li><a href="./lib/abanalyzer/sample_rb.html?TB_iframe=true&height=550&width=785"
|
51
|
-
class="thickbox" title="lib/abanalyzer/sample.rb">lib/abanalyzer/sample.rb</a></li>
|
52
|
-
|
53
|
-
<li><a href="./lib/abanalyzer/version_rb.html?TB_iframe=true&height=550&width=785"
|
54
|
-
class="thickbox" title="lib/abanalyzer/version.rb">lib/abanalyzer/version.rb</a></li>
|
55
|
-
|
56
|
-
</ul>
|
57
|
-
</div>
|
58
|
-
</div>
|
59
|
-
|
60
|
-
|
61
|
-
</div>
|
62
|
-
|
63
|
-
<div id="class-metadata">
|
64
|
-
|
65
|
-
<!-- Parent Class -->
|
66
|
-
|
67
|
-
|
68
|
-
<!-- Namespace Contents -->
|
69
|
-
|
70
|
-
<div id="namespace-list-section" class="section">
|
71
|
-
<h3 class="section-header">Namespace</h3>
|
72
|
-
<ul class="link-list">
|
73
|
-
|
74
|
-
<li><span class="type">CLASS</span> <a href="ABAnalyzer/ABTest.html">ABAnalyzer::ABTest</a></li>
|
75
|
-
|
76
|
-
<li><span class="type">CLASS</span> <a href="ABAnalyzer/InsufficientDataError.html">ABAnalyzer::InsufficientDataError</a></li>
|
77
|
-
|
78
|
-
<li><span class="type">CLASS</span> <a href="ABAnalyzer/Matrix.html">ABAnalyzer::Matrix</a></li>
|
79
|
-
|
80
|
-
<li><span class="type">CLASS</span> <a href="ABAnalyzer/MatrixFormatError.html">ABAnalyzer::MatrixFormatError</a></li>
|
81
|
-
|
82
|
-
</ul>
|
83
|
-
</div>
|
84
|
-
|
85
|
-
|
86
|
-
<!-- Method Quickref -->
|
87
|
-
|
88
|
-
<div id="method-list-section" class="section">
|
89
|
-
<h3 class="section-header">Methods</h3>
|
90
|
-
<ul class="link-list">
|
91
|
-
|
92
|
-
<li><a href="#method-c-calculate_size">::calculate_size</a></li>
|
93
|
-
|
94
|
-
<li><a href="#method-c-confidence_interval">::confidence_interval</a></li>
|
95
|
-
|
96
|
-
<li><a href="#method-c-relative_confidence_interval">::relative_confidence_interval</a></li>
|
97
|
-
|
98
|
-
</ul>
|
99
|
-
</div>
|
100
|
-
|
101
|
-
|
102
|
-
<!-- Included Modules -->
|
103
|
-
|
104
|
-
</div>
|
105
|
-
|
106
|
-
<div id="project-metadata">
|
107
|
-
|
108
|
-
|
109
|
-
<div id="fileindex-section" class="section project-section">
|
110
|
-
<h3 class="section-header">Files</h3>
|
111
|
-
<ul>
|
112
|
-
|
113
|
-
<li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
|
114
|
-
|
115
|
-
</ul>
|
116
|
-
</div>
|
117
|
-
|
118
|
-
|
119
|
-
<div id="classindex-section" class="section project-section">
|
120
|
-
<h3 class="section-header">Class Index
|
121
|
-
<span class="search-toggle"><img src="./images/find.png"
|
122
|
-
height="16" width="16" alt="[+]"
|
123
|
-
title="show/hide quicksearch" /></span></h3>
|
124
|
-
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
125
|
-
<fieldset>
|
126
|
-
<legend>Quicksearch</legend>
|
127
|
-
<input type="text" name="quicksearch" value=""
|
128
|
-
class="quicksearch-field" />
|
129
|
-
</fieldset>
|
130
|
-
</form>
|
131
|
-
|
132
|
-
<ul class="link-list">
|
133
|
-
|
134
|
-
<li><a href="./ABAnalyzer.html">ABAnalyzer</a></li>
|
135
|
-
|
136
|
-
<li><a href="./ABAnalyzer/ABTest.html">ABAnalyzer::ABTest</a></li>
|
137
|
-
|
138
|
-
<li><a href="./ABAnalyzer/InsufficientDataError.html">ABAnalyzer::InsufficientDataError</a></li>
|
139
|
-
|
140
|
-
<li><a href="./ABAnalyzer/Matrix.html">ABAnalyzer::Matrix</a></li>
|
141
|
-
|
142
|
-
<li><a href="./ABAnalyzer/MatrixFormatError.html">ABAnalyzer::MatrixFormatError</a></li>
|
143
|
-
|
144
|
-
</ul>
|
145
|
-
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
146
|
-
</div>
|
147
|
-
|
148
|
-
|
149
|
-
</div>
|
150
|
-
</div>
|
151
|
-
|
152
|
-
<div id="documentation">
|
153
|
-
<h1 class="module">ABAnalyzer</h1>
|
154
|
-
|
155
|
-
<div id="description">
|
156
|
-
|
157
|
-
</div>
|
158
|
-
|
159
|
-
<!-- Constants -->
|
160
|
-
|
161
|
-
<div id="constants-list" class="section">
|
162
|
-
<h3 class="section-header">Constants</h3>
|
163
|
-
<dl>
|
164
|
-
|
165
|
-
<dt><a name="VERSION">VERSION</a></dt>
|
166
|
-
|
167
|
-
<dd class="description"></dd>
|
168
|
-
|
169
|
-
|
170
|
-
</dl>
|
171
|
-
</div>
|
172
|
-
|
173
|
-
|
174
|
-
<!-- Attributes -->
|
175
|
-
|
176
|
-
|
177
|
-
<!-- Methods -->
|
178
|
-
|
179
|
-
<div id="public-class-method-details" class="method-section section">
|
180
|
-
<h3 class="section-header">Public Class Methods</h3>
|
181
|
-
|
182
|
-
|
183
|
-
<div id="calculate-size-method" class="method-detail ">
|
184
|
-
<a name="method-c-calculate_size"></a>
|
185
|
-
|
186
|
-
<div class="method-heading">
|
187
|
-
|
188
|
-
<span class="method-name">calculate_size</span><span
|
189
|
-
class="method-args">(p1, p2, significance, power)</span>
|
190
|
-
<span class="method-click-advice">click to toggle source</span>
|
191
|
-
|
192
|
-
</div>
|
193
|
-
|
194
|
-
<div class="method-description">
|
195
|
-
|
196
|
-
<p>
|
197
|
-
Calculate the minimum sample size (per group) based on the desire to detect
|
198
|
-
a increase from proportion p1 to proportion p2. Significance is generally
|
199
|
-
safe at 0.05 (why? just because) and a power of 0.8 (why? just because)
|
200
|
-
</p>
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
<div class="method-source-code"
|
205
|
-
id="calculate-size-source">
|
206
|
-
<pre>
|
207
|
-
<span class="ruby-comment cmt"># File lib/abanalyzer/sample.rb, line 8</span>
|
208
|
-
8: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">calculate_size</span>(<span class="ruby-identifier">p1</span>, <span class="ruby-identifier">p2</span>, <span class="ruby-identifier">significance</span>, <span class="ruby-identifier">power</span>)
|
209
|
-
9: [ <span class="ruby-identifier">p1</span>, <span class="ruby-identifier">p2</span>, <span class="ruby-identifier">significance</span>, <span class="ruby-identifier">power</span> ].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
|
210
|
-
10: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"All arguments to calculate_size must be Floats"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Float</span>)
|
211
|
-
11: }
|
212
|
-
12:
|
213
|
-
13: <span class="ruby-identifier">pbar</span> = (<span class="ruby-identifier">p1</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">p2</span>) <span class="ruby-operator">/</span> <span class="ruby-value">2.0</span>
|
214
|
-
14: <span class="ruby-identifier">sides</span> = <span class="ruby-value">2.0</span>
|
215
|
-
15:
|
216
|
-
16: <span class="ruby-identifier">zcrit</span> = <span class="ruby-constant">Statistics2</span>.<span class="ruby-identifier">pnormaldist</span>(<span class="ruby-value">1</span> <span class="ruby-operator">-</span> (<span class="ruby-identifier">significance</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">sides</span>))
|
217
|
-
17: <span class="ruby-identifier">zpow</span> = <span class="ruby-constant">Statistics2</span>.<span class="ruby-identifier">pnormaldist</span>(<span class="ruby-identifier">power</span>)
|
218
|
-
18:
|
219
|
-
19: <span class="ruby-identifier">numerator</span> = (<span class="ruby-identifier">zcrit</span> * <span class="ruby-constant">Math</span>.<span class="ruby-identifier">sqrt</span>(<span class="ruby-value">2</span> * <span class="ruby-identifier">pbar</span> * (<span class="ruby-value">1</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">pbar</span>)) <span class="ruby-operator">+</span> <span class="ruby-identifier">zpow</span> * <span class="ruby-constant">Math</span>.<span class="ruby-identifier">sqrt</span>(<span class="ruby-identifier">p2</span> * (<span class="ruby-value">1</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">p2</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">p1</span> * (<span class="ruby-value">1</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">p1</span>))) <span class="ruby-operator">**</span> <span class="ruby-value">2</span>
|
220
|
-
20: <span class="ruby-identifier">denominator</span> = (<span class="ruby-identifier">p2</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">p1</span>) <span class="ruby-operator">**</span> <span class="ruby-value">2</span>
|
221
|
-
21: (<span class="ruby-identifier">numerator</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">denominator</span>).<span class="ruby-identifier">ceil</span>
|
222
|
-
22: <span class="ruby-keyword kw">end</span></pre>
|
223
|
-
</div>
|
224
|
-
|
225
|
-
</div>
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
</div>
|
231
|
-
|
232
|
-
|
233
|
-
<div id="confidence-interval-method" class="method-detail ">
|
234
|
-
<a name="method-c-confidence_interval"></a>
|
235
|
-
|
236
|
-
<div class="method-heading">
|
237
|
-
|
238
|
-
<span class="method-name">confidence_interval</span><span
|
239
|
-
class="method-args">(successes, trials, confidence)</span>
|
240
|
-
<span class="method-click-advice">click to toggle source</span>
|
241
|
-
|
242
|
-
</div>
|
243
|
-
|
244
|
-
<div class="method-description">
|
245
|
-
|
246
|
-
<p>
|
247
|
-
Calculate the confidence interval given the number of successes and trials
|
248
|
-
at the desired confidence level. Returns an Array of [lower, upper]
|
249
|
-
</p>
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
<div class="method-source-code"
|
254
|
-
id="confidence-interval-source">
|
255
|
-
<pre>
|
256
|
-
<span class="ruby-comment cmt"># File lib/abanalyzer/sample.rb, line 26</span>
|
257
|
-
26: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">confidence_interval</span>(<span class="ruby-identifier">successes</span>, <span class="ruby-identifier">trials</span>, <span class="ruby-identifier">confidence</span>)
|
258
|
-
27: <span class="ruby-identifier">sides</span> = <span class="ruby-value">2.0</span>
|
259
|
-
28: <span class="ruby-identifier">alpha</span> = <span class="ruby-value">1</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">confidence</span>
|
260
|
-
29: <span class="ruby-identifier">zcrit</span> = <span class="ruby-constant">Statistics2</span>.<span class="ruby-identifier">pnormaldist</span>(<span class="ruby-value">1</span> <span class="ruby-operator">-</span> (<span class="ruby-identifier">alpha</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">sides</span>))
|
261
|
-
30: <span class="ruby-identifier">p</span> = <span class="ruby-identifier">successes</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">trials</span>.<span class="ruby-identifier">to_f</span>
|
262
|
-
31:
|
263
|
-
32: <span class="ruby-identifier">interval</span> = <span class="ruby-identifier">zcrit</span> * <span class="ruby-constant">Math</span>.<span class="ruby-identifier">sqrt</span>((<span class="ruby-identifier">p</span> * (<span class="ruby-value">1</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">p</span>)) <span class="ruby-operator">/</span> <span class="ruby-identifier">trials</span>.<span class="ruby-identifier">to_f</span>)
|
264
|
-
33: [<span class="ruby-identifier">p</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">interval</span>, <span class="ruby-identifier">p</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">interval</span>]
|
265
|
-
34: <span class="ruby-keyword kw">end</span></pre>
|
266
|
-
</div>
|
267
|
-
|
268
|
-
</div>
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
</div>
|
274
|
-
|
275
|
-
|
276
|
-
<div id="relative-confidence-interval-method" class="method-detail ">
|
277
|
-
<a name="method-c-relative_confidence_interval"></a>
|
278
|
-
|
279
|
-
<div class="method-heading">
|
280
|
-
|
281
|
-
<span class="method-name">relative_confidence_interval</span><span
|
282
|
-
class="method-args">(successes, trials, compared_proportion, confidence)</span>
|
283
|
-
<span class="method-click-advice">click to toggle source</span>
|
284
|
-
|
285
|
-
</div>
|
286
|
-
|
287
|
-
<div class="method-description">
|
288
|
-
|
289
|
-
<p>
|
290
|
-
Like <a
|
291
|
-
href="ABAnalyzer.html#method-c-confidence_interval">confidence_interval</a>,
|
292
|
-
but returns the relative interval compared to the baseline given in
|
293
|
-
compared_proportion
|
294
|
-
</p>
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
<div class="method-source-code"
|
299
|
-
id="relative-confidence-interval-source">
|
300
|
-
<pre>
|
301
|
-
<span class="ruby-comment cmt"># File lib/abanalyzer/sample.rb, line 38</span>
|
302
|
-
38: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">relative_confidence_interval</span>(<span class="ruby-identifier">successes</span>, <span class="ruby-identifier">trials</span>, <span class="ruby-identifier">compared_proportion</span>, <span class="ruby-identifier">confidence</span>)
|
303
|
-
39: <span class="ruby-identifier">ci</span> = <span class="ruby-identifier">confidence_interval</span>(<span class="ruby-identifier">successes</span>, <span class="ruby-identifier">trials</span>, <span class="ruby-identifier">confidence</span>)
|
304
|
-
40: [(<span class="ruby-identifier">ci</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">compared_proportion</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">compared_proportion</span>, (<span class="ruby-identifier">ci</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">compared_proportion</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">compared_proportion</span>]
|
305
|
-
41: <span class="ruby-keyword kw">end</span></pre>
|
306
|
-
</div>
|
307
|
-
|
308
|
-
</div>
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
</div>
|
314
|
-
|
315
|
-
|
316
|
-
</div>
|
317
|
-
|
318
|
-
|
319
|
-
</div>
|
320
|
-
|
321
|
-
|
322
|
-
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
323
|
-
|
324
|
-
<p>Disabled; run with --debug to generate this.</p>
|
325
|
-
|
326
|
-
</div>
|
327
|
-
|
328
|
-
<div id="validator-badges">
|
329
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
330
|
-
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
331
|
-
Rdoc Generator</a> 1.1.6</small>.</p>
|
332
|
-
</div>
|
333
|
-
|
334
|
-
</body>
|
335
|
-
</html>
|
336
|
-
|