Jul-17-2020, 05:53 AM
Within
multi_gaussian
the params
variable will be interpreted as a tuple of size 3 * n + 1
. So, the answer to your question would be something like the following:def multi_gaussian(x, *params): y0 = params[0] n_gauss = (len(params) - 1) // 3 y = y0 * np.ones_like(x) # ??? for i in range(n_gauss): parameters = params[1+3*i:1+3*i + 3] y += gaussian(x, *parameters) return yHowever, you probably need to check if
len(params)
is correct (e.g. len(params) - 1 is divisible by 3).