Created
May 12, 2014 19:19
-
-
Save okomestudio/878b44714833d7a14768 to your computer and use it in GitHub Desktop.
An example of A/B test using the chi-squared test for independence.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
# -*- coding: utf-8 -*- | |
"""An example of A/B test using the chi-squared test for independence.""" | |
import numpy as np | |
import pandas as pd | |
from scipy.stats import chi2_contingency | |
def main(): | |
data = pd.io.parsers.read_csv('n10000.csv') | |
data = data.set_index('version') | |
observed = data.values | |
print observed | |
result = chi2_contingency(observed) | |
chisq, p = result[:2] | |
print 'chisq = {}, p = {}'.format(chisq, p) | |
data = pd.io.parsers.read_csv('n40000.csv') | |
data = data.set_index('version') | |
observed = data.values | |
print observed | |
result = chi2_contingency(observed) | |
chisq, p = result[:2] | |
print 'chisq = {}, p = {}'.format(chisq, p) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version | not converted | converted | |
---|---|---|---|
A | 4514 | 486 | |
B | 4473 | 527 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version | not converted | converted | |
---|---|---|---|
A | 17998 | 2002 | |
B | 17742 | 2258 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment