-
-
Notifications
You must be signed in to change notification settings - Fork 72
add concept exercise problematic-probabilities #966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There is a way to rephrase the exercise to further mitigate potential rounding error inconsistencies by providing the float used as comparison as an argument to the functions. The student then would have to compare that value to their calculated rational number. This would likely take a bit of a revamp since it would make task 2 obsolete. However, I would prefer to avoid this, if possible, since I find it more instructive to have the student perform both calculations. |
@depial - saw this fly past in my GH notifications. I really like this exercise! I especially like how it "forces" contemplation of why there would be rational numbers in Julia, and some of what they'd be used for. I almost think that in the final two tasks, you might want to have both the rational probability and a specific rounded decimal probability be returned when there is a mis-match ... just to re-enforce things. But that's my Python "show me" talking. 😄 It's very cool that Julia integrates rationals in as general numeric types. Python puts these in a module and forces "clean" conversion by requiring that if a float-like value is used, it's forced to a specific precision by using a On one hand, that makes the rest of the numeric types pretty easy to use for general-purpose "close enough" math. On the other? If you really do need precision, then you have to do it "all the way" and have special code. But this is also why there is |
Apologies, I've not had chance to go through this in detail yet (other distractions today). This afternoon... @BethanyG, is this something you're interested in adding to the Python syllabus. The concept was merged in #3554, 18 months ago, without an exercise.
We could run the tests as a one-off in a branch on one of our forks, it doesn't need to be in I have Linux Mint 22.1 (effectively, Ubuntu 24.04) and Win 11 systems for local testing, nothing Apple. |
I'm on an intel Mac, so could perhaps test there. I might need some setup help. |
Yes — this might work! But I think we'd also need the And since in Python you have to aaaand ... the more I think on it, the more I think maybe we have two exercises - one for creation/conversion, and the other for "working with". Or not. Maybe we could do a series of purpose-built practice exercises for that. Lemme think a little on it as I get the |
We need to move this from a Julia PR discussion! But I'm not sure Decimals even got drafted - I looked into it, and found it ugly and confusing. Luckily, Julia shunted this topic off to a 3rd-party package. |
Also a bit off-topic: I've been working on the Dates & Times concept for Julia, and it reminds me why my old Python draft was huge, confusing, and impossible to merge. A bigger topic than it first appears! |
Another thought: codespaces might have a template that would allow testing on Mac...although I doubt it. Apples OS EULA expressly forbids installation on non-apple hardware for most scenarios. |
Let's take this up in an Issue on the Python track. 😄 I'll make one here shortly ... or you can. Just ref this thread so we don't forget. |
As discussed for the Python one — the topic might benefit from breaking it down into pieces. I think we discussed maybe separating date conversion from timezones from "date math"? Can't remember anymore. But it is indeed a big-ass and complicated topic! And that doesn't even dig into "wall clock" time vs other timings. sigh. |
exercises/concept/problematic-probabilities/.docs/instructions.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from one tiny typo, this looks great!
It's hard to even guess which time zone you are in currently, so I went ahead and fixed the typo. I'll merge.
@BethanyG, I had considered doing something like this, or even just returning the error/discrepancy instead (with a slight modification of the story to focus on how bad the problem was rather than just fixing it). I think I went with this because, with the examples I've used here, the errors are quite small (~1e-18). I don't see why that would stop anyone from also including a rounded decimal probability though :)
I felt this was still a bit raw, but if everyone is happy, then that's great! :) |
Here's an idea for an exercise for the
rational-numbers
concept. I've tried to incorporate a realish use case, but this moves it down the syllabus a bit. Some notes:vector-operations
seems just as valid, the prereq is listed asloops
, since this is more general.Float64
is being used for casting).introduction.md
has been pared down quite a bit from the concept version.I'm unsure if rounding errors will be consistent across Julia and OS versions (but it appears most modern processors are IEEE 754 compliant). In any case, for the examples which have a rounding error, I've tried to pick examples which had larger ones than average, so hopefully there's a bit of robustness against potential variation there. However, those errors were still quite small (~1e-16). There are ways to ensure a larger error, but I'm not sure it's necessary or not.
For reference, I'm running Linux 24.04 and using Julia 1.11.0
The one time we could have used all that extra testing... :D