test_class.file: splitmap/src/test/java/com/openkappa/splitmap/ReductionTest.java
test_class.identifier: ReductionTest
test_case.body: @Test
    public void testProductMomentCorrelationCoefficient() {
      double[] values1 = IntStream.range(0, 10000)
              .mapToDouble(i -> ThreadLocalRandom.current().nextDouble())
              .toArray();
      double[] values2 = IntStream.range(0, 10000)
              .mapToDouble(i -> -ThreadLocalRandom.current().nextDouble())
              .toArray();
  
      double[] statistics = new double[6];
      for (int i = 0; i < 10000; ++i) {
        double sp = values1[i];
        double sq = values2[i];
        double spp = sp * sp;
        double sqq = sq * sq;
        double spq = sp * sq;
        statistics[0] += sp;
        statistics[1] += sq;
        statistics[2] += spp;
        statistics[3] += sqq;
        statistics[4] += spq;
        statistics[5] += 1;
      }
  
      double sp = statistics[0];
      double sq = statistics[1];
      double spp = statistics[2];
      double sqq = statistics[3];
      double spq = statistics[4];
      double n = statistics[5];
      double pmccExpected = (n * spq - sq * sp) / (Math.sqrt((n * spp - sp * sp) * (n * sqq - sq * sq)));
  
      DoubleArrayPageWriter writer1 = new DoubleArrayPageWriter(Involutions::reverse);
      DoubleArrayPageWriter writer2 = new DoubleArrayPageWriter(Involutions::reverse);
      SplitMapPageWriter filterWriter = new SplitMapPageWriter(Involutions::reverse);
  
      int key = 0;
      int multiple = 0;
      for (int k = 0; k < 20; ++k) {
        for (int i = 0; i < 500; ++i) {
          filterWriter.add(key + i);
          writer1.add(key + i, values1[i + multiple * 500]);
          writer2.add(key + i, values2[i + multiple * 500]);
        }
        ++multiple;
        key += 1 << 16;
      }
  
      SplitMap filter = filterWriter.toSplitMap();
      PrefixIndex<ChunkedDoubleArray> pi1 = writer1.toIndex();
      PrefixIndex<ChunkedDoubleArray> pi2 = writer2.toIndex();
      double pmcc = filter.stream()
              .parallel()
              .map(partition -> partition.reduce(SimpleLinearRegression.<InputModel>reducer(pi1, pi2)))
              .collect(SimpleLinearRegression.pmcc());
      assertEquals(pmcc, pmccExpected, 1E-5);
    }
test_case.class_method_signature: ReductionTest.testProductMomentCorrelationCoefficient()
test_case.full_signature: @Test public void testProductMomentCorrelationCoefficient()
test_case.identifier: testProductMomentCorrelationCoefficient
test_case.invocations: toArray mapToDouble range nextDouble current toArray mapToDouble range nextDouble current sqrt add add add toSplitMap toIndex toIndex collect map parallel stream reduce reducer pmcc assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testProductMomentCorrelationCoefficient()
focal_class.file: splitmap/src/main/java/com/openkappa/splitmap/Reduction.java
focal_class.identifier: Reduction
focal_class.class_method_signature: Reduction.sum(double[] l, double[] r)
focal_class.full_signature: public static double[] sum(double[] l, double[] r)
focal_class.identifier: sum
focal_class.modifiers: public static
focal_class.parameters: (double[] l, double[] r)
focal_class.return: double[]
focal_class.signature: double[] sum(double[] l, double[] r)
focal_class.class_method_signature: Reduction.sumRightIntoLeft(double[] l, double[] r)
focal_class.full_signature: public static double[] sumRightIntoLeft(double[] l, double[] r)
focal_class.identifier: sumRightIntoLeft
focal_class.modifiers: public static
focal_class.parameters: (double[] l, double[] r)
focal_class.return: double[]
focal_class.signature: double[] sumRightIntoLeft(double[] l, double[] r)
focal_class.class_method_signature: Reduction.horizontalSum(double[] vector)
focal_class.full_signature: public static double horizontalSum(double[] vector)
focal_class.identifier: horizontalSum
focal_class.modifiers: public static
focal_class.parameters: (double[] vector)
focal_class.return: double
focal_class.signature: double horizontalSum(double[] vector)
focal_class.class_method_signature: Reduction.add(double x, double y)
focal_class.full_signature: public static double add(double x, double y)
focal_class.identifier: add
focal_class.modifiers: public static
focal_class.parameters: (double x, double y)
focal_class.return: double
focal_class.signature: double add(double x, double y)
focal_method.body: public static double add(double x, double y) {
      return x + y;
    }
focal_method.class_method_signature: Reduction.add(double x, double y)
focal_method.full_signature: public static double add(double x, double y)
focal_method.identifier: add
focal_method.modifiers: public static
focal_method.parameters: (double x, double y)
focal_method.return: double
focal_method.signature: double add(double x, double y)