Konfidenzintervall für den anteilsrechner
- p: Stichprobenanteil
- z: der z-kritische Wert basierend auf dem Konfidenzniveau
- n: Stichprobenanteil
95 %-KI = [ 0,4627 , 0,6573 ]
function calc() {
//get input values var p = +document.getElementById('p').value; var n = +document.getElementById('n').value; var conf = +document.getElementById('conf').value;
var confUse = conf - (-(1-conf)/2); var confOut = conf*100;
//calculate stuff var z = Math.abs(jStat.normal.inv(confUse, 0, 1)); var se = Math.sqrt(p*(1-p)/n);
var low = p - (z*se); var high = p - (-1*z*se);
//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); }