Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Assignment 1

STAT221

2022

Please submit your assignment in a single file (pdf) through Learn.

1) Congruential Random Number Generator

Write R code to generate N = 1000 pseudo-random numbers using a congruential random number generator. Choose reasonable values for the multiplier, increment, and modulo. Use your student ID as a seed.

2) Inversion sampler for the Pareto distribution

The Pareto distribution has two parameters, the location a > 0 and shape b > 0 parameters, and probability

density function given by

f (x) = { 0(b)xb(a)

and the cumulative distribution function is given by

F (x) = {0(1) −‘) b

for x ≥ a

for x < a

a)  Find the inverse CDF of the Pareto distribution

b) Write R code for an inversion sampler to generate a sample of N = 1000 random numbers from the Pareto distribution with a = 2 and b = 3.  Use the generated CNRG pseudo-random numbers of Question 1.  (do not use any functions, which directly implement the sampler like rpareto())

c)  Draw a histogram for the generated sample and add a line with the true density of the Pareto(2, 3) distribution.

3) Inversion sampler for a discrete random variable

A discrete random variable X has the probability mass function

x

1

2

3

4

5

f(x)

0.1

0.2

0.4

0.1

0.2

a) Write R code for an inversion sampler to generate a sample of 1000 random numbers from the distribution of X . Use the generated CNRG pseudo-random numbers of Question 1 (do not use any functions, which directly implement the sampler like rbinom())

b)  Show the probability mass function of the sample of simulated random numbers.  Include the true probability mass function in the plot for a comparison.

4) Inversion sampler for the binomial distribution

The binomial distribution has two parameters, the number of independent Bernoulli trials n and the probability of success on any one trial 0 < p < 1, with probability mass function

f(x) = P (X = x) = {0(‘)x(n))px (1 p)n x     ot(fo)rh

a) Write R code for an inversion sampler to generate a sample of 1000 random numbers from a binomial distribution with n = 12 Bernoulli trials and the probability of success on each trial of p = 0.8. Use the generated CNRG pseudo-random numbers of Question 1 (do not use any functions, which directly implement the sampler like rbinom())

b)  Show the probability mass function of the sample of simulated binomial random numbers. Include the true binomial probability mass function in the plot for a comparison.

5) Rolling dice

Simulate the sum of outcomes when rolling three dice, one with 6 sides, one with 12 sides, and one with 20 sides.

a)  Generate a sample of N = 1000 totals of rolling the three dice, using an inversion sampler (use runif() and choose your student ID as seed).

b)  Show the probability mass function of the sample of simulated totals.