Earlier quoted context omitted.
Isn't a method that gives an approximate or best-fit estimate to a problem still an algorithm, if it terminates?
No. You can't prove that k-means does anything useful.
Ask HN: What's your favorite elegant/beautiful algorithm?
231–240 of 507 posts
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#232Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#233Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#234Earlier quoted context omitted.
I prefer mean-shift for it's simplicity, as it even creates it's own clusters.
Could you explain what you mean by that a little more? I looked at the Clustering section of the Wikipedia page for Mean-Shift: https://en.wikipedia.org/wiki/Mean_shift#Clustering but I don't get how C and r are chosen, nor how the method is supposed to be "non-parametric" given that you need such parameters to begin with. Also, how are you supposed to assign all points to separate clusters, and how would you determi…
> So how does mean shift come into the picture? Mean shift exploits this KDE idea by imagining what the points would do if they all climbed up hill to the nearest peak on the KDE surface. It does so by iteratively shifting each point uphill until it reaches a peak.
I wonder if this would still work with high-dimensional data. Distance and space start to act weird in higher dimensions, right?
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#235Duff's device. Because you will first look at it in disgust, but then you realize how clever it really is. See: https://en.wikipedia.org/wiki/Duff%27s_device
Quite a few EA Sports games have Duff's Device in locations of computational bottlenecks. I know because I put them there. Wonderful little mechanism.
(I was still quite wet behind the ears at the time, so it's also more than possible that I was just doing something wrong.)
All that said, agreed, wonderful little mechanism. It's one of those things that every C programmer should take the time to really understand.
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#2361. The "Skew Algorithm", aka "DC3", aka Kärkkäinen-Sanders. It uses radix sort in an extremely brilliant way to construct suffix arrays in linear time. I found these explanations helpful (though it still took me some time to digest): http://www.mi.fu-berlin.de/wiki/pub/ABI/SS13Lecture3Material... 2. Fast Fourier transform (FFT). It's another quite brilliant algorithm used for decomposing a function into its frequency…
I would also vote for FFT. It's amazing how widely it's used and what sort of tricks you can do in frequency domain. Multiplying polynomials? Simple! Multiple 2D projections of a 3D object? Just FFT them, do a couple of simple steps and you will get a 3D model.
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#237Earlier quoted context omitted.
...wait, how? I’ve never heard of a use like this.
If f is monotonic and continuous, you can solve f(x) = y for x by successively narrowing an interval [a, b] where f(a) <= y <= f(b) (or vice versa for decreasing functions). In the case that the range of f spans the entire real numbers, the initial range can be determined as the smallest range [-2^k, 2^k] where k is an integer (a strategy often used for open-ended binary search).
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#238Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#239I've always appreciated the Bresenham's line algorithm. It's a very simple algorithm and has been "superseded" by Xiaolin Wu's line which can also do antialiasing, but ever since I learnt about it, I've been very fond of it. Also the fact that it's an algorithm for use in computer graphics helps, because for me it's very easy to get excited about visual stuff as opposed to the more abstract CS stuff, which I have dee…
Re: Ask HN: What's your favorite elegant/beautiful algorithm?
#240The solution usually lives in an infinite dimensional Hilbert space, whereas our space of possible approximate solutions is a finite-dimensional subspace.
To find the "best" solution that lives in the finite-dimensional basis-function (or trial function) space, we simply choose the coefficients of the basis functions such that the residual is orthogonal to the approximate solution.