test_class.declarator: sizeDump
test_class.modifier: private static
test_class.original_string: private static PrintWriter sizeDump;
test_class.type: PrintWriter
test_class.var_name: sizeDump
test_class.declarator: errorDump
test_class.modifier: private static
test_class.original_string: private static PrintWriter errorDump;
test_class.type: PrintWriter
test_class.var_name: errorDump
test_class.declarator: deviationDump
test_class.modifier: private static
test_class.original_string: private static PrintWriter deviationDump;
test_class.type: PrintWriter
test_class.var_name: deviationDump
test_class.file: ml/streaminer/src/test/java/org/streaminer/stream/quantile/TDigestTest.java
test_class.identifier: TDigestTest
test_case.body: @Test
      public void testMerge() {
          Random gen = RandomUtils.getRandom();
  
          for (int parts : new int[]{2, 5, 10, 20, 50, 100}) {
              List<Double> data = Lists.newArrayList();
  
              TDigest dist = new TDigest(100, gen);
              dist.recordAllData();
  
              List<TDigest> many = Lists.newArrayList();
              for (int i = 0; i < 100; i++) {
                  many.add(new TDigest(100, gen).recordAllData());
              }
  
              // we accumulate the data into multiple sub-digests
              List<TDigest> subs = Lists.newArrayList();
              for (int i = 0; i < parts; i++) {
                  subs.add(new TDigest(50, gen).recordAllData());
              }
  
              for (int i = 0; i < 100000; i++) {
                  double x = gen.nextDouble();
                  data.add(x);
                  dist.add(x);
                  subs.get(i % parts).add(x);
              }
              dist.compress();
              Collections.sort(data);
  
              // collect the raw data from the sub-digests
              List<Double> data2 = Lists.newArrayList();
              for (TDigest digest : subs) {
                  for (TDigest.Group group : digest.centroids()) {
                      Iterables.addAll(data2, group.data());
                  }
              }
              Collections.sort(data2);
  
              // verify that the raw data all got recorded
              assertEquals(data.size(), data2.size());
              Iterator<Double> ix = data.iterator();
              for (Double x : data2) {
                  assertEquals(ix.next(), x);
              }
  
              // now merge the sub-digests
              TDigest dist2 = TDigest.merge(50, subs);
  
              for (double q : new double[]{0.001, 0.01, 0.1, 0.2, 0.3, 0.5}) {
                  double z = quantile(q, data);
                  double e1 = dist.quantile(q) - z;
                  double e2 = dist2.quantile(q) - z;
                  System.out.printf("quantile\t%d\t%.6f\t%.6f\t%.6f\t%.6f\t%.6f\n", parts, q, z - q, e1, e2, Math.abs(e2) / q);
                  assertTrue(String.format("parts=%d, q=%.4f, e1=%.5f, e2=%.5f, rel=%.4f", parts, q, e1, e2, Math.abs(e2) / q), Math.abs(e2) / q < 0.1);
                  assertTrue(String.format("parts=%d, q=%.4f, e1=%.5f, e2=%.5f, rel=%.4f", parts, q, e1, e2, Math.abs(e2) / q), Math.abs(e2) < 0.015);
              }
  
              for (double x : new double[]{0.001, 0.01, 0.1, 0.2, 0.3, 0.5}) {
                  double z = cdf(x, data);
                  double e1 = dist.cdf(x) - z;
                  double e2 = dist2.cdf(x) - z;
  
                  System.out.printf("cdf\t%d\t%.6f\t%.6f\t%.6f\t%.6f\t%.6f\n", parts, x, z - x, e1, e2, Math.abs(e2) / x);
                  assertTrue(String.format("parts=%d, x=%.4f, e1=%.5f, e2=%.5f", parts, x, e1, e2), Math.abs(e2) < 0.015);
                  assertTrue(String.format("parts=%d, x=%.4f, e1=%.5f, e2=%.5f", parts, x, e1, e2), Math.abs(e2) / x < 0.1);
              }
          }
      }
