I would like to define a python function that has three parameters: C, psi, and m but it actually internally has an integral that is running based on another variable called eta.

def func(x: np.float64, C: np.float64, psi: np.float64, m: np.float64) -> np.float64:
    return C * (1-psi) * quad(np.power(1-eta, psi) * np.power(m/x, C/eta+1)/eta, 0, np.inf, args=(C, psi, m, x))[0]

Since I would like to fit this function to a dataset, I cannot choose eta to be a free parameter for fitting and hence it should not appear as a parameter in the function signature. But, python doesn't know the internal eta as a defined variable.

File "c:\Users\username\Desktop\Project\my_script.py", line 277, in func
    np.power(1 - eta, psi) * np.power(m / x, C/eta + 1) / eta, 0, np.inf,
NameError: name 'eta' is not defined

How can I let the function know that it is not expecting to be fed with a parameter but the inside integral takes care of that through integration.

---Thanks,

0

There are 0 answers