Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUMPY create, fill with random binary data

I need to create an 2D array.

    import numpy as np
    self.col = 10
    self.row = 5

    ...

    matrix = np.array(self.row, self.col) # NOT WORKING

What is the right syntax please

i also need to fill it with random binary data

like image 774
Somachr Avatar asked Jan 28 '14 14:01

Somachr


1 Answers

Generate a random matrix with binary values:

import numpy as np
row, col = 10, 5
matrix = np.random.randint(2, size=(row,col))
like image 137
YS-L Avatar answered Sep 22 '22 17:09

YS-L