Please submit one homework answer set for your group, along with individual versions of your code for each member of the team. Groups are expected to work together, but all individuals are expected to maintain their own unique code base (code submissions must be different for each person in the team). The best way to learn the material is to think about how you want to structure your code together as a team, and then actually implement it yourself!
Use the coinTosser() function discussed in class to build a function binomialTosser(n,p,k) that generates k realizations of a binomial random variable with parameters n and p. Recall that a binomial(n,p) random variable counts the number of heads flipped in n independent tries using a coin with a probability p of heads on any individual toss. If you need more of a primer on binomial random variables, please search the internet.
a. Build the function and supply your code for it.
b. What is the population mean of a binomial random variable? What is the population variance of a binomial random variable?
c. Use the function to generate 100000 binomial(10, 0.25) random variables. Plot an expanding window mean estimate from your 100000 random variables as a function of sample size. (An expanding window mean computes, for each value between 1 and 100000, the sample mean of all random variables up to and including that value. So the first entry is the “mean” of the first value, the 2nd entry is the mean of the first two entries, the 3rd uses the first 3 data points, … , the 100000th entry uses all 100000 data points.)
d. Find the (approximate) sampling distribution of the sample mean of a binomial random variable given the known variance of the binomial (ie, use the known population variance in place of ). What is the probability based on the approximate sampling distribution that the mean is more than 0.01 from the population mean you found in part b if your sample size is
i. k = 100
ii. k = 1000
iii. k = 10000
iv. k = 100000
1513067809116994.png