ugly weird expression to be passed to R??



On 7/31/08, dlakelan <dlakelan at street-artists.org> wrote:

> I have 800+ data points, so I calculated the probability density
>  expression "p" from my expression for the cumulative distribution
>  function, created a function that calculates -log(p) and then created a
>  sum of 800+ terms from the data points and handed that massive
>  expression to LBFGS. It takes several seconds to calculate the
>  expression, and god help you if you forget the $ at the end and it
>  prints the damn thing, but I didn't see an easier way because I thought
>  LBFGS would want to take derivatives of the expression for its
>  minimization??

Well, yes, lbfgs calculates the gradient of the figure of merit
if it is not supplied, but I think a symbolic summation should work,
because apparently

diff ('sum (foo (x, i), i, 1, n), x);
 => 'sum('diff(foo(x, i), x, 1), i, 1, n)

and I think that's enough to compute the gradient for lbfgs.
I didn't try it; if you could try it and let us know how it turns
out, I'd be interested to hear about it.

I was a little surprised by this ---

diff ('sum (foo (x, i), i, 1, inf), x);
 => 'sum('diff(foo(x,i),x,1),i,1,inf)

Anyone else?

best

Robert Dodier