from matplotlib import cm from numpy linalg import norm import numpy as np def peaks ( , ) ( *( - )** np exp (-( ** ( + ** *( / ** ** np exp(- ** ** / np exp (-( + ** ** )return (zn - hammersley ([ , ,nz peaks ( [, , [, ]xx yy np mgrid - : : - : : jzz peaks (xx ,yyplt contour (xx ,yy ,zz levels = fig=plt figure (ax fig add_subplot ( projection =' 'ax plot_surface (xx ,yy ,zz rstride = cstride = color =' ',alpha = linewidth = ax scatter ( [, , [, ,zcolor =' ', = plt show (sig kernel parameter def ( , )return (np exp - norm(xu)** sig ) np zeros (( , )for in range ( )for in range ( ) [ ,jk( [ ,:, [ ]alpha np linalg solve ( @ tk@znxx flatten (shape kx np zeros (( , )for in range ( )for in range ( )kx[ ,jk( [ ,:np array (xx flatten ()[ ],yy flatten ()[ ]]) kx alpha dim np sqrt(nastype (intyhat reshape (dim ,dimplt contour (xx ,yy ,yhat levels = smoothing cubic splines striking application of kernel methods is to fitting "well-behavedfunctions to data key examples of "well-behavedfunctions are those that do not have large second