Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by n4r9 on Wednesday October 17, 2018 @06:45AM
(#18237794)
It is absolutely an algorithm in the sense of "a set of rules to be followed". I think you mean that it doesn't guarantee an optimal solution. That just means it's a heuristic algorithm, same as simulated annealing is a heuristic algorithm for solving optimisation problems.
[ Parent
| on HN ]
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by another-cuppa on Wednesday October 17, 2018 @08:37AM
(#18238346)
Nope. An algorithm has to be effective. You can find pathological cases for k-means such that it will never converge on anything useful. So if you set your termination case to be convergence it will never terminate and if you don't then it will never be effective.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by zaphar on Wednesday October 17, 2018 @09:00AM
(#18238498)
I think you might be in the minority in this opinion. Many algorithms have pathological cases but are still considered algorithms
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by another-cuppa on Wednesday October 17, 2018 @10:56AM
(#18239667)
Minority? This is directly from Knuth.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by bstamour on Wednesday October 17, 2018 @04:36PM
(#18243550)
Knuth defines effectiveness as: "... all of the operations to be performed in the algorithm must be sufficiently basic that they can in principle be done exactly and in a finite length of time by a man using paper and pencil."
K-means and other heuristic algorithms fit that description.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by skykooler on Wednesday October 17, 2018 @09:23AM
(#18238665)
BogoSort is an algorithm. Not a very good algorithm, but an algorithm nevertheless.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by another-cuppa on Wednesday October 17, 2018 @11:06AM
(#18239762)
No it absolutely is not.
The lack of fundamental computer science knowledge in this thread is alarming.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by another-cuppa on Wednesday October 17, 2018 @02:12PM
(#18241847)
Negative 2 points on a post saying that a computational method that possibly never terminates is not an algorithm... Oh dear...
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by wnoise on Wednesday October 17, 2018 @04:31PM
(#18243492)
It never terminates with probability 0.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by n4r9 on Wednesday October 17, 2018 @10:08AM
(#18239138)
As far as I can tell you're only arguing against poor implementations of K-means. If you demand that the score strictly improves at each iteration then the algorithm must terminate.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by another-cuppa on Wednesday October 17, 2018 @11:05AM
(#18239751)
And how do you "demand that the score strictly improves"? It's an NP-hard problem.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by n4r9 on Wednesday October 17, 2018 @11:42AM
(#18240133)
K-means implementations generally terminate once there's an iteration where the score doesn't improve. This happens when there is convergence to a local minimum or - less likely - the state hops between two nearby local minima with the same score. But it will terminate on something, and most of the time that something will be pretty good.
I saw your mention of Knuth elsewhere, I looked it up and he demanded that
> An algorithm must always terminate after a finite number of steps ... a very finite number, a reasonable number
This is a pretty niche characterization and almost certainly not what the original post was asking for. However, I concur that there is no guarantee on how quickly K-means terminates or on how good the output will be,. But... if you're going to be that strict about it you would even have to rule out the Simplex Algorithm, which everyone I've ever spoken to thinks of as an algorithm.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by billfruit on Wednesday October 17, 2018 @09:13AM
(#18238588)
In that sense kmeans may be better referred to as a 'computational method' rather than an algorithm.
Re:Ask HN: What's your favorite elegant/beautiful algorithm?
by another-cuppa on Wednesday October 17, 2018 @11:43AM
(#18240147)
Indeed.