Maple

Maple does symbolic manipulation in finding derivatives and integrals. It reqires commands to end with a semicolon. To define a function, := is used for assignment.


Startup

Type xmaple &.


Help

Xmaple has a help menu in the top right corner which allows keyword searching. If you know the command or function in question, ?function gives a description of the function (in a new window). For instance
> ?Beta
FUNCTION: Beta - The Beta function
...
Let's use Maple to find maximum likelihood estimates for parameters theta and kappa in a Gamma distribution given the following data.
>  x := [22.60, 8.59, 28.91, 10.96, 10.63, 14.33, 23.06, 12.66, 15.05,\
         11.14, 19.50,  9.95];
>  sumx := sum('x[k]','k'=1..12);
>  sumlnx := sum('ln(x[k])','k'=1..12);
Next we define the log likelihood function and derivatives w.r.t theta and kappa.
>  lnL := 
  -12*kappa*ln(theta) -12*ln(GAMMA(kappa)) +(kappa-1)*sumlnx - sumx/theta;
>  d1 := diff(lnL,theta);
>  d2 := diff(lnL,kappa);
Finally, use fsolve to simultaneously solve for the values of theta and kappa where derivatives are zero.
> fsolve({d1,d2},{kappa,theta});
You could use the second derivative test to check whether this is a max or a min using Maple. The following commands plot the function, which will also tell us we have a max. The likelihood is nicer to look at than log likelihood in this case. First we set the graphics device.
> plotsetup(x11);
> plot3d(exp(lnL(theta,kappa)),theta=0.1..5,kappa=3..12,style=patch);
> plot3d(exp(lnL(theta,kappa)),theta=1.8..3,kappa=6..8,style=patch);


Exiting

Quit by typing quit or use Alt-X, or pick exit from the FILE menu.
For more help see Dockery's tutorial or visit the Maple homepage.


Information about unix and emacs.

Other Stat package demos:


Back to MSU Math Department Home Page


Author: Jim Robison-Cox
Last Updated: Tuesday, 14-Jun-2011 16:52:23 MDT