how to find the best parameters to solve a differential equation?

2

I have a differential equation:

def func(Y, t, r, p, K, alpha):
    return r * (Y ** p) * (1 - (Y / K) ** alpha)

and I want to find the best parameters that fit (r,p,K,alpha). I tried to use curve fit but it was too bad, this is my code

# I chose the value of maxfev randomly
popt, pcov = curve_fit(func, df.index, df.Value,method='lm',maxfev = 8000)

t = np.linspace(0, len(df), len(df))
y0 = popt[0]
params = (popt[1], popt[2], popt[3], popt[4]) # r, p, K, alpha
sol = odeint(func, y0, t, args=params)

and this the plot:

enter image description here

Note: this is how my real data looks like:

enter image description here

what I'm looking for it the best values for (r,p,K and alpha), how to find them?

Hassan

Posted 2020-07-12T21:14:36.383

Reputation: 21

Answers

0

If nothing else is possible, you could try using a genetic algorithm.

Erwan

Posted 2020-07-12T21:14:36.383

Reputation: 12 600