Assignment 1: Probability
CLPS 1291: Computational Cognitive Science Assignment 1
Due: 11:59PM on Feb, 15
Before you get started:
Look at the Assignment Guidelines for formatting and coding style information, submission guidelines, etc. If you have any questions related to the assignment, please post them in this Discussion.
As a reminder, we will neither accept answers that fail to follow the given template, nor consider code written outside of the allotted space. We will only review functions that follow our conventions and results documents submitted in the requested form.
If you are not familiar with MATLAB and programming, this first assignment might take you some time and we would therefore recommend that you start working on it early. We also encourage you to come to the optional tutorials and office hours.
You will need to use this skeleton code to complete the assignment.
We expect you to turn in the following:
- results.pdf - a pdf containing your calculations for problem a) and your responses to problems c) and d)
- answers.zip - a zip file containing:
- answers.m - a MATLAB script with the appropriate sections filled in with your code
- postprob.m - a MATLAB function filled in for problem d).
Coin Flips (10 points, 2.5 each)
This question is adapted from a problem set devised and generously provided by Tom Griffiths
Suppose you found a coin, and wanted to know whether it was fair or biased. Let θ denote the probability that the coin produces heads each time you flip it, and assume that successive flips are independent. You have two hypotheses: h0 is the hypothesis that the coin is fair, with θ05; h1 is the hypothesis that the coin is biased, with θ09. A priori, you consider these two hypotheses equally likely, so ph0ph105
Imagine you flip the coin once, and it produces heads. Let d denote these data. What is the likelihood of these data under h0 and h1 (i.e., what is pdh0 and pdh1)? Use Bayes rule to compute the posterior probability of h1. Work it out by hand, and show the steps in your calculation.
Write a MATLAB script that computes the answer to problem a), and check the results you obtained in problem a) against the output of your script.
Now, imagine you flipped the coin N times, and produced a sequence containing NH heads. For instance imagine we flipped a coin 10 times and got 6 heads. What is the likelihood of these data under h0 and h1?
Generalize your script from problem b) into a function that takes the number of heads and the number of tails in a sequence, and returns the posterior probability of h1. It should have inputs heads (the number of heads observed) and tails (the number of tails observed). The output should be pprob, the posterior probability of h1.
Plot this posterior probability for sequences with NNH ranging from 1 to 10. (That is, from one to ten heads in a row.) Describe what happens, and explain intuitively why this is the case. (Please include the graph in results.pdf.)