def corruptVector(v1, noiseLevel, numActiveCols):
 size = len(v1)
 v2 = np.zeros(size, dtype='uint32')
 bitsToSwap = int((noiseLevel * numActiveCols))
 for i in range(size):
  v2[i] = v1[i]
 for _ in range(bitsToSwap):
  i = random.randrange(size)
  if (v2[i] == 1):
   v2[i] = 0
  else:
   v2[i] = 1
 return v2

def corruptVector ( v1 , noiseLevel , numActiveCols ) : size = len ( v1 ) v2 = np . zeros ( size , dtype = 'uint32' ) bitsToSwap = int ( ( noiseLevel * numActiveCols ) ) for i in range ( size ) : v2 [ i ] = v1 [ i ] for _ in range ( bitsToSwap ) : i = random . randrange ( size ) if ( v2 [ i ] == 1 ) : v2 [ i ] = 0 else : v2 [ i ] = 1 return v2
corrupts a binary vector by inverting noiselevel percent of its bits .