You need to define ranges where
brute
will search for an optimum, e.g.grid = ((-1, 1, 0.1), (-1, 1, 0.1)) # Also, you can use slice objects for this: # grid = (slice(-1, 1, 0.1), slice(-1, 1, 0.1))Further, you need to define a function to be optimized:
def f(x, T): return (x[0] - T) ** 2 + (x[1] - T) ** 2And, finally, use
brute
to find the minimum:from scipy.optimize import brute brute(f, grid, (1,))