abstats 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/abstats.gemspec +19 -0
- data/lib/abstats.rb +2 -0
- data/lib/abstats/abstats.rb +32 -0
- data/lib/abstats/version.rb +3 -0
- metadata +88 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Matthew Sonier
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Abstats
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'abstats'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install abstats
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/abstats.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/abstats/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Matthew Sonier"]
|
6
|
+
gem.email = ["matt.sonier@gmail.com"]
|
7
|
+
gem.description = %q{Abstat is a simple library to help with analyzing the results of A/B test.}
|
8
|
+
gem.summary = %q{Abstat is a simple library to help with analyzing the results of A/B test.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "abstats"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Abstats::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'statistics2', '>= 0.54'
|
19
|
+
end
|
data/lib/abstats.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "statistics2"
|
2
|
+
|
3
|
+
module Abstats
|
4
|
+
# Give the statistical power representing the probability that the change seen in the
|
5
|
+
# experiment is in fact real. More specifically, the null hypothesis is that the experiment
|
6
|
+
# and the baseline are identical, this returns the probability that the test will reject the
|
7
|
+
# null hypothesis.
|
8
|
+
def self.statistical_power(n_baseline, p_baseline, n_exp, p_exp, confidence=0.95)
|
9
|
+
if(p_baseline == p_exp or p_exp == 0 or p_baseline == 0)
|
10
|
+
return 0
|
11
|
+
end
|
12
|
+
|
13
|
+
z = Statistics2.pnormaldist(confidence + ((1 - confidence)/2))
|
14
|
+
|
15
|
+
p = (p_baseline + p_exp) / 2
|
16
|
+
q = ((1 - p_baseline) + (1 - p_exp)) / 2
|
17
|
+
|
18
|
+
variance_baseline = p_baseline * (1 - p_baseline)
|
19
|
+
variance_exp = p_exp * (1 - p_exp)
|
20
|
+
|
21
|
+
n = [n_baseline, n_exp].min.to_i
|
22
|
+
|
23
|
+
a = Math.sqrt(n) * (p_baseline - p_exp).abs
|
24
|
+
b = z * Math.sqrt(2.0 * p * q)
|
25
|
+
c = Math.sqrt(variance_baseline + variance_exp)
|
26
|
+
|
27
|
+
lower = Statistics2.normaldist((a - b) / c)
|
28
|
+
upper = Statistics2.normaldist((a + b) / c)
|
29
|
+
|
30
|
+
lower + (1.0 - upper)
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: abstats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Matthew Sonier
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-09-28 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: statistics2
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 103
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 54
|
32
|
+
version: "0.54"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Abstat is a simple library to help with analyzing the results of A/B test.
|
36
|
+
email:
|
37
|
+
- matt.sonier@gmail.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- .gitignore
|
46
|
+
- Gemfile
|
47
|
+
- LICENSE
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- abstats.gemspec
|
51
|
+
- lib/abstats.rb
|
52
|
+
- lib/abstats/abstats.rb
|
53
|
+
- lib/abstats/version.rb
|
54
|
+
homepage: ""
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.8.22
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Abstat is a simple library to help with analyzing the results of A/B test.
|
87
|
+
test_files: []
|
88
|
+
|