Wednesday, November 12, 2014
Using Grid Searches to Optimize a Fit
We were able to estimate the reaction rate constants from functions of three unknown parameters and to improve the fit with a simple search for k0. For a better fit we need to search for all three unknown parameters. We can choose X0, Xeq and k0 as the unknown parameters with X = A - A0 being the amount of product at some particular time. X simplifies the formulas which is the reason why it was chosen. We have estimates for Xeq and k0 determined by the data points and can search the neighborhood of the values for the best fit. So a three dimensional grid search will allow us to improve on our initial estimates. Here is a sample of how one might start out. The first three lines determine the bounds of the search and the next three compute the grid points. X0 was initially assumed to be a small positive number.
I wrote a Mathcad program to do the search for the integers λ, μ and ν which give the lowest value for the variance, V, of A and A'.
Three such searches zoomed in on values very close to the original values.
They give a relative rms error for the fit of about three tenth of one percent. The fit of the "lower left corner" is also much better.
An error propagation formula will help us determine how errors in the grid search parameters will affect the final results. We can estimate how two independent variables, x and y, affect a third dependent variable, z, starting with the chain rule. If dx and dy represent small errors then the chain rule gives us a good estimate of dz. The formula can be modified to give the rms error of dz but we need to use an inequality to express it in terms of the rms errors of dx and dy. One can choose the right hand side of the last equation to represent a bound for the rms error of dz. One usually sees this propagation of error formula written as an equality.
The formula for the propagation of error can be used to give the expected relative errors of the computed parameters for the fit based on the relative errors of the fit variables. The matrix Λ was found by applying the propagation of error formula to each of the computed variables and evaluating it using estimated values. The differences between the fit values and original values can be used to get approximations for the relative errors of the fit variables. The bottom left shows the expected bounds and can be thought of as standard deviations. The bottom right shows the z-scores for the the actual relative errors.
The grid search we used isn't optimal but it allows us to improve on the original estimate which a plot showed to be slightly off. The final result is what can be expected from a grid search.
Supplemental (Nov 12): The program p_min(V) puts the rows of a table containing the pointer p and corresponding V values in the order of the V values. The resulting location for the minimum value of V is the first p value on the new table.
No comments:
Post a Comment