Package cern.colt.list

Examples of cern.colt.list.DoubleArrayList


   
  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

* @param phi the percentage for which the quantile is to be computed.
* phi must be in the interval <tt>(0.0,1.0]</tt>.
* @return the phi quantile element.
*/
public synchronized double quantile(double phi) {
  return quantiles(new DoubleArrayList(new double[] {phi})).get(0);
}
View Full Code Here

      subBins[c++] = percent[i] + j*step;
    }
  }

  // compute quantile elements;
  double[] quantiles = quantiles(new DoubleArrayList(subBins)).elements();

  // collect summary statistics for each bin.
  // one bin's statistics are the integrated statistics of its subintervals.
  MightyStaticBin1D[] splitBins = new MightyStaticBin1D[noOfBins];
  int maxOrderForSumOfPowers =  getMaxOrderForSumOfPowers();
View Full Code Here

@param axis an axis defining interval boundaries.
@param resolution a measure of accuracy; the desired number of subintervals per interval.
*/
public synchronized MightyStaticBin1D[] splitApproximately(hep.aida.IAxis axis, int k) {
  DoubleArrayList percentages = new DoubleArrayList(new hep.aida.ref.Converter().edges(axis));
  percentages.beforeInsert(0,Double.NEGATIVE_INFINITY);
  percentages.add(Double.POSITIVE_INFINITY);
  for (int i=percentages.size(); --i >= 0; ) {
    percentages.set(i, quantileInverse(percentages.get(i)));
  }
 
  return splitApproximately(percentages,k);
}
View Full Code Here

*
* @param element element to be appended.
*/
public synchronized void add(double element) {
  // prototyping implementation; inefficient; TODO
  this.addAllOf(new DoubleArrayList(new double[] {element}));
  /*
  sumSquares += element * element;
  if (this.done == 0) { // initial setup
    this.min = element;
    this.max = element;
View Full Code Here

  if (k<0) throw new IllegalArgumentException("k must be >= 0");
  //checkOrder(k);
  if (!hasSumOfPowers(k)) return Double.NaN;

  int maxOrder = Math.min(k,getMaxOrderForSumOfPowers());
  DoubleArrayList sumOfPows = new DoubleArrayList(maxOrder+1);
  sumOfPows.add(size());
  sumOfPows.add(sum());
  sumOfPows.add(sumOfSquares());
  for (int i=3; i<=maxOrder; i++) sumOfPows.add(sumOfPowers(i));
 
  return Descriptive.moment(k, c, size(), sumOfPows.elements());
}
View Full Code Here

* Constructs and returns an empty bin; implicitly calls {@link #setFixedOrder(boolean) setFixedOrder(false)}.
*/
public DynamicBin1D() {
  super();
  this.clear();
  this.elements = new DoubleArrayList();
  this.sortedElements = new DoubleArrayList(0);
  this.fixedOrder = false;
  this.hasSumOfLogarithms = true;
  this.hasSumOfInversions = true;
}
View Full Code Here

/**
* Returns a String representation of the receiver.
*/
public synchronized String toString() {
  StringBuffer buf = new StringBuffer(super.toString());
  DoubleArrayList distinctElements = new DoubleArrayList();
  IntArrayList frequencies = new IntArrayList();
  frequencies(distinctElements,frequencies);
  if (distinctElements.size() < 100) { // don't cause unintended floods
    buf.append("Distinct elements: "+distinctElements+"\n");
    buf.append("Frequencies: "+frequencies+"\n");
  }
  else {
    buf.append("Distinct elements & frequencies not printed (too many).");
View Full Code Here

*
* @param s the number of smallest elements to trim away (<tt>s >= 0</tt>).
* @param l the number of largest elements to trim away (<tt>l >= 0</tt>).
*/
public synchronized void trim(int s, int l) {
  DoubleArrayList elems = sortedElements();
  clear();
  addAllOfFromTo(elems, s, elems.size()-1 - l);
}
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.