5 ms·
This article hinges on a rather silly fallacy. Luckily the author does us the favor of making his mistake very clear in the curve-fitting analogy; but first loo
by belovedeagle 10y ago
This article hinges on a rather silly fallacy. Luckily the author does us the favor of making his mistake very clear in the curve-fitting analogy; but first look at the code.
He gives several examples of poorly-written FP code (which we're supposed to believe is "clever" by virtue of being FP), then introduces some new problem constraint which is carefully selected to make the FP solution break but some equally ridiculous imperative-style code not break. In fact, what he really wants to say is, "FP is stupid", but he won't come out and say it.
This is illustrated perfectly by the curve-fitting analogy: a perfectly-fit 5th degree polynomial is the "clever" solution, but oh wouldn't it be so much simpler to use an best-fit 3rd degree function? And oh look, the 3rd-degree polynomial has a positive slope at the end whereas the 5th degree polynomial has a negative slope, ergo if we just happen to pick a point greater than the previous one, ta-da! The 3rd-degree polynomial fits the new set better than the 5th-degree. QED.
When put that way, the argument is completely idiotic. You could just as easily have picked a new point lying, say, on the 5th-degree polynomial and thus "prove" that it was a better fit for some yet-to-be-defined data than was the "non-clever" 3rd-degree polynomial. The analogy to the code is that it would be trivial to come up with new requirements which could be easily solved by the "clever" FP code and very difficult by the imperative-style code; and in fact the author admits as much in the second case.
By the end I can't help but wonder if this was satire, designed to make anyone agreeing with the article look silly when the author later comes out pointing out all the above...
- rkalfane 10y agoI honestly didn't see the same thing as you, my understanding is that using the Lagrange Interpolation is the "clever" choice, but when you add more points, you'll end up with a higher order polynomial and widely different curve which is probably not what you wanted in the beginning. I read the piece more as a reminder that most specs are usually incomplete/too specific/not conveying what is actually needed, and a warning against cornering oneself with a too clever solution. I also didn't see any big issues with their stance on FP, except maybe that they dismissed the Monoid solution that someone posted down in the comments that looks both robust and readable.
- deleted 10y ago[deleted]
- kirrent 10y agoAs a physics grad that curve fitting section was hard to read. Only very low degree polynomial fits can ever be used, through some coincidence with the underlying trend, for extrapolation. A polynomial fit is a simple and easy method to fit a curve which you can use for interpolation if you want. Unless you have some clearly identifiable trend, then extrapolation doesn't mean anything no matter what curve fitting method you use. It's like criticizing a Taylor series for diverging from the target function as you get far away from its centre. No shit that'll happen. It's the name of the game. I do have to agree that that section read a lot like satire.
- GFK_of_xmaspast 10y agoYou can get away with high-degree polynomial interpretation if you have control over the node locations, see for example Nick Trefethen's chebfun: http://www.chebfun.org http://www.chebfun.org and book: https://people.maths.ox.ac.uk/trefethen/ATAP/ https://people.maths.ox.ac.uk/trefethen/ATAP/
- alexandercrohde 10y agoSo I think what the article asks for (i.e. to bring some more objectivity into the "alchemy" of code preference) is a great ask. However I agree with you however that his examples feel cherry-picked (and I sense an annoyance at FP). I suppose the most valid case would be to both real world problems and real-world change-requests to those problems. I tried to make a programming challenge based around this premise: http://alexrohde.com/zennish/index.html#/challenges http://alexrohde.com/zennish/index.html#/challenges but it never seemed to interest many people.
- ulucs 10y agoBut with mathematics, nitpicking is ~kind of~ the point. For example when dealing with real numbers, you can get away with defining Compact sets as bounded and closed sets; however when you enter a different Topological space, that definition will surely fall apart. So in retrospect, defining compact as bounded and closed was working in your limited test cases (real numbers) but in the real world you really have to embrace that it means there exists an open cover that a finite subcover covers the set. It is not pretty or clever as the limited case, but it is what you need to do if you want applicable flexibility. Same with fitting polynomials to data. Statistics and Machine Learning specifically warn you of overfitting. You can get 0% training error if you try to fit MNIST with a 60,000th order polynomial, but can you imagine the test error rate?
- belovedeagle 10y ago> that definition will surely fall apart In what sense could that even conceivably be a true statement? I could define compact sets as sets which make me think of the color purple and it would be a completely valid definition. Nothing will fall apart. I think you are vaguely referring to the fact that proofs concerning compact sets in general topological spaces are not valid if you replace compact sets with bounded and closed sets, but that's just confusing the term "compact set" with what it refers to; the proofs aren't about the term but about the thing, which doesn't change. If "compact set" meant "bounded and closed" and, say, "cover-compact set" referred to sets where (ahem) every open cover has a finite subcover, then the concept of "cover-compact" will have certain general proofs associated to it and the term "compact" will have a different collection of general proofs associated to it. So in some ways you're making the same mistake the author did: carefully selecting a certain way to generalize a concept (real -> topological) and a certain ill-conceived claim about the original concept (compact=bounded and closed), and then acting all surprised when, oops!, the claim doesn't generalize.
- justifier 10y agoi agree with both of you i think we need to merge and supplant imperative and functional