"Number" (Comparison Method)
Details
- The number comparison method considers two numeric quantities to be equivalent if they do not differ numerically beyond a given tolerance.
- The numeric tolerance should usually be set using the Tolerance option in AssessmentFunction. The default value of 0 allows only machine precision differences.
- By default, the tolerance is compared to the absolute difference between the answer key value and the answer. The DistanceFunction option can be used to specify a different distance metric.
- When multiple values in the answer key are within the tolerance range of an answer, the closest value is selected.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Create an AssessmentFunction for a number comparison question:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-1gdmpv


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-6w7so2

Numerically, approximation is always performed and equivalence is tested by default at machine precision level:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-bj4t9u

Create a check for an approximate number:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-phijix

Answers within the tolerance range are correct:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-pixlfq

Any other value is marked incorrect:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-lg9h71

"Number" is chosen automatically when all values in the answer key are numeric. Define assessment for a problem with multiple correct answers:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-9o8p7j


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-umczou


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-nnexjj

With no Tolerance specified, values not in the key are incorrect:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-lq78fc

Scope (5)Survey of the scope of standard use cases
Create an assessment for a list of answers, with each element assessed individually:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-9h7uta


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-uc58tj

Each answer is assessed and scored separately. By default, any incorrect answer gives an overall incorrect result:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-bcum1r

Use "ListAssessment""AllElementsOrdered" to create an assessment function for an ordered list of numbers, where all values must be included in the answer:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-rq73gm


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-0zrk1d


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-6t316a

Use "ListAssessment""AllElementsOrderless" to create an assessment function for a list of numbers, where all values must be included in the answer but the order does not matter:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-khyhwh

Apply the function to an answer:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-gbl6tv

Use "Number" comparison in a QuestionObject:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-fe3knw

Use "Number" comparison in a QuestionGenerator:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-gueswv


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-q88mph

Applications (1)Sample problems that can be solved with this function
Create a QuestionGenerator for reading values from a plot of a random polynomial:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-61x5dr

Generate a random instance of the question:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-beflz8

Properties & Relations (4)Properties of the function, and connections to other functions
Specify an answer key containing values that differ by less than the tolerance:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-mp6a2g

The closest value to the answer is chosen:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-m0af2x

Assessment will match exact and inexact values, even with zero tolerance:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-h81vz7

For an exact match, without numerical approximation applied, consider "ArithmeticResult" or "Expression":

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-n8ukq8


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-y6iav5

With no Tolerance specified, the tolerance is effectively based on $MachinePrecision:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-r0w3r


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abete-h4mn7s
