"Quantity" (Comparison Method)

Compare two quantities based on a tolerance.

Details

  • The "Quantity" comparison method considers two quantities to be equivalent if they do not differ beyond a given tolerance.
  • All specified quantities must have compatible units.
  • This tolerance should be expressed as any Quantity consistent with the answer key and is set using the Tolerance option in AssessmentFunction.
  • The default tolerance has a zero magnitude.
  • By default, the comparison between the answer key and the answer is computed as the absolute difference. The DistanceFunction option can be used to specify a custom distance metric.
  • When multiple values in the answer key are within the tolerance range of an answer, the closest value is selected.

范例

打开所有单元关闭所有单元

基本范例  (2)

Create an AssessmentFunction for a distance quantity question with a tolerance:

Use it to assess answers specified in any compatible unit:

Assess the distance from the Earth to the Sun, allowing a 10% margin of error:

Give an answer in kilometers:

Provide an answer computed based on the time for light to reach Earth:

Scope  (1)

Generate building height data for use in an answer key:

Create an assessment using the data with multiple scores and a tolerance:

Verify all the values and scores in the answer key:

Assess an answer and retrieve the score directly. The score corresponds to the closest answer key given the tolerance:

Applications  (1)

Retrieve hydrogen spectra wavelengths and combine values within an angstom:

Create a QuestionObject for reading a spectrum diagram:

Properties & Relations  (2)

The "Quantity" comparison method will be automatically inferred if all the answer keys are Quantity expressions:

Otherwise the fallback "Expression" comparison method will be inferred:

The "Quantity" comparison always automates unit conversion:

To prevent unit conversion and require that answers exactly match the answer key, use a different method like "Number" or "Expression":

Possible Issues  (1)

When an assessment has zero tolerance, the comparison is performed at machine precision:

Equivalent quantities are considered correct:

Small deviations are considered incorrect unless they are are less than machine precision: