ウェルチの t 検定計算機
サンプル1
サンプル2
t = -1.608761
df = 17
p 値 (片側) = 0.063040
p 値 (両側) = 0.126080
//set summary table to hidden to start var summary_display = document.getElementById("summary_table"); summary_display.style.display = "none";
//find which radio button is checked function check() { if (document.getElementById('raw').checked) { var table_display = document.getElementById("words_table"); table_display.style.display = "block"; var summary_display = document.getElementById("summary_table"); summary_display.style.display = "none"; } else { var table_display = document.getElementById("words_table"); table_display.style.display = "none"; var summary_display = document.getElementById("summary_table"); summary_display.style.display = "block"; }
} //end check
//perform one-sample t-test function calc() { if (document.getElementById('summary').checked) { 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 s12 = Math.pow(s1,2); var s22 = Math.pow(s2,2);
var df1 = (Math.pow(s12/n1 - (-1*s22/n2),2)) / ((Math.pow(s12/n1,2)/(n1-1)) - (-1*Math.pow(s22/n2,2)/(n2-1))); var df = Math.floor(df1); var t = (x1-x2)/(Math.sqrt(Math.pow(s1,2)/n1 - (-1*Math.pow(s2,2)/n2)));
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); } else { var raw1 = document.getElementById('rawData1').value.split(',').map(Number); var raw2 = document.getElementById('rawData2').value.split(',').map(Number); var x1 = math.mean(raw1) var s1 = math.std(raw1) var n1 = raw1.length; var x2 = math.mean(raw2) var s2 = math.std(raw2) var n2 = raw2.length; var s12 = Math.pow(s1,2); var s22 = Math.pow(s2,2); var df1 = (Math.pow(s12/n1 - (-1*s22/n2),2)) / ((Math.pow(s12/n1,2)/(n1-1)) - (-1*Math.pow(s22/n2,2)/(n2-1))); var df = Math.floor(df1); var t = (x1-x2)/(Math.sqrt(Math.pow(s1,2)/n1 - (-1*Math.pow(s2,2)/n2))); 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); } //output results }