8 ms·
I used to use it a lot, but the python libraries are much further ahead at this point. For my uses (essentially image processing and statistics) Octave is alway
by fluidcruft 4y ago
I used to use it a lot, but the python libraries are much further ahead at this point. For my uses (essentially image processing and statistics) Octave is always playing catchup with Matlab but python is mostly at par or ahead of Matlab. With the exception of the parallel stuff... but that wasn't anything Octave had either. Eventually when I need performance again I'll see about figuring out how to migrate parts to Julia. One thing I like about the python things is there are some hints of IDL in there (I'm a masochist and liked IDL... Matlab frustrates me at times). Matlab was great for slapping quick UIs together and making little tools, but Jupyter works well enough for that.
The 0 indexing in python does really and truly suck sometimes though.
- dr_zoidberg 4y ago> The 0 indexing in python does really and truly suck sometimes though. Now that's something you usually don't hear. At my university I heard a bit of "urban legend" about how back in the day (think early 1990's) a couple of professors got a peer-reviewed article published because they found out that Matlabs 1-indexed implementation of some algorithm resulted in numerical errors, which they measured and corrected. Don't really remember the details, and most of those involved have already retired.
- ogogmad 4y agoWhat you've said isn't surprising. The problem isn't whether 0 or 1 are "right" or not, it's the inconsistency. It makes transcribing something from a textbook harder, because the indexing logic in a textbook algorithm can get quite intricate. It's even worse if they use slices like M[i:j,m:n]. Indexing from 1 is the standard in many areas, going back many decades. SWEs have adopted a different convention.
- enriquto 4y agobut this depends a lot on the particular formula. For example, if you use discrete Furier transforms, all formulas are natural with 0-indexing, but weird with 1-indexing. In general, when the indices of an array are to be interpreted as modulo N, you want them to be 0, 1, ..., N-1 It is inevitable to have to use both conventions if you do varied math stuff. Thus, you will never be happy.
- ethbr0 4y ago(Obligatory) There are only 2 hard problems in computer science: cache invalidation, naming things, and off-by-one errors
- fluidcruft 4y agoI just never find myself working out formulae/series/proofs on paper using zero-indexing. When you look up derivations/solutions in books and references they're one indexed. A recent example was a formula that had a (n-1)!*n! term that made sense from understanding the derivation. But I forgot to code it as (n-2)!*(n-1)! at first. So you end up having to translate from one-indexed derivations to zero-indexed code and it leads to different bugs. Ultimately zero-indexing just trades one layer of bugs for another. IMHO zero-indexing makes sense to people thinking about the machine, not necessarily the work people are trying to use the machine to do. To be fair sometimes the opposite is true and zero-indexing gives less complex expressions.
- hgomersall 4y agoThere are good reasons why indexing from zero with exclusive upper bounds should be preferred. I'll defer to Dijkstra for the explanation: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...
- fluidcruft 4y agoBecause it's intuitive that an array contains an element before the first element?
- hgomersall 4y agoIs this a pithy response? The first element is indexed by zero.
- fluidcruft 4y agoIsn't dropping Dijkstra links as an appeal to authority about 0-indexing considered a pithy response? How about I drop a link about Einstein Notation with a curt observation that there are good reasons it uses both zero and one indexing simultaneously? As I said it depends on how you are thinking about things. Indexing makes sense to people who are focusing only on the machine.
- abdullahkhalids 4y agoThe 0 indexing is something one can get used to. On the other hand the fact that range(k,n) goes from k,...,n-1 is the most annoying part.
- whatshisface 4y agoThat's so that range(10) has 10 items in it.
- abdullahkhalids 4y agoYes. But when I use invoke range(k,n) or list[k:n] I intend to do operations on some specific items, not repeat some operations 10 times. So every time I see `for i in range(10)`, I have to do the mental computation: I am repeating this operation on numbers from 0,...,9. I would rather write `for i in range(9)` and know that I am operating on 0,..,9.
- hgomersall 4y agoFor anyone that spends significant time using these languages, those mental mappings are as natural as the one you seem to think is obvious - then the additional advantages of the approach become apparent. Exclusive upper bounds mean slices work neatly: a[0:10], a[10:20], a[20:30] etc. That's very neatly represented in a loop from zero in steps of ten. That pattern turns up all over the place when accessing arrays. I've spent enough time in MATLAB to have been scarred by that kind of array slicing and off-by-one errors.
- xigoi 4y agoThis has the nice advantage that range(k,n) + range(n,m) == range(k,m).
- twangist 4y agoThe 1-based indexing in Matlab does truly suck, all the time.