Created
June 17, 2015 21:31
-
-
Save kdzwinel/201293d7e35981e87b40 to your computer and use it in GitHub Desktop.
Calculating A/B Test Sample Size
This file contains hidden or 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
"use strict"; | |
//based on https://www.optimizely.com/resources/sample-size-calculator/ | |
function getSampleSize() { | |
let effect = 0.05; // Minimum Detectable Effect | |
let significance = 0.95; // Statistical Significance | |
let conversion = 0.05; // Baseline Conversion Rate | |
let c = conversion - (conversion * effect); | |
let p = Math.abs(conversion * effect); | |
let o = conversion * (1 - conversion) + c * (1 - c); | |
let n = 2 * significance * o * Math.log(1 + Math.sqrt(o) / p) / (p * p); | |
return Math.round(n); | |
} |
This file contains hidden or 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
"use strict"; | |
//based on https://www.qualtrics.com/blog/determining-sample-size/ | |
function getSampleSize() { | |
let z = 1.96;//z-score for confidence level (95% for 1.95) | |
let p = 0.5;//standard of deviation (0.5 for 50%/50%) | |
let e = 0.05;//margin of error | |
return (z * z) * p * (1 - p) / (e * e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment