3 ms·
The only problem with this is that I don't personally find it obvious/intuitive that (1,0) + (1,2,3,4,5,6) = (2,2,4,4,6,6). In fact, I would probably expect th
by Closi 5y ago
The only problem with this is that I don't personally find it obvious/intuitive that (1,0) + (1,2,3,4,5,6) = (2,2,4,4,6,6).
In fact, I would probably expect the output to be (1,0,1,2,3,4,5,6).
- CapmCrackaWaka 5y agoI guess that's the difference between people who prefer R vs. people who use more traditional languages. '+' means addition in the scientific world, if I'm trying to figure out how to add numbers the first thing I try is '+'. To me, those vectors are just that - vectors of numbers, not instances of a class (even though that is kind of true under the hood). I have a problem I want to solve, and R does a good job of giving me what I want.
- Karrot_Kream 5y agoIndeed, no mathematician or statistician would think of `+` as concatenation. List concatenation isn't a relevant problem to most mathematicians. This is where the above comments about prior knowledge and context come into play. Likewise, when I multiply two vectors together, or multiply a scalar with a vector, I have a definite idea what I "want" out of that multiplication. For many programmers, they think of this more as an exercise in data-types than an expression of linear algebra.
- Closi 5y agoStatisticians might see it differently, but I still don’t think it’s obvious that (1,0) represents effectively a repeating pattern that’s extended to the size of the other vector. For instance, for the statement (a,b,c,d,e) + (a,b,c,d,e,f) are we really all saying that it’s clear, obvious and unambiguous that this means (a+a, b+b, c+c, d+d, e+e, f+a). Personally if you showed me that and asked me to describe what would happen before reading this thread, I would have said it would either throw an error, concatenate the vectors or only add the matching elements. I wouldn’t personally guess that the first vector would be treated as a repeating sequence, but different people might make different assumptions - I just don’t think it’s particularly clear, and I struggle to believe it’s clear, unambiguous and obvious to statisticians too.
- Karrot_Kream 5y ago> I would have said it would either throw an error, concatenate the vectors or only add the matching elements Heh this itself is common evidence of an (experienced) programmer's way of thinking. Remember, when dealing with mathematics, there's no machine (or runtime or similar abstraction) there lurking in the background, enforcing conditions, or even lending a physical reality. Operations in mathematics are defined. Notation in mathematics is just an operation encoded as an "arbitrary" symbol. Which leads to > I just don’t think it’s particularly clear, and I struggle to believe it’s clear, unambiguous and obvious to statisticians too. This happens to be convention in both a subset of textbooks and many programming environments. It's mostly an artifact of the notation. If you want to explore what math notation "feels like" a bit more without learning math (which I _wholeheartedly_ recommend as it's incredibly useful), try out the APL programming language a bit. It evokes a similar atmosphere of notation conveying the idea of well-defined operations.