I've defined a function that references an array and broadcasts variables across that array. When the function is run, it works fine. However, when I attempt to use scipy.minimize to minimize the function I get the following error:
operands could not be broadcast together with shapes (75,) (2,)
Any help would be much appreciated!
import numpy as np
from scipy.optimize import minimize
a = [2, 4, 6, 5, 2]
b = 3
c = 4
def mult(x):
target = np.array(np.array(a) * x) + x
mean = np.mean(target)
sd = np.std(target)
mean_ch = np.abs(mean / b - 1)
sd_ch = np.abs(sd / c - 1)
total_ch = mean_ch + sd_ch
return total_ch
x0 = [2, 4]
minimize(mult, x0)