Package cern.colt.list

Examples of cern.colt.list.DoubleArrayList


/**
* Returns a string representation of the receiver, containing
* the String representation of each key-value pair, sorted ascending by value.
*/
public String toStringByValue() {
  DoubleArrayList theKeys = new DoubleArrayList();
  keysSortedByValue(theKeys);

  StringBuffer buf = new StringBuffer();
  buf.append("[");
  int maxIndex = theKeys.size() - 1;
  for (int i = 0; i <= maxIndex; i++) {
    double key = theKeys.get(i);
      buf.append(String.valueOf(key));
    buf.append("->");
      buf.append(String.valueOf(get(key)));
    if (i < maxIndex) buf.append(", ");
  }
View Full Code Here


    }
  else {
    this.beta=1.0;
  }
  
  DoubleArrayList quantileElements = super.quantileElements(phis);

  // restore state we were in before.
  // remove the temporarily added infinities.
  if (partial != null) removeInfinitiesFrom(missingValues, partial);
View Full Code Here

* This method was created in VisualAge.
* @param k int
*/
public DoubleBuffer(int k) {
  super(k);
  this.values = new DoubleArrayList(0);
  this.isSorted = false;
}
View Full Code Here

  protected boolean isSorted;
/**
* Constructs an empty exact quantile finder.
*/
public ExactDoubleQuantileFinder() {
  this.buffer = new DoubleArrayList(0);
  this.clear();
}
View Full Code Here

}
/**
* Observed epsilon
*/
public static double epsilon(DoubleArrayList sortedList, DoubleQuantileFinder finder, double phi) {
  double element = finder.quantileElements(new DoubleArrayList(new double[] {phi})).get(0);
  return epsilon(sortedList, phi, element);
}
View Full Code Here

public static double observedEpsilonAtPhi(double phi, ExactDoubleQuantileFinder exactFinder, DoubleQuantileFinder approxFinder) {
  int N = (int) exactFinder.size();
 
  int exactRank = (int) Utils.epsilonCeiling(phi * N) - 1;
  //System.out.println("exactRank="+exactRank);
  exactFinder.quantileElements(new DoubleArrayList(new double[] {phi})).get(0); // just to ensure exactFinder is sorted
  double approxElement = approxFinder.quantileElements(new DoubleArrayList(new double[] {phi})).get(0);
  //System.out.println("approxElem="+approxElement);
  IntArrayList approxRanks = binaryMultiSearch(exactFinder.buffer, approxElement);
  int from = approxRanks.get(0);
  int to = approxRanks.get(1);

View Full Code Here

* @return double[]
* @param values cern.it.hepodbms.primitivearray.DoubleArrayList
* @param phis double[]
*/
public static DoubleArrayList observedEpsilonsAtPhis(DoubleArrayList phis, ExactDoubleQuantileFinder exactFinder, DoubleQuantileFinder approxFinder, double desiredEpsilon) {
  DoubleArrayList epsilons = new DoubleArrayList(phis.size());
 
  for (int i=phis.size(); --i >=0;) {
    double epsilon = observedEpsilonAtPhi(phis.get(i), exactFinder, approxFinder);
    epsilons.add(epsilon);
    if (epsilon>desiredEpsilon) System.out.println("Real epsilon = "+epsilon+" is larger than desired by "+(epsilon-desiredEpsilon));
  }
  return epsilons;
}
View Full Code Here

   
  DoubleQuantileFinder exactFinder = QuantileFinderFactory.newDoubleQuantileFinder(false, -1, 0.0, delta, quantiles, null);
  System.out.println(exactFinder);

  DoubleArrayList list = new DoubleArrayList(size);

  for (int chunk=0; chunk<chunks; chunk++) {
    list.setSize(0);
    int d = chunk*size;
    timer2.start();
    for (int i=0; i<size; i++) {
      list.add((double)(i + d));
    }
    timer2.stop();
   

   
    //System.out.println("unshuffled="+list);
    if (doShuffle) {
      Timer timer3 = new Timer().start();
      list.shuffle();
      System.out.println("shuffling took ");
      timer3.stop().display();
    }
    //System.out.println("shuffled="+list);
    //list.sort();
    //System.out.println("sorted="+list);

    timer.start();
    approxFinder.addAllOf(list);
    timer.stop();

    if (computeExactQuantilesAlso) {
      exactFinder.addAllOf(list);
    }

  }
  System.out.println("list.add() took" + timer2);
  System.out.println("approxFinder.add() took" + timer);

  //System.out.println("free="+Runtime.getRuntime().freeMemory());
  //System.out.println("total="+Runtime.getRuntime().totalMemory());

  timer.reset().start();

  //approxFinder.close();
  DoubleArrayList approxQuantiles = approxFinder.quantileElements(new DoubleArrayList(phis));

  timer.stop().display();
 
  System.out.println("Phis="+new DoubleArrayList(phis));
  System.out.println("ApproxQuantiles="+approxQuantiles);

  //System.out.println("MaxLevel of full buffers="+maxLevelOfFullBuffers(approxFinder.bufferSet));

  //System.out.println("total buffers filled="+ approxFinder.totalBuffersFilled);
  //System.out.println("free="+Runtime.getRuntime().freeMemory());
  //System.out.println("total="+Runtime.getRuntime().totalMemory());


  if (computeExactQuantilesAlso) {
    System.out.println("Comparing with exact quantile computation...");

    timer.reset().start();

    //exactFinder.close();
    DoubleArrayList exactQuantiles = exactFinder.quantileElements(new DoubleArrayList(phis));
    timer.stop().display();

    System.out.println("ExactQuantiles="+exactQuantiles);


    //double[] errors1 = errors1(exactQuantiles.elements(), approxQuantiles.elements());
    //System.out.println("Error1="+new DoubleArrayList(errors1));

    /*
    final DoubleArrayList buffer = new DoubleArrayList((int)exactFinder.size());
    exactFinder.forEach(
      new cern.colt.function.DoubleFunction() {
        public void apply(double element) {
          buffer.add(element);
        }
      }
    );
    */
       
   
    DoubleArrayList observedEpsilons = observedEpsilonsAtPhis(new DoubleArrayList(phis), (ExactDoubleQuantileFinder) exactFinder, approxFinder, epsilon);
    System.out.println("observedEpsilons="+observedEpsilons);

    double element = 1000.0f;
   

    System.out.println("exact phi("+element+")="+exactFinder.phi(element));
    System.out.println("apprx phi("+element+")="+approxFinder.phi(element));

    System.out.println("exact elem(phi("+element+"))="+exactFinder.quantileElements(new DoubleArrayList(new double[] {exactFinder.phi(element)})));
    System.out.println("apprx elem(phi("+element+"))="+approxFinder.quantileElements(new DoubleArrayList(new double[] {approxFinder.phi(element)})));
  }
}
View Full Code Here

}
/**
* Not yet commented.
*/
public static void testRank() {
  DoubleArrayList list = new DoubleArrayList(new double[] {1.0f, 5.0f, 5.0f, 5.0f, 7.0f, 10.f});
  //System.out.println(rankOfWithin(5.0f, list));
}
View Full Code Here

  DoubleBuffer[] fullBuffers = bufferSet._getFullOrPartialBuffers();
  double[] quantileElements = new double[phis.size()];

  //do the main work: determine values at given positions in sorted sequence
  return new DoubleArrayList(bufferSet.getValuesAtPositions(fullBuffers, triggerPositions));
}
View Full Code Here

TOP

Related Classes of cern.colt.list.DoubleArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.