Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A/B test analysis library for Ruby - performs Chi-Square tests and G-tests on A/B results
Ruby
Branch: master
Pull request Compare This branch is 2 commits ahead, 3 commits behind livingsocial:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.rdoc
Rakefile

README.rdoc

ABAnalyzer

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. For more information, see:

Installation

Simply run:

gem install abanalyzer

Basic Usage

The simplest test (which uses a gtest):

require 'rubygems'
require 'abanalyzer'

values = {}
values[:agroup] = { :opened => 100, :unopened => 300 }
values[:bgroup] = { :opened => 50, :unopened => 350 }

tester = ABAnalyzer::ABTest.new values
# Are the two different?  Returns true or false (at 0.05 level of significance)
puts tester.different?

Multiple Categories

You can use the ABAnalyzer module to test for differences in more than two categories. For instance, to test accross three:

require 'rubygems'
require 'abanalyzer'

values = {}
values[:agroup] = { :male => 200, :female => 250 }
values[:bgroup] = { :male => 150, :female => 300}
values[:cgroup] = { :male => 50, :female => 50 }

tester = ABAnalyzer::ABTest.new values
# Are the two different?  Returns true or false (at 0.05 level of significance)
puts tester.different?

Tests Available

You can get the actual p-value for either a Chi-Square test for independence or a G-Test for independence.

...
tester = ABAnalyzer::ABTest.new values
puts tester.chisquare_p
puts tester.gtest_p

You can additionally get the actual score for either a Chi-Square test for independence or a G-Test for independence.

...
tester = ABAnalyzer::ABTest.new values
puts tester.chisquare_score
puts tester.gtest_score

Running Tests

Testing can be run by using:

rake test
Something went wrong with that request. Please try again.