Skip to content

Commit 2b3305d

Browse files
authored
Merge pull request #13 from lambda-feedback/docs
Updated user docs
2 parents b27e83b + e0a2270 commit 2b3305d

1 file changed

Lines changed: 55 additions & 3 deletions

File tree

app/docs/user.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,59 @@
1-
# IsSimilar
1+
# IsSimilar
22

3-
Use this evaluation function to check if the student's reponse is within a tolerance range defined in `params`. Works exactly like the [numpy.isclose](https://numpy.org/doc/stable/reference/generated/numpy.isclose.html#numpy.isclose) function. Valid params include `atol` and `rtol` (absolute and relative tolerances) which can be used in combination, or alone.
3+
Use this evaluation function to check if a student's response is within a tolerance range of the correct answer. Works like the [numpy.isclose](https://numpy.org/doc/stable/reference/generated/numpy.isclose.html#numpy.isclose) function.
4+
5+
A response is accepted if:
6+
7+
```
8+
|response - answer| ≤ atol + rtol × |answer|
9+
```
10+
11+
The left-hand side is the absolute difference between the student's response and the correct answer. The right-hand side is the total allowed difference, made up of a fixed part (`atol`) and a part that scales with the size of the answer (`rtol × |answer|`). A response is marked correct whenever the actual difference does not exceed the allowed difference.
12+
13+
## Parameters
14+
15+
Both parameters default to `0` (exact match required) and can be used individually or together.
16+
17+
### `atol` — Absolute tolerance
18+
19+
Specifies a fixed margin around the answer, regardless of its magnitude. Use this when you know the acceptable error in the same units as the answer.
20+
21+
### `rtol` — Relative tolerance
22+
23+
Specifies an acceptable error as a fraction of the answer's magnitude. Use this when the answer is very large or very small and a percentage-based margin makes more sense than a fixed one.
24+
25+
## Examples
26+
27+
### Exact match (default)
28+
29+
No params needed. The student must enter exactly `42` (floating-point precision is handled automatically).
30+
31+
### Absolute tolerance
32+
33+
```json
34+
{ "atol": 0.05 }
35+
```
36+
37+
With answer `9.81`, accepts any response in the range **9.76 – 9.86**. Good for physical measurements where the acceptable error is known in the same units.
38+
39+
### Relative tolerance
40+
41+
```json
42+
{ "rtol": 0.01 }
43+
```
44+
45+
With answer `6.674e-11`, accepts any response within **1%** of the answer. Good for very large or very small values where a fixed margin would be impractical.
46+
47+
### Combined tolerances
48+
49+
```json
50+
{ "atol": 0.01, "rtol": 0.005 }
51+
```
52+
53+
Both tolerances contribute: with answer `9.81`, the allowed difference is `0.01 + 0.005 × 9.81 ≈ 0.059`. Useful when you want a minimum floor (`atol`) plus a proportional allowance (`rtol`).
54+
55+
## Notes
456

557
**Note:** If the answer is not a number, all responses will generate an error.
658

7-
**Note:** If the response is not a number, a feedback message asking the user to submit a number will be returned.
59+
**Note:** If the response is not a number, a feedback message asking the student to submit a number will be returned.

0 commit comments

Comments
 (0)