一份比例 z 检验计算器
- p = 观察到的样本比例
- p 0 = 假设的人口比例
- n = 样本量
z 统计量: 0.55487
p 值(单侧): 0.28949
p 值(两侧): 0.57898
95% CI = [ 0.2914 , 0.6486 ]
function calc() {
//get input values var p0 = +document.getElementById('p0').value; var p = +document.getElementById('p').value; var n = +document.getElementById('n').value;
//calculate stuff var z = (p-p0)/(Math.sqrt(p0*(1-p0)/n));
//calculate p-value if (z<0) { var p1 = jStat.normal.cdf(z, 0, 1); var p2 = p1*2; } else { var p1 = 1-jStat.normal.cdf(z, 0, 1); var p2 = p1*2; } //calculate C.I. var zCrit = Math.abs(jStat.normal.inv(.975, 0, 1)); var se = Math.sqrt(p*(1-p)/n); var low = p - (zCrit*se); var high = p - (-1*zCrit*se); //output probabilities document.getElementById('z').innerHTML = z.toFixed(5); document.getElementById('p1').innerHTML = p1.toFixed(5); document.getElementById('p2').innerHTML = p2.toFixed(5); document.getElementById('low').innerHTML = low.toFixed(4); document.getElementById('high').innerHTML = high.toFixed(4); }