Calculateur de test t pour échantillons appariés
Échantillon 1
Échantillon 2
t = -1,608761
df = 22
Valeur p (unilatérale) = 0,060963
Valeur p (bilatérale) = 0,121926
function calc() { //get raw data var raw1 = document.getElementById('rawData1').value.split(',').map(Number); var raw2 = document.getElementById('rawData2').value.split(',').map(Number);
//calculate paired differences var diff = []; for (var i = 0; i < raw1.length; i++) { diff.push(raw1[i]-raw2[i]); } console.log(diff); //calculate test statistic t var xdiff = math.mean(diff) var s = math.std(diff) var n = raw1.length; var df = n-1; var t = xdiff /(s/Math.sqrt(n)); //calculate p-value if (t<0) { var p1 = jStat.studentt.cdf(t, df); var p2 = p1*2; } else { var p1 = 1-jStat.studentt.cdf(t, df); var p2 = p1*2; } document.getElementById('t').innerHTML = t.toFixed(6); document.getElementById('df').innerHTML = df; document.getElementById('p1').innerHTML = p1.toFixed(6); document.getElementById('p2').innerHTML = p2.toFixed(6); }