This calculator helps you determine the statistical significance of your A/B test results. By inputting the number of visitors and conversions for each variation, you can understand if the observed difference in conversion rates is likely due to a real effect or just random chance.
function calculateABTestSignificance() {
var visitorsA = parseFloat(document.getElementById("visitorsA").value);
var conversionsA = parseFloat(document.getElementById("conversionsA").value);
var visitorsB = parseFloat(document.getElementById("visitorsB").value);
var conversionsB = parseFloat(document.getElementById("conversionsB").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = "; // Clear previous results
if (isNaN(visitorsA) || isNaN(conversionsA) || isNaN(visitorsB) || isNaN(conversionsB) ||
visitorsA <= 0 || conversionsA < 0 || visitorsB <= 0 || conversionsB < 0) {
resultDiv.innerHTML = 'Please enter valid positive numbers for visitors and non-negative numbers for conversions.';
return;
}
// Calculate conversion rates
var rateA = conversionsA / visitorsA;
var rateB = conversionsB / visitorsB;
// Calculate pooled proportion
var pooledConversions = conversionsA + conversionsB;
var pooledVisitors = visitorsA + visitorsB;
var pooledRate = pooledConversions / pooledVisitors;
// Calculate standard error for each group
var seA = Math.sqrt((pooledRate * (1 – pooledRate)) / visitorsA);
var seB = Math.sqrt((pooledRate * (1 – pooledRate)) / visitorsB);
// Calculate standard error of the difference
var seDifference = Math.sqrt(Math.pow(seA, 2) + Math.pow(seB, 2));
// Calculate Z-score
var zScore = (rateB – rateA) / seDifference;
// Calculate P-value (for a two-tailed test)
// This is an approximation using the normal distribution CDF.
// For more precision, a Z-table or more complex statistical functions would be used.
function normalCDF(x) {
var t = 1 / (1 + 0.3275911 * Math.abs(x));
var y = 1 – (((((10614 * t – 132341) * t + 47036) * t – 114606) * t + 40371) * t – 12643) * t * Math.exp(-x * x / 2);
if (x < 0) {
return y;
} else {
return 1 – y;
}
}
var pValue = 2 * (1 – normalCDF(Math.abs(zScore)));
var htmlOutput = '