我如何开始这个?

时间:2015-11-08 21:42:04

标签: r

homework problem I am stuck on

所以我长期坚持这个问题。 我想我应该首先创建这两个函数,如下所示:

n = runif(10000)
int sum = 0
estimator1_fun = function(n){
  for(i in 1:10000){
    sum = sum + ((n/i)*runif(1))
  )
  return (sum)
}

并对其他函数执行相同操作,并使用mse公式?我是否正确接近这个?我尝试格式化它,但发现使用图像会更好。

1 个答案:

答案 0 :(得分:0)

假设U(0,Theta_0)是从0到Theta_0的均匀分布,并且Theta_0是固定常数,我将按如下方式进行:

1. Define Theta_0. Give it a fixed value.
2. Write the function that gives a random number from that distribution
   - The distribution function is runif(0,Theta_0). 
   - Arguments could be Theta_0 and N.
3. Sample it a few thousand (or whatever) times into a vector X.
4. Calculate the two estimates.
5. Repeat steps 3 & 4 for more samples
6. Plot the two estimates against the number of samples and 
       see if it is approaching Theta_0