4 ms·
It is faulty to think of the math notation and code being equivalent. The math states something much more general, and often much deeper, than some mundane for-
by reikonomusha 7y ago
It is faulty to think of the math notation and code being equivalent. The math states something much more general, and often much deeper, than some mundane for-loop. I’d have titled this “Python Recipes to Calculate Values of Simple Vector Math Expressions”.
Often times the symbols may not even be concrete numbers. Often the “real” number may not even be representable on a computer. Often a symbol does represent a concrete number but indirectly defined by some set of rules (e.g., x is the smallest eigenvalue of M; or y is the greatest value less than the supremum of f) that may require a whole library of code to calculate.
The mathematical notation is “meant” to be flexible and manipulated, not to be interpreted (necessarily) as a rigid computational process. It should also be noted that while some notation comes from convention, a lot of it is improvised and contextual!
- spinningslate 7y agoWell, yes. Sort of. How many people will be coming to the maths of machine learning but _not_ expecting to implement it in a programming language? Not denying your point: the maths is fundamentally broader. But the article doesn't refute that. The opening sentence makes that pretty clear: > When working with Machine Learning projects, you will come across a wide variety of equations that you need to implement in code.
- reikonomusha 7y agoI claim that even in the math of machine learning, many of the symbols presented do not mechanically translate as such. Other commenters have discussed differing notational conventions, but even to assume that x_i is indexing some real numbers is memory is often too much. I’m not saying there isn’t any value showing somebody how an elementary summation corresponds to a for-loop. I am saying it’s a lot more than that, though.
- roywiggins 7y agoThis is true, but much of math understanding comes from analogies. Summation over an infinite set is like mechanical summation over a finite one, etc. As a teaching tool I think it's valuable. But it's important not to identify the math with the analogies that are used to teach it.
- JackRabbitSlim 7y ago> The math states something much more general, and often much deeper, than some mundane for-loop Eh? Code can be just as generalized and "deep". The code may (probably) not be usefully executable, but it could describe any concept. At that point it's just "math" again, albeit with different format and symbols. So I guess your point stands, but its a very thin distinction of common usage.
- reikonomusha 7y agoCode can be studied, reasoned about, interpreted with some semantics, and often even turned into some manner of equations. Heck, Standard ML is even defined by a bunch of equations. But very rarely is code written for the same reason a mathematical expression is written. I agree code can be as you say, but most often isn't. Code, at the end of the day, more often than not, is written to express some logic to be executed by a computer. At least 80%, if not more than 98%, of code is written to express imperative commands to a machine. I say this as a fan of abstraction, Lisp, Prolog, etc. I just don't buy that s = 0 for x in a: s += x return s is interpreted with the same generality and depth as s := \sum_{x\in a} x, the latter of which is seen in and of itself more as an "object" which may or may not be used to represent a computation that the code above indicates.
- Jaxkr 7y agoYeah, but those deep general properties don’t matter to someone who can’t even evaluate the expression. I’ve encountered these math explanations through code before, and I think there a fantastic way to answer the question “what does this notation do?” I am currently taking an algorithms class and often ad hoc notation is introduced and explained through a code analogy. I think it’s a great way to help someone understand unfamiliar math notation quickly.
- dreamcompiler 7y agoYes. Math notation is independent of time and space. Code isn't. Math is a pineapple upside down cake. Code expresses one (of many!) recipes to produce one. The danger here is if you start equating math to code and you write an algorithm in, say, an imperative language on a uniprocessor, you can become blind to declarative/parallel solutions. The math is the Platonic ideal of the thing in question, and it doesn't change. Always keep the math in mind and don't get lost in the code.