This is probably just a basic CS question, so I appreciate the help. I'm doing Monte Carlo permutation tests in matlab for One-Sample and Paired Two-Sample Tests (where there are x^n unique vectors for n observations of x possible classes) and it is taking a very long time to generate all of the unique vectors.
For very large numbers of samples, the time it takes to generate that many unique vectors increases dramatically as the number of samples increases (for two reasons, one is the reduced ratio of unsample:sampled unique permutations and the second is the need to compare each new permutation to the previous permutations to see if it’s unique). I could speed things up immensely if I could pre-generate every possible subset and then just sample from the indices of those vectors, but obviously the size of the matrix of all possible vectors is too large.
Is there a way to turn an index into what would be the corresponding vector? It seems like there must be. I.e. in the binary case (x = 2), if each vector has 10 observations, there are 2^10 unique binary vectors. The random number generator delivers 512, so the program calculates the unique binary vector that corresponds to index 512 and returns that. That way I could just pull the desired number of indices from [1,2^10] and calculate the corresponding unique binary vector for each.
Eventually I’ll need to take that to the multiclass case (x>3) and for unpaired two-sample tests (where there are n! possible combinations of the observations), but the binary subset case seems like the easiest place to start.
Thought on how to do that? Again, thanks for the help.