Add noise to sdr by turning off numNoiseBits active bits and turning on
  numNoiseBits in active bits
  @param sdr        (array) Numpy array of the  SDR
  @param noiseLevel (float) amount of noise to be applied on the vector.
12058
def corruptSparseVector(sdr, noiseLevel):
  

  numNoiseBits = int(noiseLevel * np.sum(sdr))
  if numNoiseBits <= 0:
    return sdr
  activeBits = np.where(sdr > 0)[0]
  inActiveBits = np.where(sdr == 0)[0]

  turnOffBits = np.random.permutation(activeBits)
  turnOnBits = np.random.permutation(inActiveBits)
  turnOffBits = turnOffBits[:numNoiseBits]
  turnOnBits = turnOnBits[:numNoiseBits]

  sdr[turnOffBits] = 0
  sdr[turnOnBits] = 1
1047308
def createEvenlySpreadSDRs(numSDRs, n, w):
  
  assert w <= n

  available = np.arange(n)
  np.random.shuffle(available)

  SDRs = []

  for _ in xrange(numSDRs):
    selected = available[:w]
    available = available[w:]

    if available.size == 0:
      remainderSelected = np.random.choice(
        np.setdiff1d(np.arange(n), selected),
        size=(w - selected.size),
        replace= False)
      selected = np.append(selected, remainderSelected)

      available = np.setdiff1d(np.arange(n), remainderSelected)
      np.random.shuffle(available)

    selected.sort()
    SDRs.append(selected)

  return SDRs
152935
def wiggle(self,noiseLevel=.1):
        """"""
        noise=(np.random.rand(*self.data.shape))-.5
        self.data=self.data+noise*noiseLevel
517224
public void unregisterDereferencedListener(Provider.DereferenceListener dereferenceListener) {
        if (dereferenceListeners != null) {
            dereferenceListeners.remove(dereferenceListener);
            if (dereferenceListeners.isEmpty()) {
                dereferenceListeners = null;
            }
        }
    }
1371753
@Deprecated
    public void setMinLevel(String minLevel) {
        this.minLevel = minLevel != null ? Level.toLevel(minLevel) : null;
    }
539467
@Override
    public Sample addNoise(List<Sample> samples) {
        Sample appended = Mixer.append(samples);
        String noiseFile = _noiseFiles[RAND.nextInt(_noiseFiles.length)];
        Sample noise = SampleUtil.readSample(noiseFile);

        // Decrease the volume of the noise to make sure the voices can be heard
        return Mixer.mix(appended, 1.0, noise, 0.6);
    }
336304
private double Noise(int x, int y) {
        int n = x + y * 57;
        n = (n << 13) ^ n;

        return (1.0 - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0);
    }
437962
public void setUserDetectorThreshold(int threshold) {
        String minPriority = ProjectFilterSettings.getIntPriorityAsString(threshold);
        filterSettings.setMinPriority(minPriority);
    }
1055672
public void addListener(final ProcessorListener<ApiType> processorListener) {
    lock.writeLock().lock();
    try {
      addListenerLocked(processorListener);
    } finally {
      lock.writeLock().unlock();
    }
  }
742445
def logCellActivity_varyNumColumns(noiseSigma, noiseEverywhere):
  
  noiseLevels = [0.30, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90]
  l2Overrides = {"sampleSizeDistal": 20}
  columnCounts = [1, 2, 3, 4, 5]

  results = defaultdict(list)

  for trial in xrange(1):
    print "trial", trial
    objectDescriptions = createRandomObjectDescriptions(10, 10)

    for numColumns in columnCounts:
      print "numColumns", numColumns
      for noiseLevel in noiseLevels:
        r = doExperiment(numColumns, l2Overrides, objectDescriptions,
                         noiseLevel, noiseSigma, numInitialTraversals=6,
                         noiseEverywhere=noiseEverywhere)
        results[(numColumns, noiseLevel)].extend(r)

  d = []
  for (numColumns, noiseLevel), cellCounts in results.iteritems():
    d.append({"numColumns": numColumns,
              "noiseLevel": noiseLevel,
              "results": cellCounts})

  filename = os.path.join("plots",
                          "varyColumns_sigma%.2f_%s.json"
                          % (noiseSigma, time.strftime("%Y%m%d-%H%M%S")))
  with open(filename, "w") as fout:
    json.dump(d, fout)

  print "Wrote to", filename
  print "Visualize this file at: http://numenta.github.io/htmresearch/visualizations/grid-of-scatterplots/L2-columns-with-noise.html"
1246428
public void setWarningLevel(int level) {
        if (level < WarningMessage.NONE || level > WarningMessage.PARANOIA) {
            this.warningLevel = WarningMessage.LIKELY_ERRORS;
        }
        else {
            this.warningLevel = level;
        }
    }
26918
public void addShutdownListener(final ShutdownListener shutdownListener) {
        synchronized (lock) {
            if (!shutdown) {
                throw UndertowMessages.MESSAGES.handlerNotShutdown();
            }
            long count = activeRequestsUpdater.get(this);
            if (count == 0) {
                shutdownListener.shutdown(true);
            } else {
                shutdownListeners.add(shutdownListener);
            }
        }
    }
413753
public void addRandomHyperPlane() {
        INDArray newPlane = Nd4j.randn(new int[] {1,dim});
        newPlane.divi(newPlane.normmaxNumber());
        if(wholeHyperPlane == null)
            wholeHyperPlane = newPlane;
        else {
            wholeHyperPlane = Nd4j.concat(0,wholeHyperPlane,newPlane);
        }
    }
553068
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
505193
def signal_to_noise_map(self):
        """"""
        signal_to_noise_map = np.divide(self.data, self.noise_map)
        signal_to_noise_map[signal_to_noise_map < 0] = 0
        return signal_to_noise_map
70305
def remove_noise(time, magnitude, error, error_limit=3, std_limit=5):
    
    data, mjd = magnitude, time

    data_len = len(mjd)
    error_mean = np.mean(error)
    error_tolerance = error_limit * (error_mean or 1)
    data_mean = np.mean(data)
    data_std = np.std(data)

    mjd_out, data_out, error_out = [], [], []
    for i in range(data_len):
        is_not_noise = (
            error[i] < error_tolerance and
            (np.absolute(data[i] - data_mean) / data_std) < std_limit)

        if is_not_noise:
            mjd_out.append(mjd[i])
            data_out.append(data[i])
            error_out.append(error[i])

    data_out = np.asarray(data_out)
    mjd_out = np.asarray(mjd_out)
    error_out = np.asarray(error_out)

    return mjd_out, data_out, error_out
247052
static public double sphere_noise(double[] x) {

    double sum = 0.0;

    for (int i = 0; i < x.length; i++) {
      sum += x[i] * x[i];
    }

    // NOISE
    // Comment the next line to remove the noise
    sum *= (1.0 + 0.1 * Math.abs(random.nextGaussian()));

    return (sum);
  }