两比例 z 检验计算器
- p = 总合并比例
- p 1 = 样本 1 的比例
- p 2 = 样本 2 的比例
- n 1 = 样本 1 大小
- n 2 = 样本量 2
z 统计量: 0.31917
p 值(单侧): 0.37480
p 值(两侧): 0.74960
function calc() {
//get input values var p1 = +document.getElementById('p1').value; var n1 = +document.getElementById('n1').value; var p2 = +document.getElementById('p2').value; var n2 = +document.getElementById('n2').value;
//calculate stuff var pool = (p1*n1 - (-p2*n2))/(n1-(-1*n2)); var z = (p1-p2)/(Math.sqrt(pool*(1-pool)*(1/n1-(-1/n2))));
//calculate p-value if (z<0) { var p1out = jStat.normal.cdf(z, 0, 1); var p2out = p1out*2; } else { var p1out = 1-jStat.normal.cdf(z, 0, 1); var p2out = p1out*2; } //output probabilities document.getElementById('z').innerHTML = z.toFixed(5); document.getElementById('p1out').innerHTML = p1out.toFixed(5); document.getElementById('p2out').innerHTML = p2out.toFixed(5); }