Widget:WJG Sandbox Merge: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1,065: | Line 1,065: | ||
$("#details").slideToggle("slow"); | $("#details").slideToggle("slow"); | ||
} | } | ||
function convolve_bernouli(qprobs){ | |||
//takes in an array of probabilities of guessing questions correct | |||
for (var counter = 0; counter < qprobs.length; counter++) { | |||
//if the loop is in the first iteration, then initialize the array | |||
if (counter==0){ | |||
var pdfArray=[1-qprobs[0],qprobs[0]]; | |||
}else{ | |||
//initialize new Array for pdfs | |||
var newpdfArray= []; | |||
for (var i = 0; i < pdfArray.length+1; i+=1) { | |||
newpdfArray[i]=0; | |||
} | |||
//multiply by ones first | |||
for (var i = 0; i < pdfArray.length; i+=1) { | |||
newpdfArray[i+1]+=pdfArray[i]*qprobs[counter]; //probability of adding a success | |||
newpdfArray[i]+=pdfArray[i]*(1-qprobs[counter]); | |||
} | |||
pdfArray=newpdfArray; | |||
} | |||
} | |||
console.log(pdfArray); | |||
return(pdfArray); | |||
}//ends convolve_bernouli | |||
function endExam(event) { | function endExam(event) { | ||
if (window.exam.timer) { | if (window.exam.timer) { |