多项分布计算器
结果 | 可能性 | 频率 |
---|---|---|
结果1 | ||
结果2 | ||
结果3 | ||
结果4 | ||
结果5 | ||
结果6 | ||
结果 7 | ||
结果 8 | ||
结果 9 | ||
结果 10 |
多项式概率: 0.118125
概率总计必须为 1。目前总计为0.359
//show answer to start var answer_display = document.getElementById("answer");
//hide error message to start var error_msg_display = document.getElementById("error_msg"); error_msg_display.style.display = "none";
//define factorial function
function factorial(num)
{
var rval=1;
for (var i = 2; i <= num; i++)
rval = rval * i;
return rval;
}
function calc() {
//get input data
var p1 = document.getElementById('p1').value;
var p2 = document.getElementById('p2').value;
var p3 = document.getElementById('p3').value;
var p4 = document.getElementById('p4').value;
var p5 = document.getElementById('p5').value;
var p6 = document.getElementById('p6').value;
var p7 = document.getElementById('p7').value;
var p8 = document.getElementById('p8').value;
var p9 = document.getElementById('p9').value;
var p10 = document.getElementById('p10').value;
var f1 = document.getElementById('f1').value;
var f2 = document.getElementById('f2').value;
var f3 = document.getElementById('f3').value;
var f4 = document.getElementById('f4').value;
var f5 = document.getElementById('f5').value;
var f6 = document.getElementById('f6').value;
var f7 = document.getElementById('f7').value;
var f8 = document.getElementById('f8').value;
var f9 = document.getElementById('f9').value;
var f10 = document.getElementById('f10').value;
var p_group = [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10];
var f_group = [f1, f2, f3, f4, f5, f6, f7, f8, f9, f10];
var p_sum = parseFloat(math.sum(p_group)).toFixed(5);
var n = math.sum(f_group);
//do calculations
if (p_sum == 1) {
answer_display.style.display = "block";
error_msg_display.style.display = "none";
var nPORTION = factorial(n);
var xFACT = [];
for (var i=0; i
var pxFACT = [];
for (var j=0; j
var p = nPORTION*pxPORTION/xPORTION; document.getElementById('p').innerHTML = p.toFixed(6); } else { answer_display.style.display = "none"; error_msg_display.style.display = "block"; document.getElementById('p_sum').innerHTML = p_sum; }
} //end massive calc function