多参数估计。广播问题

Multiple Parameter Estimation. Problems with broadcasting

我需要通过非线性最小二乘回归获得参数(kf、beta1、beta2、gamma)。 错误信息是: "ValueError: operands could not be broadcast together with shapes (4,7) (0,)"

我用接下来收集的数据做了 4 个实验:

我想结合使用四个实验来最小化参数估计的误差。

import numpy as np
from scipy.optimize import leastsq

flux = [flujo_ms, flujo_ms, flujo_ms, flujo_ms]
brfv = [[0.00694] * 7, [0.00972] * 7, [0.0139] * 7, [0.0208]*7]
fr = [fr1, fr2, fr3, fr4]


def foulingRate(parameters, flux, brfv, mlts=8.22):
    kf, beta1, beta2, gamma = parameters
    FR = kf * np.exp(flux * (beta1 * brfv + beta2 * mlts + gamma))
    return FR


def objective(pars, yData, xData, brfv):
    # it will minimize this function
    err = yData - foulingRate(pars, xData, brfv)
    return err

x0 = [5.6 * 10 ** -4, -2.48 * 10 ** 8, 5.1 * 10 ** 4,
      2.81 * 10 ** 6]  # initial values for the parameters

plsq = leastsq(objective, x0, args=(fr, flux, brfv))
print("Fitted parameters = {0}".format(plsq[0]))

我找到了解决办法。我使用了模块 lmfit:cars9.uchicago.edu/software/python/lmfit