code: def corruptDenseVector(vector, noiseLevel):
    
    size = len(vector)
    for i in range(size):
      rnd = random.random()
      if rnd < noiseLevel:
        if vector[i] == 1:
          vector[i] = 0
        else:
          vector[i] = 1
docs: Corrupts a binary vector by inverting noiseLevel percent of its bits.
  
    @param vector     (array) binary vector to be corrupted
    @param noiseLevel (float) amount of noise to be applied on the vector.