test_class.declarator: x
test_class.modifier: private
test_class.original_string: private double[] x;
test_class.type: double[]
test_class.var_name: x
test_class.declarator: y
test_class.modifier: private
test_class.original_string: private double[] y;
test_class.type: double[]
test_class.var_name: y
test_class.file: lib/src/test/java/edu/stanford/futuredata/macrobase/analysis/classify/stats/LinearInterpolatorTest.java
test_class.identifier: LinearInterpolatorTest
test_case.body: @Test
      public void testEvaluate() throws Exception {
          LinearInterpolator interpolator = new LinearInterpolator(x, y);
          double result;
  
          result = interpolator.evaluate(-3);
          assertEquals(Double.NaN, result, 0.01);
  
          result = interpolator.evaluate(-2);
          assertEquals(1.0, result, 0.01);
  
          result = interpolator.evaluate(-1);
          assertEquals(2.0, result, 0.01);
  
          result = interpolator.evaluate(0);
          assertEquals(3.0, result, 0.01);
  
          result = interpolator.evaluate(0.5);
          assertEquals(3.0, result, 0.01);
  
          result = interpolator.evaluate(1);
          assertEquals(3.0, result, 0.01);
  
          result = interpolator.evaluate(1.5);
          assertEquals(5.0, result, 0.01);
  
          result = interpolator.evaluate(3);
          assertEquals(-1.0, result, 0.01);
  
          result = interpolator.evaluate(3.5);
          assertEquals(Double.NaN, result, 0.01);
      }
test_case.class_method_signature: LinearInterpolatorTest.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 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: x
focal_class.modifier: private
focal_class.original_string: private double[] x;
focal_class.type: double[]
focal_class.var_name: x
focal_class.declarator: y
focal_class.modifier: private
focal_class.original_string: private double[] y;
focal_class.type: double[]
focal_class.var_name: y
focal_class.file: lib/src/main/java/edu/stanford/futuredata/macrobase/analysis/classify/stats/LinearInterpolator.java
focal_class.identifier: LinearInterpolator
focal_class.class_method_signature: LinearInterpolator.LinearInterpolator(double[] x, double[] y)
focal_class.full_signature: public  LinearInterpolator(double[] x, double[] y)
focal_class.identifier: LinearInterpolator
focal_class.modifiers: public
focal_class.parameters: (double[] x, double[] y)
focal_class.signature:  LinearInterpolator(double[] x, double[] y)
focal_class.class_method_signature: LinearInterpolator.evaluate(double value)
focal_class.full_signature: public double evaluate(double value)
focal_class.identifier: evaluate
focal_class.modifiers: public
focal_class.parameters: (double value)
focal_class.return: double
focal_class.signature: double evaluate(double value)
focal_method.body: public double evaluate(double value) throws MacroBaseInternalError {
          if ((value > x[x.length - 1]) || (value < x[0])) {
              return Double.NaN;
          }
  
          for (int i = 0; i < x.length; i++) {
              if (value == x[i]) {
                  return y[i];
              }
              if (value >= x[i+1]) {
                  continue;
              }
              double dx = x[i+1] - x[i];
              double dy = y[i+1] - y[i];
              double slope = dy / dx;
              double intercept = y[i] - x[i] * slope;
              return slope * value + intercept;
          }
  
          throw new MacroBaseInternalError("Linear interpolator implemented incorrectly");
      }
focal_method.class_method_signature: LinearInterpolator.evaluate(double value)
focal_method.full_signature: public double evaluate(double value)
focal_method.identifier: evaluate
focal_method.modifiers: public
focal_method.parameters: (double value)
focal_method.return: double
focal_method.signature: double evaluate(double value)