The extol
meta-information sets the absolute tolerance of the exsolution
. Thus, exsolution
plus/mins extol
is the interval which is accepted as correct.
To set a relative tolerance you can use the num_to_tol()
function which converts a numeric solution to an absolute tolerance. It also assures a certain minimal tolerance. See the source code for the precise computation:
num_to_tol
## function (x, reltol = 2e-04, min = 0.01, digits = 2)
## pmax(min, round(reltol * abs(x), digits = digits))
This function is useful if the order of magnitude of the correct answer can change substantially across different random replications:
exams::num_to_tol(10)
## [1] 0.01
exams::num_to_tol(100)
## [1] 0.02
## exams::num_to_tol(1000)
## [1] 0.2
exams::num_to_tol(10000)
## [1] 2
The default of reltol = 2e-04
and min = 0.01
was chosen based on our needs and experiences in our own exams. You might prefer different specifications, of course.
To apply it in a given exercise for a solution in a variable sol
, say, you typically do:
exsolution: `r sol`
extol: `r num_to_tol(sol)`