On 4/27/08, Justin Harford <blindstein at gmail.com> wrote:
> Here are some data
> pH as function of volume base added.
OK, you didn't state a model for this, so I guess pH = a0 + a1*exp(V/a2).
I copied the data into /tmp/pH.data . Then:
data : read_matrix("/tmp/pH.data");
load (draw);
draw2d (points (data));
eq : pH = a0 + a1*exp(V/a2);
load (lsquares);
mse : lsquares_mse (data, [V, pH], eq);
aa : lsquares_estimates_approximate (mse, [a0, a1, a2], initial = [1,
1, 1], tol = 1.0E-4);
=> [[a0 = 4.763752712967456, a1 = .06125878208051295, a2 = 5.300326897239077]]
subst (first (aa), eq);
=> pH = .06125878208051295*%e^(.1886676085055993*V) +4.763752712967456
draw2d (points (data), explicit (rhs (%), V, 5, 18));
lsquares_residuals (data, [V, pH], eq, first (aa));
=> <list of numbers>
I guess fitting an equation to data could be a pretty common operation;
maybe we can automate the process above somewhat.
HTH
Robert Dodier