Fall 2011: STAT 598Z: Introduction to Computing for Statisticians

1. Write an accept/reject sampler to generate uniform samples from the unit disk in two dimensions. Recall that the unit disk is characterized by $\{(x,y) s.t. x^2 + y^2 \leq 1\}$. What is the efficiency of your sampler?
2. Implement any other algorithm for generating uniform samples from the unit disk in two dimensions.
3. Plot the samples that you generated and visually confirm that they are indeed uniformly distributed.
4. Write a sampler to generate samples from the density $p(x)=\frac{\alpha \beta^\alpha}{x^{\alpha+1}}$ for $x \geq \beta$ using the inverse transform.
5. Download your favorite Shakespear play from http://openshakespeare.org/ and save it in a text file. Read the file and annotate each line with the line number and write the result back into another text file. You need to skip blank lines. For instance if you input text is

All's Well, that Ends Well

Actus primus. Scoena Prima.

Enter yong Bertram Count of Rossillion, his Mother, and Helena, Lord Lafew, all in blacke.

1 All's Well, that Ends Well

2 Actus primus. Scoena Prima.

3 Enter yong Bertram Count of Rossillion, his Mother, and Helena, Lord Lafew, all in blacke.