Wilcoxon 签名地点测试计算器
样品1
样品2
检验统计量 W = 29.5
非均等对的数量 (n) = 13
参考下面的临界值表,根据n和所选的alpha水平来决定测试结果是否具有统计显着性。
如果检验统计量W小于下表临界值中找到的值,则检验结果具有统计显着性。
function calc() { //get raw data var raw1 = document.getElementById('rawData1').value.split(',').map(Number); var raw2 = document.getElementById('rawData2').value.split(',').map(Number);
//calculate raw paired differences var diff = []; for (var i = 0; i < raw1.length; i++) { if (raw1[i]-raw2[i] != 0) { diff.push(raw1[i]-raw2[i]); } } //calculate absolute paired differences var diff_abs = []; for (var i = 0; i < raw1.length; i++) { if (raw1[i]-raw2[i] != 0) { diff_abs.push(Math.abs(raw1[i]-raw2[i])); } } //rank absolute paired differences var sorted = diff_abs.slice().sort(function(a,b){return a-b}) var reversed = sorted.slice(0).reverse(); var frac_rank = diff_abs.slice().map(function(n) { return ( (sorted.indexOf(n) + 1) + (reversed.length - reversed.indexOf(n)) ) / 2 }); //create array of positive ranks var positive_ranks = []; for (var i = 0; i < diff.length; i++) { if (diff[i] > 0) { positive_ranks.push(frac_rank[i]); } }
//create array of negative ranks var negative_ranks = []; for (var i = 0; i < diff.length; i++) { if (diff[i] < 0) { negative_ranks.push(frac_rank[i]); } } //find sum of positive and negative ranks var positive_sum = Math.abs(math.sum(positive_ranks)); var negative_sum = Math.abs(math.sum(negative_ranks)); var w = Math.min(positive_sum, negative_sum); var n = diff.length; //output results document.getElementById('w').innerHTML = w; document.getElementById('n').innerHTML = n; }