R 我该怎么开始呢?

R 我该怎么开始呢?,r,R,所以我在这个问题上纠缠了很长时间。 我想我应该先创建两个函数,如下所示: n = runif(10000) int sum = 0 estimator1_fun = function(n){ for(i in 1:10000){ sum = sum + ((n/i)*runif(1)) ) return (sum) } 对另一个函数做同样的操作,并使用mse公式?我的做法正确吗?我尝试格式化它,但发现使用图像会更好。假设U(0,θU 0)是从0到θU 0的均匀分布,并且θU

所以我在这个问题上纠缠了很长时间。 我想我应该先创建两个函数,如下所示:

n = runif(10000)
int sum = 0
estimator1_fun = function(n){
  for(i in 1:10000){
    sum = sum + ((n/i)*runif(1))
  )
  return (sum)
}
对另一个函数做同样的操作,并使用mse公式?我的做法正确吗?我尝试格式化它,但发现使用图像会更好。

假设U(0,θU 0)是从0到θU 0的均匀分布,并且θU 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

那应该足够了。。。我不会为你写代码。为你的问题写一个更具描述性的标题。