Wednesday, 12 February 2014

Mathematica and MATLAB

I highly recommend that you install Mathematica and use it while you study and work on examples sheets (in many courses). I personally use it on almost a daily basis.
You can download a free copy:
http://www.maths.cam.ac.uk/computing/software/mathematica/

It is very easy install and learn to use. The time you spend learning to use it (and similarly MATLAB) is a very good investment.
http://www.maths.cam.ac.uk/undergrad/catam/software/matlabinstall/matlab-personal.htm

Here is a Mathematica program for Example Sheet 1, #15.

(* POLYA URN *)
{w, b} = {1, 1}
For[i = 1, i <= 50, i++, {
  For[j = 1, j <= 1000, j++, {
      m = RandomInteger[{1, w + b}];
      If[m <= w, w = w + 1, b = b + 1];
      }]
    Print[w/(w + b) // N];
  }]