Interval keyakinan untuk kalkulator perbedaan antara rata-rata
- x 1 , x 2 : rata-rata sampel 1, rata-rata sampel 2
- t : nilai t-kritis berdasarkan tingkat kepercayaan
- s p 2 : varians yang dikelompokkan
- n 1 , n 2 : ukuran sampel 1, ukuran sampel 2
CI 95 % = [ -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); }