I have two arrays $f(z)$ and $z$ both indexed by k and I want to solve $\frac{df}{dz}=\mu(1-f)$ to find $\mu(z)$
What would be the best numerical method to solve this equation?
I have two arrays $f(z)$ and $z$ both indexed by k and I want to solve $\frac{df}{dz}=\mu(1-f)$ to find $\mu(z)$
What would be the best numerical method to solve this equation?
What you have is a linear ODE-constrained parameter identification problem: given the two data arrays $(z_k,f_k)$ (indexed by $k$) and the ODE model (the constraint), find the parameter $\mu$ that best fits the data, where the notion of best is defined in a statistically precise way. A very simple example would be a least-squares type regularized functional
$$ \arg \min_\mu \sum_k \left( f_k - f(z_k) \right)^2 + \| \mu \|^2 \; {\rm subject \; to\;} f_z = \mu (1-f).$$
One approach to this would be to write it as an ODE-constrained optimization problem with a properly regularized cost function, then solve its discrete equivalent using a numerical method and off-the shelf optimizer, as exemplified in these slides (1). Note that the optimization algorithm used there is a local Newton-type procedure. This means, for most practical problems, that you will need a reasonably good initial guess for the Newton procedure to converge to a "good-quality" minimum point, i.e., to a $\bar\mu$ not "too far" (in some norm) from the unknown "true" parameter $\mu^{\rm true}$.
If local minima are a major concern, and you do not have a good "guess" at $\mu^{\rm true}$ to start your Newton routine from, then global optimization is an alternative (caveat emptor: these procedures are more computationally expensive than a local routine). Or you can bring out the best of the two approaches into a combined global/local optimization strategy.
If you don't have the time to implement all this, then there are other options to consider:
idgrey
, greyest
). The workflow for your problem is described in detail here.