First, we fill in a \(10 \times 10\) matrix with all results from a gamma random variable:
gamma_data = rgamma(n = 10**2, shape = 1, rate = 2)
mat_1 = matrix(data = gamma_data ,nrow = 10, ncol = 10)
mat_1
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1.06906218 0.12708437 0.06165277 0.6399725 0.30402054 0.3304283
## [2,] 0.09944883 0.17199455 0.29264728 0.1411786 1.30274538 0.1105541
## [3,] 1.53259009 1.88990021 0.43033158 1.4383084 0.95174071 1.3116098
## [4,] 0.14018112 0.01359758 1.55806958 0.4847050 0.52150042 0.4719283
## [5,] 2.05762072 1.08562332 0.40059149 0.2264735 0.60233274 1.4132712
## [6,] 0.96908653 0.32593022 0.08685801 0.5054438 0.32999951 0.8715394
## [7,] 0.09537206 0.19384307 0.03442488 0.1604852 0.25028268 0.2822954
## [8,] 1.10866813 0.73513739 1.31065018 0.4599803 0.43445391 1.6612669
## [9,] 0.13958359 0.68885233 0.43380366 0.8310270 0.64430515 0.3901496
## [10,] 1.31007495 0.73786431 0.86154328 0.3389275 0.07523289 0.2237733
## [,7] [,8] [,9] [,10]
## [1,] 0.1937760 0.48131668 0.19552116 0.86947740
## [2,] 0.2712254 0.33051316 0.51025289 0.07282286
## [3,] 1.4571647 0.09723192 0.03409601 0.23551075
## [4,] 1.3782204 1.50709663 0.06659585 1.48764746
## [5,] 0.2885872 1.06605966 0.07296715 0.41383377
## [6,] 0.3276209 0.14821316 0.57670947 0.27281869
## [7,] 0.9440199 0.49594908 0.02073539 0.72792941
## [8,] 1.0386090 0.04685126 0.07450510 0.02652724
## [9,] 0.6394525 0.78586641 0.07003723 0.17140521
## [10,] 0.1811572 0.46257692 2.15320473 0.09251799
Next, we fill in a \(10 \times 10\) matrix with all results from a normal random variable:
norm_data = rnorm(n = 10**2, mean = -1, sd = 4**.5)
mat_2 = matrix(data = norm_data ,nrow = 10, ncol = 10)
mat_2
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] -0.17645317 -4.571504338 -0.1421891 -1.3227731 -1.3670521 -1.5862612
## [2,] -0.97628774 -3.494048502 -0.1492196 -2.9799389 0.9545341 0.3697849
## [3,] -0.42540783 -2.798225040 -0.3465120 -0.2182111 -1.4850801 -1.6587533
## [4,] 0.57399968 -2.295197065 -2.1368158 -1.3888166 -4.0143697 0.8104758
## [5,] 4.54049136 0.008585364 -1.9299474 0.4114172 -3.6330402 3.1329649
## [6,] 1.30745608 1.368062803 -1.6398039 -2.6001163 1.9010426 0.8175565
## [7,] -0.62052569 -2.921439789 -2.1294546 1.8118661 0.4526423 -1.0958135
## [8,] -1.36308132 -1.260371673 -0.5683503 2.1223345 3.2869705 -0.2620435
## [9,] 0.07565943 0.951963769 -3.0824958 0.3021520 -1.6982644 -0.8831351
## [10,] 0.55702880 -0.490651957 0.4958701 -4.1417266 -0.5718073 -0.2765245
## [,7] [,8] [,9] [,10]
## [1,] 0.5450002 -1.9610978 -2.83727105 1.52902829
## [2,] 1.7737949 -0.4058424 1.64132522 -2.79829028
## [3,] -2.0496873 -1.5409087 1.89773948 1.97994974
## [4,] -2.5309728 -2.4133402 -0.68579273 -0.43053393
## [5,] -1.7654127 -3.0053271 -0.27770391 1.18119657
## [6,] -6.6601972 -2.0581981 -1.43869936 -1.13915744
## [7,] -1.6915801 1.0290237 -0.66132819 -4.06904443
## [8,] -1.3526147 -2.1567585 -0.07442263 -2.18292201
## [9,] 2.5697275 -1.7779785 -2.36117605 -0.03313389
## [10,] 3.0412646 -1.8249343 -1.96509083 -1.02047917
Next, we fill in a \(10 \times 10\) matrix with all results from a uniform random variable:
uni_data = runif(n = 10**2, min = 0, max = 3)
mat_3 = matrix(data = uni_data ,nrow = 10, ncol = 10)
mat_3
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 0.08908519 2.6504925 1.2935408 1.380870 2.519763 1.3043748 0.6529241
## [2,] 0.56492074 2.0848292 0.8122138 2.531794 2.358328 2.6914193 1.0506719
## [3,] 0.75401914 1.7278145 2.5819328 1.719653 1.472053 0.3461945 0.1252872
## [4,] 2.38661269 0.4598184 1.2626667 2.125851 1.418798 0.3905455 0.7693803
## [5,] 2.59771538 2.8389467 1.0171893 1.864496 2.971823 0.6285831 0.3441161
## [6,] 1.22696512 0.9502076 2.4096512 2.169076 2.958932 2.5486129 2.0020976
## [7,] 0.31733454 1.6521498 2.5099357 2.275196 1.089704 1.0627950 1.9631519
## [8,] 0.74431116 2.9133314 1.3783952 2.716645 1.516390 1.9532587 2.7207133
## [9,] 0.97110148 2.4777734 2.7549866 2.769912 1.619366 2.8965258 2.7446513
## [10,] 2.41070971 1.7220912 1.2743636 2.748039 2.867175 0.1084868 0.7257885
## [,8] [,9] [,10]
## [1,] 1.1039581 0.9291158 0.7090228
## [2,] 0.5742199 2.8205772 1.4077204
## [3,] 1.9579960 0.8989270 1.5593243
## [4,] 2.2135229 1.1352848 1.2204100
## [5,] 2.3198886 2.0835697 1.8018789
## [6,] 1.1099345 1.4728601 1.4326846
## [7,] 1.6437364 1.3834598 1.8450671
## [8,] 2.2817078 0.6846492 2.6777105
## [9,] 1.7933491 1.4673972 0.6149160
## [10,] 2.7505692 0.3624569 0.8892740
Finally, we piece together the needed components from each of these three matrices for our final result.
result = mat_1
result[lower.tri(result)] = mat_2[lower.tri(mat_2)]
result[upper.tri(result)] = mat_3[upper.tri(mat_3)]
result
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1.06906218 2.650492457 1.2935408 1.3808703 2.5197635 1.3043748
## [2,] -0.97628774 0.171994554 0.8122138 2.5317940 2.3583281 2.6914193
## [3,] -0.42540783 -2.798225040 0.4303316 1.7196534 1.4720534 0.3461945
## [4,] 0.57399968 -2.295197065 -2.1368158 0.4847050 1.4187977 0.3905455
## [5,] 4.54049136 0.008585364 -1.9299474 0.4114172 0.6023327 0.6285831
## [6,] 1.30745608 1.368062803 -1.6398039 -2.6001163 1.9010426 0.8715394
## [7,] -0.62052569 -2.921439789 -2.1294546 1.8118661 0.4526423 -1.0958135
## [8,] -1.36308132 -1.260371673 -0.5683503 2.1223345 3.2869705 -0.2620435
## [9,] 0.07565943 0.951963769 -3.0824958 0.3021520 -1.6982644 -0.8831351
## [10,] 0.55702880 -0.490651957 0.4958701 -4.1417266 -0.5718073 -0.2765245
## [,7] [,8] [,9] [,10]
## [1,] 0.6529241 1.10395806 0.92911579 0.70902278
## [2,] 1.0506719 0.57421989 2.82057720 1.40772037
## [3,] 0.1252872 1.95799598 0.89892704 1.55932427
## [4,] 0.7693803 2.21352291 1.13528481 1.22041001
## [5,] 0.3441161 2.31988862 2.08356966 1.80187890
## [6,] 2.0020976 1.10993447 1.47286011 1.43268460
## [7,] 0.9440199 1.64373644 1.38345984 1.84506715
## [8,] -1.3526147 0.04685126 0.68464919 2.67771050
## [9,] 2.5697275 -1.77797854 0.07003723 0.61491603
## [10,] 3.0412646 -1.82493428 -1.96509083 0.09251799