Search code examples
rr-exams

how to use the function ```num_to_schoice()```?


I would like to built a simple probability exercise such that the solution is just a one decimal number between zero and one (different from zero and one). I would like to use the function num_to_schoice, but if I write:

num_to_schoice(0.3,digits=1,range=c(0.1,0.9))

I get the error message:

NULL Warning message: In num_to_schoice(0.3, digits = 1, range = c(0.1, 0.9)) : specified 'range' is too small for 'delta'

Could someone please explain how the function num_to_schoice should be properly used?


Solution

  • Let me add a couple of points to existing answer by @Edward (+1):

    If you generate a solution from the sequence 0.1, 0.2, ..., 0.9 and want four from the remaining eight numbers as distractors, I would recommend not using num_to_schoice(). Only if moving to a correct solution in 0.10, 0.11, 0.12, ..., 0.9, say, I would use num_to_schoice().

    Without num_to_schoice() for one digit

    You can set up an answerlist with all nine numbers from the sequence, sorting the correct solution into the first position, and then using the exshuffle meta-information tag to do the actual sampling.

    For example, in the data-generation you need something like this:

    sol <- 0.3
    ans <- c(sol, setdiff(1:9/10, sol))
    ans <- paste0("$", ans, "$")
    

    In the question you can then include

    answerlist(ans, markup = "markdown")
    ## Answerlist
    ## ----------
    ## * $0.3$
    ## * $0.1$
    ## * $0.2$
    ## * $0.4$
    ## * $0.5$
    ## * $0.6$
    ## * $0.7$
    ## * $0.8$
    ## * $0.9$
    

    Finally, the meta-information needs:

    exsolution: 100000000
    exshuffle: 5
    

    This will then use the correct solution and four of the eight false answers - all in shuffled order. (Note that the above uses .Rmd syntax, for .Rnw this needs to be adapted accordingly.)

    With num_to_schoice() for two digits

    For the scenario with one digit using num_to_schoice() which tries to do too many things, but for more than one digit it might be useful. Specifically, num_to_schoice() assures that the rank of the correct solution is non-iformative, i.e., the correct solution could be the smallest, second-smallest, ..., largest number in the displayed sequence with equal probability. Specifically, this may be important if the distribution of the correct solution is not uniform across the possible range. This is the reason why the following code sometimes fails:

    num_to_schoice(0.3, digits = 1, delta = 0.1, range = c(0.1, 0.9))
    

    Internally, this first decides how many of the four wrong answers should be to the left of the correct solution 0.3. Clearly, there is room for at most two wrong answers to the left, which may result in a warning and a NULL result` if exceeded. Moving to two digits can resolve this, e.g.:

    num_to_schoice(0.31, range = c(0.01, 0.99),
      digits = 2, delta = 0.03, method = "delta")
    

    Remarks:

    • Personally, I would only do this if the correct solution can potentially also have two digits. Otherwise students might pick up this pattern.
    • You need to assure that to the left and to the right of the correct solution there is at least 4 * delta so that there is enough room for the wrong answers.
    • Using delta = 0.01 would certainly be possible but if you want larger deltas then delta = 0.03 or delta = 0.07 are also often useful choices. This is because sampling from an equidistant grid with such a delta is typically not noticable for most students. In contrast, deltas like 0.05, 0.1, 0.02, etc. are typically picked up quickly.