this = rand(100,3,4)
for i in range(0,100):
for j in range(0,3):
for k in range(0,4):
if rand()<0.5:
this[i,j,k]=0
Where rand
is numpy.random.rand
Can the above be written in chained list comprehension?
Aim: to assign value 0 to each term in "this" (3D matrix) with certain probability(0.5)