"Vector" (Comparison Method)

Compare vectors based on distances.

Details

  • The vector comparison method considers two vector quantities to be equivalent if by default the Euclidean distance between vectors is within 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.
  • Any other distance metric can be specified for the comparison using the DistanceFunction option.
  • When multiple vectors in the answer key are within the tolerance range of an answer, the assessment is based on the closest vector.

Examples

open allclose all

Basic Examples  (3)

Create an AssessmentFunction for a vector comparison with a nonzero tolerance:

Answers within the tolerance range are marked as correct:

Use zero tolerance:

During assessment, equivalence is tested by default at machine precision level:

Define an assessment for a problem with multiple correct answers:

Assess an answer and see the score:

Scope  (2)

Define assessment for a symbolic vector and numeric tolerance:

Answers within the tolerance range are correct:

The tolerance is applied at the vector level, not at the components level. By default, the tolerance corresponds to the norm of the difference between the compared vectors:

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

Evaluate multiple answers:

Options  (1)

Any other distance metric can be used instead of the Euclidean default one:

This answer gives zero distance in a Dot product with the answer key:

Any nonzero distance is marked as incorrect:

Applications  (1)

Create a QuestionObject for reading values from a chart:

Properties & Relations  (2)

Define an assessment for a problem with multiple correct answers within the tolerance of each other:

The closest vector in the answer key within the tolerance is used to determine the score:

Create a vector assessment:

The tolerance is applied to the distance between the vectors:

The incorrect mark is expected because the distance is larger than the tolerance:

Create a second assessment for the same vectors, comparing each element independently as a number:

Each component is compared separately to the elements in the answer keys. The first correct answer is selected with the corresponding score

Manually compute the distances to see that each is less than the tolerance:

Possible Issues  (4)

In AssessmentFunction[{a,b,c}] the values a, b and c are treated as three distinct answers instead of a single vector:

Always give vectors in a list:

When no comparison method is specified, the "Vector" comparison method is used for numeric vectors:

Symbolic expressions are not automatically treated as vectors:

With the setting "ListAssessment" set to either "AllElementsOrderless" or "AllElementsOrdered", each element in each value of the answer key must be a vector, resulting in nested lists:

The submitted answer should be a list of vectors in any order:

When a score is specified for a single vector, the outer list is not necessary:

Interactive Examples  (1)

Create a geometry problem: