# Random sampling a matrix to reflect a real world case

I'm trying to create two matrices one that can be filled with 0's and 0.25's and another with 0's and 1's.

vector <- c()
for(i in 1:1000){
dummy_qt <- as.data.frame(matrix(sample(c(0, 0.25), 44, replace = TRUE), 4, 11))
colnames(dummy_qt) <- c(2005:2015)
boot_qt <- dummy_qt %>%
summarise_all(funs(sum)) %>%
sum()/11

dummy_y <- as.data.frame(matrix(sample(c(0, 1), 44, replace = TRUE), 4, 11))
colnames(dummy_y) <- c(2005:2015)
boot_y <- dummy_y %>%
mutate(sumrow = rowSums(.)/11) %>%
select(sumrow) %>%
sum()

qt_y <- sum(boot_qt, boot_y)
vector[i] <- qt_y
}


After creating the matrices, I run a mathematical formula, and put it into a vector. However, I know the maximum the matrix dummy_qt can get is 1 (as it is possible to see on the example below), and the dummy_y is 4 (as it is possible to see on the example below), making the final result 5 if all values within the matrix are 0.25 for the first matrix and 1 for the second.

For example:

dummy_qt <- as.data.frame(matrix(0.25, 4, 11))
dummy_y <- as.data.frame(matrix(1, 4, 11))
boot_qt <- dummy_qt %>%
summarise_all(funs(sum)) %>%
sum()/11
boot_y <- dummy_y %>%
mutate(sumrow = rowSums(.)/11) %>%
select(sumrow) %>%
sum()
qt_y <- sum(boot_qt, boot_y)


Whenever I run this, usually the histogram shows that I only get values between 0 and 3.25 which doesn't reflect the reality. This is all based on a real world example where I often have those matrices without any 0's being that they are just filled with 0.25 or 1 values, depending on the matrix. Am I doing something wrong or does this make perfect sense statistically? My final goal is to get some CI, by bootstrapping.

• Can the downvoter explain why he did so? I'm happy to add or remove info if it makes the post better. – FilipeTeixeira Mar 23 '18 at 17:33

Unless I am missing something about the matrix creation process, I believe the issue is just that you are looking for something that very (very) rarely occurs.  Here is my understanding (please correct if I am wrong):  the sample matrices are created by sampling from c(0,a) with equal probability to fill the matrix entries, and the maximum scores are obtained only if the matrix is all a’s.  However, this will only happen with probability $(\frac{1}{2})^{44}$, or 1 out of 17.6 trillion trials.  Thus, I’m not sure it should be surprising that the simulation results in values that don't quite reach the maximum value 4.