working with likelihood functions



Jim_Garrett@bd.com wrote:
> I'm a newcomer to Maxima.  I'm really delighted to find this, and I intend
> to learn to use it well because, since it's GPL'd, no one will ever be able
> to take it away from me!  Thanks to everyone who's contributed to it.
> 
> I'm a statistician, so run into summations (over observed data points)
> often.  I seem to be running into some walls regarding manipulating
> summations.
> 
> I've been practicing with a well-known, simple example: demonstrating that
> the average is the maximum likelihood estimator for the mean of a Gaussian
> series of observations (independent and having common parameters mu and
> sigma).  I'll use Latex notation.  Here are a few questions:
> 
> (If you wish to send me information off-list, please send it to this
> address and to my home address, jim_garrett@comcast.net.)
> 
> 1.   Suppose I define the log-likelihood function for a single data point
> $x_i$ (the log-likelihood is the log of the probability density function
> for the observations, regarding the observed data as fixed and the
> parameters--mu and sigma here--as varying):
> 
> loglik_1 : log(1/sqrt(2 * %pi) * exp(-1/2 * (x[i] - mu)^2));

try loglik_1(i) := log(1/sqrt(2 * %pi) * exp(-1/2 * (x[i] - mu)^2));


> 
> Now if I see $x_1, x_2, \ldots, x_n$ data observations, the log-likelihood
> for the sequence is obtained by adding loglik_1, with a difference $i$ each
> time.  I tried
> 
>    loglik : sum(loglik_1, i, 1, 10);

try
      loglik : sum(loglik_1(i),i,1,10);

> 
> but that gave me 10 * loglik_1 for a single arbitrary $i$.  How can I
> communicate that each term in the summation is different?
> 
> 2.   Moving on, I meet something of this form:
> 
>    \[ \sum_{i = 1}^n (x_i - \mu) = 0. \]
> 
> In order to solve for mu, I want to make this into two summations:
> 
>    \[ \sum_{i = 1}^n (x_i - \mu) = \sum_{i = 1}^n x_i - \sum_{i = 1}^n \mu.
> \]
> 
> How can I do that?

There may be some simplification flag to do this, but
here's another way..

Maybe use some other operator for sum(*, i,1,n), say s.  Declare s
to be a linear operator. then replace by sum.

> 
> 3.   Can Maxima realize that for one summation it's summing a constant,
> i.e., $\sum_{i = 1}^n \mu = n \mu$?

I think so.

> 
> I'm sure I'll have more questions later on.  These are standard things that
> arise in statistics, so once I figure this out I'll be able to advise other
> statisticians with a "design pattern", if you will.
> 
> Thanks for any advice.
> 
> Jim Garrett
> Becton Dickinson Diagnostic Systems
> Baltimore, Maryland, USA
> 
> **********************************************************************
> This message is intended only for the designated recipient(s).  It may
> contain confidential or proprietary information and may be subject to
> the attorney-client privilege or other confidentiality protections.
> If you are not a designated recipient, you may not review, use, copy
> or distribute this message.  If you receive this in error, please
> notify the sender by reply e-mail and delete this message.  Thank you. 
> 
> ***********************************************************************
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima