test_class.declarator: counts
test_class.modifier: private
test_class.original_string: private double[] counts;
test_class.type: double[]
test_class.var_name: counts
test_class.declarator: metrics
test_class.modifier: private
test_class.original_string: private double[] metrics;
test_class.type: double[]
test_class.var_name: metrics
test_class.file: lib/src/test/java/edu/stanford/futuredata/macrobase/analysis/classify/stats/WeightedPercentileTest.java
test_class.identifier: WeightedPercentileTest
test_case.body: @Test
      public void testEvaluate() throws Exception {
          WeightedPercentile wp = new WeightedPercentile(counts, metrics);
  
          // p100 is defined as the largest element
          double p100 = wp.evaluate(100.0);
          assertEquals(1000.0, p100, 0.01);
  
          double p99 = wp.evaluate(99.0);
          assertEquals(995.0, p99, 0.01);
  
          double p90 = wp.evaluate(90.0);
          assertEquals(949.0, p90, 0.01);
  
          double p50 = wp.evaluate(50.0);
          assertEquals(707.0, p50, 0.01);
  
          double p1 = wp.evaluate(1.0);
          assertEquals(100.0, p1, 0.01);
  
          double p0 = wp.evaluate(0.0);
          assertEquals(1.0, p0, 0.01);
      }
test_case.class_method_signature: WeightedPercentileTest.testEvaluate()
test_case.full_signature: @Test public void testEvaluate()
test_case.identifier: testEvaluate
test_case.invocations: evaluate assertEquals evaluate assertEquals evaluate assertEquals evaluate assertEquals evaluate assertEquals evaluate assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEvaluate()
focal_class.declarator: counts
focal_class.modifier: private
focal_class.original_string: private double[] counts;
focal_class.type: double[]
focal_class.var_name: counts
focal_class.declarator: metrics
focal_class.modifier: private
focal_class.original_string: private double[] metrics;
focal_class.type: double[]
focal_class.var_name: metrics
focal_class.declarator: numRawMetrics = 0
focal_class.modifier: private
focal_class.original_string: private double numRawMetrics = 0;
focal_class.type: double
focal_class.var_name: numRawMetrics
focal_class.declarator: weightedMetrics
focal_class.modifier: private
focal_class.original_string: private WeightedMetric[] weightedMetrics;
focal_class.type: WeightedMetric[]
focal_class.var_name: weightedMetrics
focal_class.file: lib/src/main/java/edu/stanford/futuredata/macrobase/analysis/classify/stats/WeightedPercentile.java
focal_class.identifier: WeightedPercentile
focal_class.class_method_signature: WeightedPercentile.WeightedPercentile(double[] counts, double[] metrics)
focal_class.full_signature: public  WeightedPercentile(double[] counts, double[] metrics)
focal_class.identifier: WeightedPercentile
focal_class.modifiers: public
focal_class.parameters: (double[] counts, double[] metrics)
focal_class.signature:  WeightedPercentile(double[] counts, double[] metrics)
focal_class.class_method_signature: WeightedPercentile.evaluate(double percentile)
focal_class.full_signature: public double evaluate(double percentile)
focal_class.identifier: evaluate
focal_class.modifiers: public
focal_class.parameters: (double percentile)
focal_class.return: double
focal_class.signature: double evaluate(double percentile)
focal_class.class_method_signature: WeightedPercentile.computeCounts()
focal_class.full_signature: private void computeCounts()
focal_class.identifier: computeCounts
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void computeCounts()
focal_method.body: public double evaluate(double percentile) {
          if (percentile >= 50.0) {
              int numToPass = (int)((100.0 - percentile) / 100.0 * numRawMetrics);
              int numPassed = 0;
              for (int i = weightedMetrics.length - 1; i >= 0; i--) {
                  numPassed += weightedMetrics[i].count;
                  if (numPassed >= numToPass) {
                      return weightedMetrics[i].metric;
                  }
              }
          } else {
              int numToPass = (int)(percentile / 100.0 * numRawMetrics);
              int numPassed = 0;
              for (int i = 0; i < weightedMetrics.length; i++) {
                  numPassed += weightedMetrics[i].count;
                  if (numPassed >= numToPass) {
                      return weightedMetrics[i].metric;
                  }
              }
          }
          throw new MacroBaseInternalError("WeightedPercentile was implemented incorrectly");
      }
focal_method.class_method_signature: WeightedPercentile.evaluate(double percentile)
focal_method.full_signature: public double evaluate(double percentile)
focal_method.identifier: evaluate
focal_method.modifiers: public
focal_method.parameters: (double percentile)
focal_method.return: double
focal_method.signature: double evaluate(double percentile)