24 points · by niyazpk · 17y ago · 43 comments
Runner up for me would be K-means clustering, one specific implementation of it.
let me have a look, I think I downloaded the code.
edit: I can't find it in a couple of minutes, I was interested in it because one of the companies I'm involved in needed a way to classify items without any prior knowledge of the number of groups so I read up on that.
The most interesting feature of that particular implementation was how they chose their initial 'seeds', that is a big factor in how long it takes for the algorithm to converge on a solution.
I'll keep looking for it, I'm fairly sure I have at least a bunch of references to it in an email and a copy of some papers on my harddrive somewhere. Note to self: get organized better.
There are a variety of implementations that speed this process up. One is canopy clustering which allows you specify which clusters the points will check with (ie checking with all the clusters takes a while, but canopies can limit the search). You can also try different distance metrics such as the triangle inequality.
There should be lots of implementations online, specifically for Matlab which you can port over to another language if you wanted. It's one of the most widely used and most useful clustering algorithms and often provides initialization for lots of other algorithms such as Expectation Maximization (EM).
This link comes to mind: http://cseweb.ucsd.edu/~elkan/fastkmeans.html
TeX: by a large margin the best-documented substantial piece of code I've ever seen, and (by now) with an extremely low bug count. As for the actual code, there's plenty to love and plenty to hate.
Lots of things in Norvig's "Paradigms of artificial intelligence programming". Nothing in there is really astonishing, but the standard is consistently extremely high and of course it's accompanied by a wealth of insightful comment, namely the actual text of the book.
Various bits of low-level bit-twiddling. I love the population-count trick that begins with x & 0x55555555, but typically it's not actually the best way to do the job (four lookups in a 256-element table will usually be faster), so instead I'll pick the trick for finding whether a word has a zero-byte in it (useful, e.g., for operations like strlen), the idea of which is basically to subtract 0x01010101 and look for evidence of borrows across byte boundaries.
Hard as I try, I cannot for the love of god single out one piece among them. Interestingly, I can immediatly name the worst piece of source code I have ever seen: SAP DB. (I don't even know whether it's still available online, but it was ugly {formatting inconsistent, somplaces littered with German comments, etc.}--there are shurely better contenders for this place, but the fact that one of the biggest software companies produced it, let alone having clients using it sent shivers down my spine...)
EDIT: PageRank, how could I have forgotten...
I can see why formatting would not make it pretty but that would not say much about the algorithm, and why would German comments be ugly ? Programmers in different countries routinely comment their code in their native language, it's only natural really.
ad Language: Of course its only natural, albeit unprofessional. I would expect anybody in a project to code using English, comments and identifiers--regardless of where the people actually come from. IMHO this is good coding practice, but probably you have different experiences.
Personally I code up all my stuff with identifiers, function names and comments in English.
But I can't see why a German company writing code would be chastised for writing their code in German.
I'd rather have them use German and do it properly than in broken English. Now in Germany most if not all programmers will be fluent (to some degree) in English, but in plenty of other countries that is not the case.
Being able to program should not come with an automatic requirement to be fluent in English as well.
Obviously there are issues with character sets when writing comments, plenty of language implementations wouldn't know what to do if you threw utf-8 at them, but I think that any modern implementation should allow for identifier names and comments to be in any language. Why should the English speaking world get a free pass here, and everybody else be at a disadvantage ?
Why? This might make sense for open source code at the moment, but if it's code internal to (say) a German organization, commenting in the native language of the coders is likely to be easier and lead to less confusion.
Another impressive stuff are IMHO genetic programming, neural networks and language interpreters. Every programmer should play with this stuff.
http://betterexplained.com/articles/understanding-quakes-fas...