平均値間の差の信頼区間計算ツール
- x 1 、 x 2 : サンプル 1 の平均、サンプル 2 の平均
- t: 信頼水準に基づく t 臨界値
- s p 2 : グループ化された分散
- n 1 、n 2 : サンプルサイズ 1、サンプルサイズ 2
95 % CI = [ -2.0049 , 3.6049 ]
function calc() {
//get input values var x1 = +document.getElementById('x1').value; var s1 = +document.getElementById('s1').value; var n1 = +document.getElementById('n1').value; var x2 = +document.getElementById('x2').value; var s2 = +document.getElementById('s2').value; var n2 = +document.getElementById('n2').value; var conf = +document.getElementById('conf').value;
var confUse = conf - (-(1-conf)/2); var confOut = conf*100; var df = n1 - (-1*n2) - 2; var s2p = ((n1-1)*(Math.pow(s1,2)) - ((-1*(n2-1))*Math.pow(s2,2))) / df;
//calculate stuff var meanDiff = x1-x2; var t = jStat.studentt.inv(confUse, df); var se = Math.sqrt((s2p/n1) - (-1*s2p/n2));
var low = meanDiff - (t*se); var high = meanDiff - (-1*t*se); console.log(s2p);
//output results document.getElementById('confOut').innerHTML = confOut; document.getElementById('confOut2').innerHTML = confOut; document.getElementById('low').innerHTML = low.toFixed(4); document.getElementById('low2').innerHTML = low.toFixed(4); document.getElementById('high').innerHTML = high.toFixed(4); document.getElementById('high2').innerHTML = high.toFixed(4); }