test_case.class_method_signature: TDigestTest.testMerge()
test_case.full_signature: @Test public void testMerge()
test_case.identifier: testMerge
test_case.invocations: getRandom newArrayList recordAllData newArrayList add recordAllData newArrayList add recordAllData nextDouble add add add get compress sort newArrayList centroids addAll data sort assertEquals size size iterator assertEquals next merge quantile quantile quantile printf abs assertTrue format abs abs assertTrue format abs abs cdf cdf cdf printf abs assertTrue format abs assertTrue format abs
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMerge()
focal_class.declarator: gen
focal_class.modifier: private
focal_class.original_string: private Random gen;
focal_class.type: Random
focal_class.var_name: gen
focal_class.declarator: compression = 100
focal_class.modifier: private
focal_class.original_string: private double compression = 100;
focal_class.type: double
focal_class.var_name: compression
focal_class.declarator: summary = new GroupTree()
focal_class.modifier: private
focal_class.original_string: private GroupTree summary = new GroupTree();
focal_class.type: GroupTree
focal_class.var_name: summary
focal_class.declarator: count = 0
focal_class.modifier: private
focal_class.original_string: private int count = 0;
focal_class.type: int
focal_class.var_name: count
focal_class.declarator: recordAllData = false
focal_class.modifier: private
focal_class.original_string: private boolean recordAllData = false;
focal_class.type: boolean
focal_class.var_name: recordAllData
focal_class.declarator: VERBOSE_ENCODING = 1
focal_class.modifier: public final static
focal_class.original_string: public final static int VERBOSE_ENCODING = 1;
focal_class.type: int
focal_class.var_name: VERBOSE_ENCODING
focal_class.declarator: SMALL_ENCODING = 2
focal_class.modifier: public final static
focal_class.original_string: public final static int SMALL_ENCODING = 2;
focal_class.type: int
focal_class.var_name: SMALL_ENCODING
focal_class.file: ml/streaminer/src/main/java/org/streaminer/stream/quantile/TDigest.java
focal_class.identifier: TDigest
focal_class.interfaces: implements IQuantiles<Double>
focal_class.class_method_signature: TDigest.TDigest(double compression)
focal_class.full_signature: public  TDigest(double compression)
focal_class.identifier: TDigest
focal_class.modifiers: public
focal_class.parameters: (double compression)
focal_class.signature:  TDigest(double compression)
focal_class.class_method_signature: TDigest.TDigest(double compression, Random random)
focal_class.full_signature: public  TDigest(double compression, Random random)
focal_class.identifier: TDigest
focal_class.modifiers: public
focal_class.parameters: (double compression, Random random)
focal_class.signature:  TDigest(double compression, Random random)
focal_class.class_method_signature: TDigest.add(double x)
focal_class.full_signature: public void add(double x)
focal_class.identifier: add
focal_class.modifiers: public
focal_class.parameters: (double x)
focal_class.return: void
focal_class.signature: void add(double x)
focal_class.class_method_signature: TDigest.add(double x, int w)
focal_class.full_signature: public void add(double x, int w)
focal_class.identifier: add
focal_class.modifiers: public
focal_class.parameters: (double x, int w)
focal_class.return: void
focal_class.signature: void add(double x, int w)
focal_class.class_method_signature: TDigest.add(double x, int w, Group base)
focal_class.full_signature: private void add(double x, int w, Group base)
focal_class.identifier: add
focal_class.modifiers: private
focal_class.parameters: (double x, int w, Group base)
focal_class.return: void
focal_class.signature: void add(double x, int w, Group base)
focal_class.class_method_signature: TDigest.add(TDigest other)
focal_class.full_signature: public void add(TDigest other)
focal_class.identifier: add
focal_class.modifiers: public
focal_class.parameters: (TDigest other)
focal_class.return: void
focal_class.signature: void add(TDigest other)
focal_class.class_method_signature: TDigest.merge(double compression, Iterable<TDigest> subData)
focal_class.full_signature: public static TDigest merge(double compression, Iterable<TDigest> subData)
focal_class.identifier: merge
focal_class.modifiers: public static
focal_class.parameters: (double compression, Iterable<TDigest> subData)
focal_class.return: TDigest
focal_class.signature: TDigest merge(double compression, Iterable<TDigest> subData)
focal_class.class_method_signature: TDigest.compress()
focal_class.full_signature: public void compress()
focal_class.identifier: compress
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void compress()
focal_class.class_method_signature: TDigest.compress(GroupTree other)
focal_class.full_signature: private void compress(GroupTree other)
focal_class.identifier: compress
focal_class.modifiers: private
focal_class.parameters: (GroupTree other)
focal_class.return: void
focal_class.signature: void compress(GroupTree other)
focal_class.class_method_signature: TDigest.size()
focal_class.full_signature: public int size()
focal_class.identifier: size
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int size()
focal_class.class_method_signature: TDigest.cdf(double x)
focal_class.full_signature: public double cdf(double x)
focal_class.identifier: cdf
focal_class.modifiers: public
focal_class.parameters: (double x)
focal_class.return: double
focal_class.signature: double cdf(double x)
focal_class.class_method_signature: TDigest.quantile(double q)
focal_class.full_signature: public double quantile(double q)
focal_class.identifier: quantile
focal_class.modifiers: public
focal_class.parameters: (double q)
focal_class.return: double
focal_class.signature: double quantile(double q)
focal_class.class_method_signature: TDigest.centroidCount()
focal_class.full_signature: public int centroidCount()
focal_class.identifier: centroidCount
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int centroidCount()
focal_class.class_method_signature: TDigest.centroids()
focal_class.full_signature: public Iterable<? extends Group> centroids()
focal_class.identifier: centroids
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Iterable<? extends Group>
focal_class.signature: Iterable<? extends Group> centroids()
focal_class.class_method_signature: TDigest.compression()
focal_class.full_signature: public double compression()
focal_class.identifier: compression
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double compression()
focal_class.class_method_signature: TDigest.recordAllData()
focal_class.full_signature: public TDigest recordAllData()
focal_class.identifier: recordAllData
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: TDigest
focal_class.signature: TDigest recordAllData()
focal_class.class_method_signature: TDigest.byteSize()
focal_class.full_signature: public int byteSize()
focal_class.identifier: byteSize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int byteSize()
focal_class.class_method_signature: TDigest.smallByteSize()
focal_class.full_signature: public int smallByteSize()
focal_class.identifier: smallByteSize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int smallByteSize()
focal_class.class_method_signature: TDigest.asBytes(ByteBuffer buf)
focal_class.full_signature: public void asBytes(ByteBuffer buf)
focal_class.identifier: asBytes
focal_class.modifiers: public
focal_class.parameters: (ByteBuffer buf)
focal_class.return: void
focal_class.signature: void asBytes(ByteBuffer buf)
focal_class.class_method_signature: TDigest.asSmallBytes(ByteBuffer buf)
focal_class.full_signature: public void asSmallBytes(ByteBuffer buf)
focal_class.identifier: asSmallBytes
focal_class.modifiers: public
focal_class.parameters: (ByteBuffer buf)
focal_class.return: void
focal_class.signature: void asSmallBytes(ByteBuffer buf)
focal_class.class_method_signature: TDigest.encode(ByteBuffer buf, int n)
focal_class.full_signature: public static void encode(ByteBuffer buf, int n)
focal_class.identifier: encode
focal_class.modifiers: public static
focal_class.parameters: (ByteBuffer buf, int n)
focal_class.return: void
focal_class.signature: void encode(ByteBuffer buf, int n)
focal_class.class_method_signature: TDigest.decode(ByteBuffer buf)
focal_class.full_signature: public static int decode(ByteBuffer buf)
focal_class.identifier: decode
focal_class.modifiers: public static
focal_class.parameters: (ByteBuffer buf)
focal_class.return: int
focal_class.signature: int decode(ByteBuffer buf)
focal_class.class_method_signature: TDigest.fromBytes(ByteBuffer buf)
focal_class.full_signature: public static TDigest fromBytes(ByteBuffer buf)
focal_class.identifier: fromBytes
focal_class.modifiers: public static
focal_class.parameters: (ByteBuffer buf)
focal_class.return: TDigest
focal_class.signature: TDigest fromBytes(ByteBuffer buf)
focal_class.class_method_signature: TDigest.createGroup(double mean, int id)
focal_class.full_signature: private Group createGroup(double mean, int id)
focal_class.identifier: createGroup
focal_class.modifiers: private
focal_class.parameters: (double mean, int id)
focal_class.return: Group
focal_class.signature: Group createGroup(double mean, int id)
focal_class.class_method_signature: TDigest.interpolate(double x, double x0, double x1)
focal_class.full_signature: private double interpolate(double x, double x0, double x1)
focal_class.identifier: interpolate
focal_class.modifiers: private
focal_class.parameters: (double x, double x0, double x1)
focal_class.return: double
focal_class.signature: double interpolate(double x, double x0, double x1)
focal_class.class_method_signature: TDigest.offer(Double value)
focal_class.full_signature: public void offer(Double value)
focal_class.identifier: offer
focal_class.modifiers: public
focal_class.parameters: (Double value)
focal_class.return: void
focal_class.signature: void offer(Double value)
focal_class.class_method_signature: TDigest.getQuantile(double q)
focal_class.full_signature: public Double getQuantile(double q)
focal_class.identifier: getQuantile
focal_class.modifiers: public
focal_class.parameters: (double q)
focal_class.return: Double
focal_class.signature: Double getQuantile(double q)
focal_method.body: public static TDigest merge(double compression, Iterable<TDigest> subData) {
          Preconditions.checkArgument(subData.iterator().hasNext(), "Can't merge 0 digests");
          List<TDigest> elements = Lists.newArrayList(subData);
          int n = Math.max(1, elements.size() / 4);
          TDigest r = new TDigest(compression, elements.get(0).gen);
          if (elements.get(0).recordAllData) {
              r.recordAllData();
          }
          for (int i = 0; i < elements.size(); i += n) {
              if (n > 1) {
                  r.add(merge(compression, elements.subList(i, Math.min(i + n, elements.size()))));
              } else {
                  r.add(elements.get(i));
              }
          }
          return r;
      }
focal_method.class_method_signature: TDigest.merge(double compression, Iterable<TDigest> subData)
focal_method.full_signature: public static TDigest merge(double compression, Iterable<TDigest> subData)
focal_method.identifier: merge
focal_method.invocations: checkArgument hasNext iterator newArrayList max size get get recordAllData size add merge subList min size add get
focal_method.modifiers: public static
focal_method.parameters: (double compression, Iterable<TDigest> subData)
focal_method.return: TDigest
focal_method.signature: TDigest merge(double compression, Iterable<TDigest> subData)