sumScoreToOptimalScore <- function(sumScore, wfdList, optList, prec=0.0001, verbose=F) {
theta <- 50
jump <- theta/2
bestguess <- Inf
up <- NULL
if (verbose) {
print("----")
}
while (TRUE) {
guess <- testscore(theta, wfdList, optList)
diff <- guess-sumScore
if (verbose) {
print(paste("sum:", guess, " theta:", theta, sep = ""))
}
if (abs(diff) < prec) {
return(theta)
}
if (guess > sumScore) {
if (theta==0) {
return(theta)
}
if (!is.null(up)) {
if (up) {
jump <- jump/2
}
}
up <- FALSE
theta <- max(theta-jump, 0)
}
else {
if (theta==100) {
return(theta)
}
if (!is.null(up)) {
if (!up) {
jump <- jump/2
}
}
up <- TRUE
theta <- min(theta+jump, 100)
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.