swcarpentry / DEPRECATED-bc

DEPRECATED: This repository is now frozen - please see individual lesson repositories.
Other
299 stars 383 forks source link

Which challenge in novice Python lesson addresses floating point imprecision? #666

Closed jdblischak closed 7 years ago

jdblischak commented 9 years ago

The following line appears in the novice Python lesson on modular programming with functions:

The mean of the centered data isn't quite zero—we'll explore why not in the challenges—but it's pretty close.

The context in the lesson is that after centering a data set on zero, the mean is not zero but 1e-15. However, it is not clear to me which of the subsequent challenges is meant to address the issue of floating point imprecision. Could this be made more explicit either in the lesson or in the teaching guide? My guess is that it is meant to be explored in the last challenge when the learners are asked to compare their implementation of the rescale function with their neighbors. But even if that is so, it is still unclear how much depth to explain this concept to novices. Simply seeing that their answers are slightly different than their neighbors provides no more understanding of the issue.

Here are links to the lesson in its various formats: ipynb md rendered

tbekolay commented 9 years ago

I agree @jdblischak, the promise of exploring the floating point issue doesn't pay off in the challenges. However, I feel like adding in some prose on floating point inaccuracies would detract from the lesson which is already quite detailed.

How about we remove the reference to the challenges, and include a link to some resource on floating point inaccuracies instead? I'll search around for something good.

tbekolay commented 9 years ago

This seems like a nice gentle resource: https://docs.python.org/2.7/faq/design.html#why-are-floating-point-calculations-so-inaccurate

While this is apparently "the resource" but far from gentle: http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

gvwilson commented 9 years ago

I used to have material on this (see http://software-carpentry.org/v4/test/float.html), but it didn't lead anywhere - once people know there are problems, they say, "OK, now what do I do?" And the answer, "compare floats with tolerances", is pretty much ignored by most scientists in practice, in part because the code they get doesn't do it (quick, how much of your code does?), and partly because we don't know how to tell them what tolerances to use.

tbekolay commented 9 years ago

Thanks for the info Greg! We actually test for tolerances a lot in our Nengo tests, but never manually -- we use numpy.allclose.

Does it make sense to link to that v4 lesson in this lesson? It seems the most comprehensive but understandable overview that I can find online.

jdblischak commented 9 years ago

How about we remove the reference to the challenges, and include a link to some resource on floating point inaccuracies instead? I'll search around for something good.

+1