I am new to python. I want to write a function which generates a random nxm binary matrix with each value 0 for probability p.
What I did.
def randbin(M,N,P): # function to generate random binary matrix
mat = (np.random.rand(M,N)>=P).astype(int)
return mat
y = randbin(5,4,0.3)
Every time I print the output, I didn't get the result as per the estimated probability. I don't know what I am doing wrong.