test_class.file: legacy/src/test/java/macrobase/analysis/stats/WinsorizerTest.java
test_class.identifier: WinsorizerTest
test_case.body: @Test
      public void testTrimOutlier() {
          int n = 10;
          int k = 2;
          List<double[]> metrics = new ArrayList<double[]>(n);
          for (int i = 0; i < n; i++) {
              double[] curVec = new double[k];
              for (int j = 0; j < k; j++) {
                  curVec[j] = (double)i;
              }
              metrics.add(curVec);
          }
          // Add an outlier here
          metrics.get(5)[0] = 1e5;
          metrics.get(5)[1] = -0.24;
  
          Winsorizer trimmer = new Winsorizer(20);
          List<double[]> trimmed = trimmer.process(metrics);
  
          for (int i = 0; i < n; i++) {
              double[] curRow = trimmed.get(i);
              double[] origRow = metrics.get(i);
              for (int j = 0; j < curRow.length; j++) {
                  if (curRow[j] < trimmer.bounds[j][1] && curRow[j] > trimmer.bounds[j][0]) {
                      assertEquals(curRow[j], origRow[j], 0);
                  } else {
                      assertTrue(curRow[j] >= trimmer.bounds[j][0] && curRow[j] <= trimmer.bounds[j][1]);
                  }
              }
          }
      }
test_case.class_method_signature: WinsorizerTest.testTrimOutlier()
test_case.full_signature: @Test public void testTrimOutlier()
test_case.identifier: testTrimOutlier
test_case.invocations: add get get process get get assertEquals assertTrue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testTrimOutlier()
focal_class.declarator: trimPct
focal_class.modifier: public
focal_class.original_string: public double trimPct;
focal_class.type: double
focal_class.var_name: trimPct
focal_class.declarator: bounds
focal_class.modifier: public
focal_class.original_string: public double[][] bounds;
focal_class.type: double[][]
focal_class.var_name: bounds
focal_class.file: legacy/src/main/java/macrobase/analysis/stats/Winsorizer.java
focal_class.identifier: Winsorizer
focal_class.class_method_signature: Winsorizer.Winsorizer(double trimPct)
focal_class.full_signature: public  Winsorizer(double trimPct)
focal_class.identifier: Winsorizer
focal_class.modifiers: public
focal_class.parameters: (double trimPct)
focal_class.signature:  Winsorizer(double trimPct)
focal_class.class_method_signature: Winsorizer.process(List<double[]> metrics)
focal_class.full_signature: public List<double[]> process(List<double[]> metrics)
focal_class.identifier: process
focal_class.modifiers: public
focal_class.parameters: (List<double[]> metrics)
focal_class.return: List<double[]>
focal_class.signature: List<double[]> process(List<double[]> metrics)
focal_method.body: public List<double[]> process(List<double[]> metrics) {
          int n = metrics.size();
          int k = metrics.get(0).length;
          Percentile p = new Percentile();
          bounds = new double[k][2];
          List<double[]> newMetrics = new ArrayList<>(n);
          for (int i = 0; i < n; i++) {
              newMetrics.add(new double[k]);
          }
  
          double[] curDimensionValues = new double[n];
          for (int j = 0; j < k; j++) {
              for (int i = 0; i < n; i++) {
                  curDimensionValues[i] = metrics.get(i)[j];
              }
              p.setData(curDimensionValues);
              bounds[j][0] = p.evaluate(trimPct);
              bounds[j][1] = p.evaluate(100 - trimPct);
              for (int i = 0; i < n; i++) {
                  double curValue = curDimensionValues[i];
                  if (curValue > bounds[j][1]) {
                      newMetrics.get(i)[j] = bounds[j][1];
                  } else if (curValue < bounds[j][0]) {
                      newMetrics.get(i)[j] = bounds[j][0];
                  } else {
                      newMetrics.get(i)[j] = curValue;
                  }
              }
          }
  
          return newMetrics;
      }
focal_method.class_method_signature: Winsorizer.process(List<double[]> metrics)
focal_method.full_signature: public List<double[]> process(List<double[]> metrics)
focal_method.identifier: process
focal_method.invocations: size get add get setData evaluate evaluate get get get
focal_method.modifiers: public
focal_method.parameters: (List<double[]> metrics)
focal_method.return: List<double[]>
focal_method.signature: List<double[]> process(List<double[]> metrics)