Closed chrismarsden7 closed 2 years ago
Hi Chris,
the main issue here is that you made 2 typoes in the bounds of alpha_m and alpha_n, rather than define a min/max you define the min twice. However, there's more going on, so I'll keep the response I typed originally down here as well. If you take xdata = np.linspace(1e-16, 1, 101, endpoint=False)
(see below) with the appropriate bounds it works.
Happy fitting! Peter
Hi Chris,
I also have issues getting this to work properly :\
There are a few things going on I think, and a workaround at the end.
Your model (( 1.0 - x**alpha_m )**alpha_n * L * beta0 / Rax
) has a few problematic properties, the first of which is that L
, beta0
, and Rax
are effectively identical (I'm inclined to say colinear, but I'm not 100% sure on the jargon here), meaning that any change/error in one of the three I can be corrected with the others. This will lead to infinite covariances between these variables, and their individual values will be meaningless.
Secondly, symfit uses the first (Jacobian) and sometimes second (Hessian) derivatives of your model wrt the parameters. In your model these contain discontinuities:
d [(1-x**a)**b]/da = -b x**a log(x) (1-x**a)**(b-1)
has a discontinuity at x=0d [(1-x**a)**b]/db = (1-x**a)**b log(1-x**a)
has a discontinuity at x=1If you limit your x range to x=0.1 to x=0.9 and fix L to 5e5 the fit already behaves much much better. From there you can either play with the initial guesses, or go for a derivative free minimizer such as Nelder-Mead or Powell (from symfit.core.minimizers import NelderMead, Powell
), but those will ignore your bounds (this is where I realized there's an issue with your bounds). Alternatively if it's not cooperating and you're tired of tweaking initial guesses you can try the DifferentialEvolution global minimizer. Will take a bit longer to run the fit though.
Hi, I'm trying to use Symfit for the first time to fit a simple parabolic function. I have provided code below to re-create the issue, with the solver not finding a result and throwing up error messages that I don't fully understand. I have generated fake data (xdata,ydata) using exactly the same functional form as the function used to fit said data. The initial guesses I choose seem to have no effect on what the solver is doing.
Cheers, Chris