Consider a random sample X1, X2, Xn from the probability density function:
f(x; θ) =
0, if 0 < x < θ-1
3x, if 0 ≤ x ≤ 1
0, otherwise
Find the method of moments estimator of θ. Find the maximum likelihood estimator of θ. Use the following R codes to generate a sample of size 10,000:
pdf <- function(x) {
if (0 < x & x < 1) {
return(3*x)
} else {
return(0)
}
}
rand_smplfunc <- function(func, lower, upper, n) {
x_values <- seq(lower, upper, by = 10^-3)
sample(x_values, size = n, replace = TRUE, prob = func(x_values))
}
n <- 10000
sample <- rand_smplfunc(pdf, 0, 1, n)
Use R to compute the method of moments estimate of θ and the maximum likelihood estimate of θ. Paste the output here.