the function has many local minima and maximawith global minimum around the figure also illustrates the relationship between and the (unnormalizedgibbs pdf ft the following python code implements slight variant of algorithm whereinstead of stopping after fixed number of iterationsthe algorithm stops when the temperature is lower than some threshold (here - instead of stopping after fixed number of iterations or when the temperature is low enoughit is useful to stop when consecutive function values are closer than some distance to each otheror when the best found function value has not changed over fixed number of iterations for "currentstate xthe proposal state is here drawn from the ( distribution we use geometric cooling with decay parameter and initial temperature we set the initial state to figure depicts realization of the sequence of states xt for after initially fluctuating wildlythe sequence settles down to value around with ( - corresponding to the global optimizer and minimumrespectively simann py import numpy as np import matplotlib pyplot as plt def wiggly ( ) -np exp( ** / *np sin ( * - ** ** np sin ( - * ** ** ind np vstack (np argwhere ( )) [ind ]float ('inf 'return wiggly beta sig = xnp array ([ ]xx =[sx= (xwhile > **- ) =beta* +sig*np random randn (sy (yalpha np amin (np exp (-(sy -sx)/ , )if np random uniform (<alpha = sx=sy xx=np hstack ((xx , )print ('minimizer {: }minimum ={: }format ( [ sx [ ])plt plot(xxplt show (minimizer minimum -