Hi all,
I've just identified a similar problem to Martin Jones which has plagued my questions for weeks!
In the following question
https://numbas.mathcentre.ac.uk/question/184984/testing-billy-s-copy-of-a4-q1-probability-table-fi/ , I give a table of probabilities for a random variable. There are 5 values: I generate 4 of them as a list
p_aux of random decimals, and create the list
p by appending
1 - sum(p_aux). I then ask the student to calculate
p[2] + p[3] + p[4]. Unfortunately, since the sum of a list of decimals has type number rather than decimal,
p[3] is decimal and
p[4] has type number, so there is almost always a floating point error in here.
This is visible in the variables panel when I define a new variable answer and set it equal to p[2] + p[3] + p[4] (screenshot 1). However, if I don't - if I just type in p[2] + p[3] + p[4] directly as the expected answer of the gap - the floating point error is not visible in the display answer (screenshot 2) or in the marking algorithm testing panel (screenshot 3). This is really frustrating, especially when the issue is rare and only affects a tiny handful of students (making it even harder to debug!).
So a few questions / requests:
- Why is the sum of a list of decimals not decimal? (Same with the sum of a list of rationals.)
- Could there be a big prominent warning on the variables page when a variable relies on an implicit cast that loses information, so that we know to use precround or similar?
- Could there be a nice easy button somewhere, like the one in the variables testing panel, that will automatically run a unit test 100 times on 100 randomised variables? This would save me having to do it by hand.
Thanks!