Total Points: 40

Part 1. Review Questions (2+5+3 pts)

  1. Multiply the inverse of a matrix \(\begin{bmatrix} 3 & 2 & 1\\ 4 & 8 & 1\\ 5 & 9 & 16 \end{bmatrix}\) with itself.

    Also, return those entries that are bigger than \(10^{-9}\).

# Your code here
  1. Make a list lst1 with components

Answer the following questions using R:

# Your code here
  1. Download the family.txt shown in Lecture 2 to your laptop. Then, read the file into R using the function read.delim(). Then, compute the following statistics in R:
# Your code here

Part 2: Normal Distribution (2+5+3+4 pts)

R provides several functions for the normal/Gaussian distribution:

Use R to answer the following questions:

  1. Create and store a vector norm_vec with \(100,000\) random variables from a Normal distribution with mean 6 and standard deviation 2. Print out the first 7 elements of norm_vec using the function head().
set.seed(123)  ## Don't change this line. It makes the result reproducible.
# Your code starts from here
  1. Plot two histograms, one with the first 100 elements of norm_vec, and the other with all the elements of norm_vec. Set the argument freq = FALSE for both histograms for better comparisons.
# Your code starts from here
  1. Standardize the vector norm_vec to \(N(0,1)\) by subtracting its mean and then dividing it by its standard deviation. Name it as norm_vec_std. Compute the standard deviation of norm_vec_std. Also, what is the percentage of observations in norm_vec_std that are greater than 1.644854?
# Your code here
  1. Apply the function pnorm() (without specifying any other arguments) to the vector norm_vec_std. Then, compute its mean and variance after applying the function pnorm(). Finally, plot its histogram after applying the function pnorm() with the argument freq = FALSE.
# Your code here

Part 3: Binomial Distribution (4pts per question)

The binomial distribution \(\mathrm{Bin}(m,p)\) is defined by the number of successes in \(m\) independent trials, each have probability \(p\) of success. Think of flipping an (unfair) coin \(m\) times, where the coin could be biased and has probability \(p\) of landing on heads.

Similar to the above normal distribution, R also provides several functions for the binomial distribution:

  1. Initialize a matrix binom_mat with 3 columns and 100 rows, whose entries are all NA.
set.seed(1234)  ## Don't change this line. It makes the result reproducible.
# Your code starts from here
  1. Compute the means of every 10 elements in the first column of binom_mat. There should be 10 mean values in total. Then, output the median of these 10 mean values. Assign it to a variable MoM.
# Your code here
  1. Now, change the first element in the first column of binom_mat to -100. Then, repeat what we did in Question 2 (i.e., compute the means of every 10 elements in the first column of binom_mat and then calculate the median as MoM2.)
# Your code here
  1. Create a list binom_lst with 3 components:
set.seed(1234)  ## Don't change this line. It makes the result reproducible.
# Your code starts from here