Probability Lab

Mathematica Tutorial

In Mathematica, you create cells that contain instructions (similar to Jupyter notebooks for those who are familiar with them).
You can run a cell by pressing SHIFT+ENTER or CTRL+ENTER, depending on your operating system. Here is a basic example:

a = 2 * 3

A variable that has been defined once can be reused in later cells:

b = a^2

For our lab, a very important quantity are the Binomial coefficients. The number of ways to choose 3 out of 5 objects is equal to

Binomial[5,3]

This is how we can define functions:

f[x_] := x^2

Note that variable names in functions require an underscore (the “_” symbol). We can then use this function to plug in some numbers

f[5]

We can also define a function in two variables, which will be needed to this lab.

g[a_,b_]:= a-2*b

g[1,2]

A final ingredient for us is how to perform sums. Since we have defined the function f above as simply f=x^2, we can use it to calculate the sum of the first 5 square numbers 1+4+9+16+25=55.

Sum[f[i],{i,1,5}]

Try it out for yourself!

In the tutorial section above, we provided you will all ingredients that you need to answer the questions for this lab. Try to play around yourself by changing numbers, functions etc. You can then use the remaining space below to solve the exercises.