2015-11-08 31 views
-3

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公式?我是否正確地接近這個?我嘗試格式化它,但發現使用圖像會更好。

+0

寫更具描述性標題的提問。 – nrussell

回答

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 
+0

這應該夠了......我不會爲你寫代碼。 –