Gradient Ascent Demo

Some number (unedited code uses only one) of starting positions ("particles") are randomly selected. When update is pressed, each particle takes a small step in the direction of the gradient (first derivative in this case, since the function values are one-dimensional). A scaled histogram of particle positions is shown at bottom. Download code.