how to generate all possible combinations of a 14x10 matrix containing only 1's and 0's

前端 未结 11 1250
悲&欢浪女
悲&欢浪女 2021-01-23 23:32

I\'m working on a problem and one solution would require an input of every 14x10 matrix that is possible to be made up of 1\'s and 0\'s... how can I generate these so that I can

11条回答
  •  情深已故
    2021-01-24 00:15

    Depending on what you want to accomplish with the generated matrices, you might be better off generating a random sample and running a number of simulations. Something like:

    matrix_samples = []
    # generate 10 matrices
    for i in range(10):
        sample = numpy.random.binomial(1, .5, 14*10)
        sample.shape = (14, 10)
        matrix_samples.append(sample)
    

    You could do this a number of times to see how results vary across simulations. Of course, you could also modify the code to ensure that there are no repeats in a sample set, again depending on what you're trying to accomplish.

提交回复
热议问题