I have the following R code
n <- 10
samples_0 <- 5
x <- 25
samples <- matrix(c(runif(n*samples_0, 0, x)), ncol=n)
theta1 <- ((n + 1) / n) * samples
theta2 <- (n + 1) * samples
var(theta1)
var(theta2)
If the code above was run on an infinitely large samples_0, what would the values of the variance of theta1 (var(theta1) in code) and theta2 (var(theta2)) be to 11 decimal places?
rm(list=ls())
n <- 10
samples_0 <- 10000000
for(i in 1:samples_0){
x <- 25
samples <- matrix(c(runif(n*samples_0[i], 0, x)), ncol=n)
theta1 <- ((n + 1) / n) * samples
theta2 <- (n + 1) * samples
}
var(theta1)
var(theta2)
plot(theta2)
#Here we see that our data is uniformally distributed,so if we increase the sample size it convert a dence form of recangle.it tends to normal distribution.
OUTPUT:-
> var(theta1)
[,1] [,2] [,3] [,4] [,5]
[1,] 63.030224952 -0.0168437722 3.317596e-02 -0.0353162309
2.154431e-02
[2,] -0.016843772 63.0099845011 -1.803850e-02 0.0213997798
-2.060295e-02
[3,] 0.033175959 -0.0180384991 6.301845e+01 0.0021669905
-7.070155e-05
[4,] -0.035316231 0.0213997798 2.166991e-03 63.0000416055
2.392772e-02
[5,] 0.021544315 -0.0206029495 -7.070155e-05 0.0239277242
6.301258e+01
[6,] -0.013296808 -0.0009509087 5.446718e-03 0.0122691572
-1.118176e-04
[7,] 0.016381570 -0.0077938267 8.969020e-03 0.0348942978
-2.724619e-02
[8,] -0.019554125 -0.0093099748 -2.677580e-03 -0.0042883917
6.177605e-04
[9,] -0.007973789 0.0235519094 1.315681e-02 0.0006755162
1.490616e-02
[10,] 0.008881979 -0.0240627816 -3.823215e-03 0.0282431352
2.409941e-03
[,6] [,7] [,8] [,9] [,10]
[1,] -0.0132968080 0.016381570 -0.0195541247 -0.0079737893
0.008881979
[2,] -0.0009509087 -0.007793827 -0.0093099748 0.0235519094
-0.024062782
[3,] 0.0054467184 0.008969020 -0.0026775801 0.0131568122
-0.003823215
[4,] 0.0122691572 0.034894298 -0.0042883917 0.0006755162
0.028243135
[5,] -0.0001118176 -0.027246187 0.0006177605 0.0149061591
0.002409941
[6,] 63.0232211003 0.039798149 -0.0066579803 0.0169614369
-0.002302151
[7,] 0.0397981487 63.022145390 0.0013889206 0.0065857189
0.008577477
[8,] -0.0066579803 0.001388921 63.0160685323 -0.0294366807
0.006110090
[9,] 0.0169614369 0.006585719 -0.0294366807 63.0150500016
-0.017090139
[10,] -0.0023021514 0.008577477 0.0061100904 -0.0170901385
63.026330909
Get Answers For Free
Most questions answered within 1 hours.