working with likelihood functions



Welcome to Maxima!

> loglik : sum(loglik_1, i, 1, 10);
> ... gave me 10 * loglik_1 for a single arbitrary $i$.

This is a bug.  I have made a full bug report, with suggested
correction, in
http://sourceforge.net/tracker/index.php?func=detail&aid=740134&group_id
=4933&atid=104933.  It is possible that others on the list do not
consider it a bug, but a feature, a surprising but consistent
consequence of Maxima's evaluation rules.  I argue in the bug report
that this is not correct, and that there is a sensible way to handle
cases like this.

> 3.   Can Maxima realize that for one summation it's summing a
constant,

Yes, this is precisely what it is doing in your case above, but in a
buggy way of course.  There is another twist here.  Let's use Fateman's
approach:

   declare(mysum,linear)
   qqq: mysum(f(i)+k,i,1,n)
     => mysum(1, i, 1, n) k + mysum(f(i), i, 1, n)  CORRECT

Now substitute sum for mysum:

   subst('sum,'mysum,qqq)
      => SUM(1, i, 1, n) k + SUM(f(i), i, 1, n)

Note that sum(1,i,1,n) has not been simplified to n, and that both sums
remain in the verb form (display as SUM(...) instead of the Sigma
symbol).

To get the expected result, you instead need to do:

  subst(nounify('sum),'mysum,qqq);

or (equally obscurely):

  rrr: subst('sum,'mysum,qqq);
  ev(rrr,sum);

Note that it does NOT work to wrap the ev around the subst:

  ev(subst('sum,'mysum,qqq),sum)    DOES NOT WORK

I don't particularly *like* this state of affairs, and perhaps someday
we will design a better scheme, but for now you need to work with it....

       -s