STA 215 - Using Mathematica

Mathematica is a symbolic computation program available at Duke Statistics and at the public workstation clusters. It is a package for symbolic computation, including differentiation, integration, numerical integration, simplifying algebraic expressions, etc. To start Mathematica, type math at the unix prompt.

Here's an example:

  (* The ff mathematica commands plot the posterior in (a,b) for
     Likelihood: p(y[i]|a,b) = Beta(a,b)
     Prior:      p(a,b)      = const  *)

  pbeta[y_,a_,b_] := y^(a-1)(1-y)^(b-1)/Beta[a,b]   (* the Beta(a,b) pdf *)
  y = {0.7,0.9,0.6,0.8}                             (* a data vector     *)
  likl[a_,b_] := Product[pbeta[y[[i]],a,b],{i,1,4}] (* the likelihood    *) 
  Plot3D[likl[a,b],{a,4,10},{b,4,10}]               (* plot the posterior
						       = likelihood *)

  (* Note: something's wrong - the plot looks awefull. If you play 
     around with it, and fix things up, please send me a note *)