0
$\begingroup$

enter image description here

I need a similar (or the same) 2D surface to the one in the picture to produce some plots of my own experiments. Any ideas how can I find $f(x, y)$ of this surface?

PS: The picture is taken from Andrew NG's Coursera Machine Learning class, week 5.

  • 0
    How are you getting the data? Is this picture all you have that you are working off of?2017-02-21
  • 0
    Yes. I do not have the data. This is just a visualization of gradient descent. He does not mention about the closed form formula of this data and he does not give any data that has this behavior. I just want to produce something similar to this surface.2017-02-21
  • 0
    Then it seems really unlikely that you are going to be able to express this as an explicit function. You are probably better off estimating points and just using them to build a new surface or just ignoring the surface and only using the points.2017-02-21
  • 0
    I was thinking of making a mixture of 2d gaussian distributions with fine tuning the parameters manually. Would it be similar enough to this? The reason I asked this question here is that I thought maybe this surface is sort of "famous" surface people use which everybody knows the formula.2017-02-21
  • 0
    I definitely don't know it, but that doesn't mean it isn't famous among those who work in Machine Learning perhaps.2017-02-21

1 Answers 1

0

Okay. I gave some time to this, and here is what I found.

Matlab/octave has a function called peaks. This function plots the following function on 2d surface:

$$ \begin{align} f(x,y) &= 3*(1-x)^2*exp(-x^2 - (y+1)^2) \dots \\ & - 10*(x/5 - x^3 - y^5)*exp(-x^2-y^2) \dots \\ & - 1/3*exp(-(x+1)^2 - y^2) \end{align} $$

This is a pretty interesting surface. Here is the visualization:

enter image description here

Before finding peaks function, I was trying to mix couple 2d gaussian distributions. Here is the octave code that I wrote:

tx = linspace (-3, 3, 100)';
[xx, yy] = meshgrid (tx, tx);

% Each row contains a 2D gaussian parameters in the form:
% f(x, y) = A * exp(- (( ((x_0 - x)^2 ) / (2 * sigma_0^2) ) +
%                      ( ((y_0 - y)^2 ) / (2 * sigma_1^2) ) ) );
% in this order: A, x_0, y_0, sigma_0, sigma_1.

p = [ 1.80     0       1.7     0.55      0.55;
     -1.30    -0.5    -1.5     0.45      0.45;
     -0.45    -1.5     0.5     0.40      0.40;
      0.95    -0.5    -0.5     0.55      0.55;
      0.95     1.5     0       0.55      0.55; ]; 

zz = zeros( size(xx) );

for i=1:size(p, 1)
    zz += p(i,1) * exp(- (( ((xx-p(i,2)).^2) / (2 * p(i,4) ^ 2) ) +
                          ( ((yy-p(i,3)).^2) / (2 * p(i,5) ^ 2) )) );
end

surf(xx, yy, zz);

Here is the plot of the octave code:

enter image description here

The advantage of using the sum of gaussians over peaks function is that one can easily change the surface by playing with the mean and sigma values whichever the way he/she wants the surface to be.