In: Math
The following should be performed using R and the R code included in your submission.
To obtain first prize in a lottery, you need to correctly choose n different numbers from N and 1 number from 20, known as the supplementary. That is we first draw n numbers from 1:N without replacement and then 1 number from 1:20 in another draw. Suppose n=7 and N=35. Let X be the number of drawn numbers that match your selection, where the supplementary counts as 8, so that X=0,…,15. For a first prize X=15 i.e. all numbers are matched.
(a) Calculate probabilities P(X=x), x=0, 1, …, 7, without and with the supplementary. Plot the distribution function and the cumulative distribution function. Hint: Part of the answer involves the hypergeometric.
(b) Using R, generate 1,000,000 random numbers from this distribution and plot a histogram of the simulated data.
(c) Calculate the expected value, E(X), and the variance, σ2 (or Var(X)). Obtain the mean and the variance of the simulated data. Compare the estimates with the theoretical parameters.
(d) Assume that each week 10,000,000 entries are lodged, for a single draw. What is the value of � from the Poisson approximation to the number of entries with a first prize? Use the Poisson approximation for the following. What is the probability that there will be no entry with a first prize? What is the expected number of weeks until the first prize?
a)
Without supplementary, let we draw numbers from a total of numbers the probability that numbers matches is
We can see that follows hypergeometric distribution. Here
The R code for plotting PDF and CDF is given below.
N <- 35
n <- 7
x <- 0:n
PDF <- dhyper(x, m = n, n = N-n, k = n, log = FALSE)
CDF <- phyper(x, m = n, n = N-n, k = n, log = FALSE)
plot(x,CDF, xlab = "X",col="blue", main = "CDF of Hypergeometric
distribution")
#plot(x,PDF, xlab = "X",col="blue", main = "PDf of Hypergeometric
distribution")
With supplementary (), let we draw numbers from a total of numbers the probability that numbers matches is
b)
The R code for generating 1000000 random number from the given distribution and drawing the histogram is given below.
n_rand <- 1000000
N <- 35
n <- 7
X <- rhyper(n_rand, m = n, n = N-n, k = n)
hist(X, breaks = 10, xlab = "X", col = "blue", main =
"Histogram")
c)
The mean of the distribution, is
. The variance is
The simulated values are mean = 1.398336 variance = 0.9225554
n_rand <- 1000000
N <- 35
n <- 7
X <- rhyper(n_rand, m = n, n = N-n, k = n)
mean(X)
var(X)
d)
The symbol in the question is not visible.