I’ve been trying to fit some parameters to a curve but I need to put a constraint on one of the constants and I don’t know how to make my code acknowledge the constraints and fit a value with the correct value. I’ll try to write a simple example code just to show my problem:
def chi(paras):
mpi=paras[0:32]
cf=paras[32]
chif=0
for i in range(32):
chif+=((fpi-f(mpi,cf))/error)**2
return chif
m=Minuit.from_array_func(chi,parin,parstep,name=parname,errordef=1)
fmin,param=m.migrad(ncall=10000)
print(m.values)
I want for example cf<=np.log(mpi**2). I’ve tried for example:
if cf<=np.log(mpi**2):
chif+=((fpi-f(mpi,cf))/error)**2
else:
pass
but it hasn’t worked. Is there anyway to put this constraint in the code?