### Merge branch 'saad-master-patch-76208' into 'master'

```Fixed a few typos.

See merge request !7```
parents 96340f3f 67328c19
 ... ... @@ -5,8 +5,8 @@ % I tend to run 'matlab -nodesktop' and then cut and paste from an editor % into the matlab terminal window. But I hope it works well in the matlab % GUI too for those who prefer that. % The practical will only cover Newtons Method (with it's variant Levenberg) % and the Gauss-Newton method (and it's variant Levenberg-Marquardt). But % The practical will only cover Newton's Method (with its variant Levenberg) % and the Gauss-Newton method (and its variant Levenberg-Marquardt). But % I think that will be plenty. % % Jesper Andersson ... ... @@ -32,7 +32,7 @@ ylabel('y'); % From that plot you get an overview of the function, but it is very hard % to see along the valley the actual minimum is located. So to aid in that % to see along the valley where the actual minimum is located. So to aid in that % we will make our own colormap that is densely sampled in the range of % values that constitute the valley, and sparsely sampled elsewhere. ... ... @@ -110,7 +110,7 @@ p = [xp; yp]; % proxy(x,y) = f_xp + grad'*[x-xp; y-yp] + (1/2)*[x-xp; y-yp]'*H*[x-xp; y-yp]; % Let us now calculate this proxy-function for a neighbourhood % around our starting point. Not that for better visualiation % around our starting point. Note that for better visualisation % you might need to modify the neighbourhood if you have picked % a different starting point. ... ... @@ -225,7 +225,7 @@ d2f_dxdy = diff(zp,xp,yp) % And this is what the gradient and Hessian looks like. % I am glad I didn't have to do that by hand. % It demonstrates a little why Newton's method isn't % everyones cup of tea. % everyone's cup of tea. % xp=1.1; yp=-0.8; ... ... @@ -288,7 +288,7 @@ proxy = zp + grad(1).*(xn-xp) + grad(2).*(yn-yp) + 0.5*pH(1,1).*(xn-xp).^2 + 0.5 refresh_peaks(x,y,xp,yp); % Similar to refresh_rosenbrock alpha(0.5); % To improve visibility in the 3D plot surf(xn,yn,proxy); pause(5); % Too allow some time to see the proxy function pause(5); % To allow some time to see the proxy function % Next show where the corresponding step takes us np = [xp; yp] - inv(pH)*grad; pp = [[xp; yp] np]; ... ... @@ -297,13 +297,13 @@ refresh_peaks(x,y,xp,yp); plot3(pp(1,2),pp(2,2),real_f,'ro','MarkerSize',10,'MarkerFaceColor','b','MarkerEdgeColor','y','LineWidth',3); % Again, take some time to rotate it to see where the new point ended up. % Not that the new point is blue with yellow border. This is to allow it % Note that the new point is blue with yellow border. This is to allow it % to be easily seen regardless of where on the surface it ends up. % If you happened to pick lambda=15, you would have seen it take a step % almost straight down to the minimum. That is a _fluke_. What you expect % from a step with a non-negligible lambda is for it to take a step in % "the right direction", i.e. so that the cost-function decreases. You % don't neccessarily expect the step to be very good. % don't necessarily expect the step to be very good. % As before, you can keep playing with the lines of code above. Cutting % and pasting, and following the algorithm as it proceeds towards the ... ... @@ -329,7 +329,7 @@ plot3(pp(1,2),pp(2,2),real_f,'ro','MarkerSize',10,'MarkerFaceColor','b','MarkerE % % % The final think we will do in this practical is to take a look at % The final thing we will do in this practical is to take a look at % a variant of Newton's method called "The Gauss-Newton method". % It seems kind of likely that, between them, Gauss and Newton should % be able to come up with something quite good. ... ... @@ -376,7 +376,7 @@ cf = sum((y - b(1)*exp(b(2)*x)).^2) % The former formulation is more useful for our calculations, % but the latter might be easier to think about when we derive % expressions for the derivaties and the Hessian. % expressions for the derivatives and the Hessian. % Let us denote our generative model by f(b1,b2:x), i.e. it is a % function of b1 and b2, given x. And remember that once we have the % data x is a constant. ... ... @@ -450,7 +450,7 @@ end lcm(length(scm),:) = scm(length(scm),:); colormap(lcm); % And let us a pick a starting point and show it on the graph % And let us pick a starting point and show it on the graph % Feel free to pick a different one to me. b = [4 0.08]; fb = (y - b(1)*exp(b(2)*x))' * (y - b(1)*exp(b(2)*x)); ... ... @@ -557,7 +557,7 @@ plot3(nb(1),nb(2),fnb,'ro','MarkerSize',12,'MarkerFaceColor','b','MarkerEdgeColo % And the full Levenberg-Marquardt algorithm proceeds analogously % to the Levenberg (see pseudo code above). Feel free to take a % few more steps, or even implement your own Levenberg-Marquardt % algorithm based. % algorithm. % The last thing we are going to do is to introduce you to the % concept of the Jacobian. The Jacobian is simply the Nxm matrix ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!