# Homework 2

Due 2020-09-16 by midnight

- Study Chapters 5-8 of Shotts.
- Look at Oetiker, Partl, Hyna,
& Schlegl. Some parts can be skimmed, but others should be read
carefully.
- Read Chapters 2, 3, 4, 5, & 18 of Jones, Maillardet, & Robinson.
- Download the files svproc.cls and spbasic.bst (right click and save file or use wget). The tex file contained in Bad.tex is incomplete. Fill in all the necessary details and make all the necessary changes so that it looks like the fllowing pdf file: Good.pdf. Use R to reproduce the plot based off the data given in the pdf file and replace
*put your name here* with your name. Save the new tex file as 'Good.tex'.
- Practice writing code without using loops. Write the following without using loops, including not using apply statement. Save the results in a file labeled noloops.R
- Produce a vector containing all integers from 1 to 100 that are not divisible by 2, 3, or 7.
- Create a function that inputs a matrix or array and return the same matrix or array, but where every element that is between -1 and 1 switches signs (i.e. .5 becomes -.5 and -.2 becomes .2).
- Write a function that inputs a matrix and returns a matrix where each column is subtracted by the individual column mean.

*This part is designed to help you gain: 1. experience in implementing
algorithms, and 2. an appreciation for what happens "behind the scenes" when
using functions to simulate random deviates.* R has builtin
functions for many probability distributions. In two scripts, an R file named 'rdg.R' and a python file named 'rdg.py',
write functions that are drop-in replacements for R's builtin functions
rnorm, rlnorm, rexp, rpois, rgamma, rchisq, rt, rf, rbeta, rbinom, and rnbinom.
A drop-in replacement function not only has the same name as the original
function, but also the same argument names in the same order, with the same
return type. Your functions may call each other (e.g., you can use your rnorm
function to implement your rlnorm function) but they cannot use any random
number generation functions in R except runif or in Python except numpy's uniform function. Good references include this file (although, in some cases, it lacks the
needed generality), Wikipedia, and general web searching. Note that some of
these methods rely on the Box-Muller Transformation and
others use the Inverse CDF method.
- Submit this homework by committing (only) the requested files in the
appropriate directory (i.e., homework/2) and pushing to your central Git
repository.