Please see the above equation. As you can see 0<= i <j <= n
. I wrote the following command in R
. When i=0
, we consider X_0 = 0
. I generated two observations n=2
and I manually calculated the values. They are, 4.540201, 1.460604
. However, my r
codes overwrite the results. I got this output 1.460604 1.460604
. I couldn't figure it out. What is the reason for that?
I updated the code below.
n = 2
set.seed(2)
x = rexp(n, 1)
xo = sort(x)
xo
value1 = matrix(NA, nrow = 2,2)
for(j in 1:n){
for(i in 0:(j-1)){
value1[i,j] = ifelse(i==0,((n - j + 1)*sum(xo[i+1] - 0)), ((n - j + 1)*sum(xo[i+1] - xo[i])) )
}
}
value1