I am working with largish binary matrices, at the moment up to 100×100.
Lets say I am working with 30×30 binary matrices. Then there are a total of 2^(30×30) binary matrices. I want to select a binary matrix at random, where each of the 2^(30×30) matrices has the same probability of being selected.
My solution attempt was to pick a number between 1 and 2^(30×30) using the function randi(n) with n = 2^(30×30) and then converting the result to the appropriate binary matrix. The problem I ran into was that randi(n) does not take values for n larger than 2^54. Matlab in general does not seem to like very large numbers.
Any suggestions?
If each matrix of booleans has equal probability, then the elements of the matrix each have equal probability of 0 and 1. You can just fill a matrix of the appropriate size with n² uniform random booleans.
I don’t have MATLAB handy, but in Octave you’d do something like
unidrnd(2, n, n) - 1.