human
Write me a the Python code you requested given the following:
I am working on the file "MLR/An_Exclusive_Guide_to_Exclusion_Limits.ipynb".
The first task is:
Again, not bad for the number of trials.
TODO

Extend the problem by letting the bump position vary.
Make brazil plot
Can you write Python code for it?
assistant
#Here is the Python code you requested.

def find_bestfit(data):
    N = 20
    bkgs = np.linspace(0, 2000, N)
    sigs = np.linspace(0, 2000, N)
    pos  = np.linspace(0, 100, N)
    
    points = np.array(np.meshgrid(bkgs, sigs, pos)).T.reshape(-1,3)
    ts = list(map(lambda x: -2*lnLike(x[0], x[1], data, mu=x[2]), points))
    start = points[np.argmin(ts),:]

    return minimize(lambda x: -2*lnLike(x[0], x[1], data, mu=x[2]), start)
    
def TS_pos(sig_norm, sig_pos, data, bestfit=None):
    numerator = minimize(lambda b: -2*lnLike(b, sig_norm, data, mu=sig_pos), 1e3)
    if not bestfit:
        bestfit = minimize(lambda x: -2*lnLike(x[0], x[1], data, mu=x[2]), 
                           (1e3, 1e3, 1e1))
    return numerator.fun - bestfit.fun

def visualise_TS_pos(data, signormlim=(500, 1500), sigposlim=(1,100), ax=None, title=None):
    if ax is None:
        fig, ax = plt.subplots()
    
    def starting_point(data):
        N = 20
        bkgs = np.linspace(0, 2000, N)
        sigs = np.linspace(0, 2000, N)
        pos  = np.linspace(0, 100, N)
    
        points = np.array(np.meshgrid(bkgs, sigs, pos)).T.reshape(-1,3)
        ts = list(map(lambda x: -2*lnLike(x[0], x[1], data, mu=x[2]), points))
        return points[np.argmin(ts),:]
    
    bestfit = minimize(lambda x: -2*lnLike(x[0], x[1], data, mu=x[2]), starting_point(data))
    print(bestfit)
    sig_pos = np.logspace(*np.log10(sigposlim), 50)
    sig_norms = np.linspace(*signormlim, 100)
    ts = [[TS_pos(n, p, data, bestfit=bestfit) for n in sig_norms] for p in sig_pos]
    X, Y = np.meshgrid(sig_pos, sig_norms)
    Z = np.array(ts).T

    r = ax.contourf(X, Y, Z, 100, cmap='Blues_r')
    plt.colorbar(r, label='TS', ax=ax)
    ax.contour(X, Y, Z, colors='white', levels=[5.991])
    
    ax.set_xlim(*sigposlim)
    ax.set_ylim(*signormlim)
    ax.set_xscale('log')
    ax.set_xlabel('Signal Position')
    ax.set_ylabel('Signal Normalisation')
    ax.set_title(title)

fig, axes = plt.subplots(ncols=3, nrows=2, figsize=(14,8))
for i, p in enumerate([3, 10, 20]):
    d =...