Package cern.colt.list

Examples of cern.colt.list.DoubleArrayList


   public void clearCache() {
      //values.clear();
      // Keep the array previously returned by getCachedValues
      // intact to allow caching values for several
      // replications.
      values = new DoubleArrayList();
      index = 0;
   }
View Full Code Here


    *
    *
    */
   public void setTicksSynchro (int s)  {
      if (((CustomHistogramDataset)this.dataset.getSeriesCollection()).getBinWidth(s) == -1){
         DoubleArrayList newTicks = new DoubleArrayList();
         ListIterator binsIter = ((HistogramSeriesCollection)this.dataset).getBins(s).listIterator();

         int i = 0;
         HistogramBin prec = (HistogramBin)binsIter.next();
         double var;
         newTicks.add(prec.getStartBoundary());
         newTicks.add(var = prec.getEndBoundary());
         HistogramBin temp;
         while(binsIter.hasNext()) {
            temp = (HistogramBin)binsIter.next();
            if(temp.getStartBoundary() != var) {
               newTicks.add(var = temp.getStartBoundary());
            } else if(temp.getEndBoundary() != var) {
               newTicks.add(var = temp.getEndBoundary());
            }
         }
         XAxis.setLabels(newTicks.elements());
      }
      else {
         XAxis.setLabels(((CustomHistogramDataset)this.dataset.getSeriesCollection()).getBinWidth(s));
      }
   }
View Full Code Here

    removeOutlierTraces(traces, mus, sigmas);

    int numOfTraces = traces.size();

    DoubleArrayList scheduleTimes = new DoubleArrayList();
    List<DoubleArrayList> scheduleDeviations = new ArrayList<DoubleArrayList>();

    for (int i = 0; i < numOfTraces; i++)
      scheduleDeviations.add(new DoubleArrayList());

    for (int t = from; t <= to; t += step) {

      DoubleArrayList rawValues = new DoubleArrayList();
      DoubleArrayList values = new DoubleArrayList();

      for (SortedMap<Integer, Double> m : traces) {
        if (t < m.firstKey() || t > m.lastKey()) {
          rawValues.add(Double.NaN);
          continue;
        }
        double schedDev = InterpolationLibrary.interpolate(m, t);
        values.add(schedDev);
        rawValues.add(schedDev);
      }

      if (values.size() < Math.max(_minSampleSize, 2))
        continue;

      double mu = Descriptive.mean(values);
      double sigma = Descriptive.sampleStandardDeviation(values.size(),
          Descriptive.sampleVariance(values, mu));

      int goodValueCount = pruneOutlierValues(rawValues, mu, sigma);
      if (goodValueCount < _minSampleSize)
        continue;

      scheduleTimes.add(t);
      for (int traceIndex = 0; traceIndex < traces.size(); traceIndex++)
        scheduleDeviations.get(traceIndex).add(rawValues.get(traceIndex));
    }

    scheduleTimes.trimToSize();
    double[] scheduleTimesArray = scheduleTimes.elements();

    double[][] scheduleDeviationsArrays = new double[numOfTraces][];

    for (int traceIndex = 0; traceIndex < numOfTraces; traceIndex++) {
      DoubleArrayList list = scheduleDeviations.get(traceIndex);
      list.trimToSize();
      scheduleDeviationsArrays[traceIndex] = list.elements();
    }

    return new ScheduleDeviationHistory(tripId, scheduleTimesArray,
        scheduleDeviationsArrays);
  }
View Full Code Here

  private void computeMeanAndStandardDeviationForTraces(
      List<SortedMap<Integer, Double>> traces, int from, int to, int step,
      SortedMap<Integer, Double> mus, SortedMap<Integer, Double> sigmas) {

    for (int x = from; x <= to; x += step) {
      DoubleArrayList values = new DoubleArrayList();
      for (SortedMap<Integer, Double> m : traces) {
        if (x < m.firstKey() || x > m.lastKey())
          continue;
        double schedDev = InterpolationLibrary.interpolate(m, x);
        values.add(schedDev);
      }
      if (values.size() < 2)
        continue;
      double mu = Descriptive.mean(values);
      double sigma = Descriptive.sampleStandardDeviation(values.size(),
          Descriptive.sampleVariance(values, mu));
      mus.put(x, mu);
      sigmas.put(x, sigma);
    }
  }
View Full Code Here

  private void computeCumulativeProbabilityForRealTimeBlockLocations(
      Map<Date, Record> recordsByTime, List<BlockLocation> locations,
      double minProbabilityForConsideration,
      List<CurrentVehicleEstimateBean> beans) {

    DoubleArrayList ps = new DoubleArrayList();

    for (BlockLocation location : locations) {

      Date t = new Date(location.getTime());
      Record record = recordsByTime.get(t);

      CoordinatePoint userLocation = record.getLocation();
      CoordinatePoint vehicleLocation = location.getLocation();

      double d = SphericalGeometryLibrary.distance(userLocation,
          vehicleLocation);

      double p = _realTimeLocationDeviationModel.probability(d);
      ps.add(p);
    }

    BlockLocation last = locations.get(locations.size() - 1);
    double mu = Descriptive.mean(ps);
    String debug = asString(ps);
View Full Code Here

  private void computeCumulativeProbabilityForScheduledBlockLocations(
      List<Record> records, BlockInstance blockInstance,
      double minProbabilityForConsideration,
      List<CurrentVehicleEstimateBean> beans) {

    DoubleArrayList ps = new DoubleArrayList();
    List<ScheduledBlockLocation> blockLocations = new ArrayList<ScheduledBlockLocation>();

    Record firstRecord = records.get(0);
    ScheduledBlockLocation firstLocation = _blockGeospatialService.getBestScheduledBlockLocationForLocation(
        blockInstance, firstRecord.getLocation(), firstRecord.getTimestamp(),
        0, Double.POSITIVE_INFINITY);
    blockLocations.add(firstLocation);

    ps.add(updateScheduledBlockLocationProbability(blockInstance, firstRecord,
        firstLocation));

    Record lastRecord = records.get(records.size() - 1);
    ScheduledBlockLocation lastLocation = _blockGeospatialService.getBestScheduledBlockLocationForLocation(
        blockInstance, lastRecord.getLocation(), lastRecord.getTimestamp(), 0,
        Double.POSITIVE_INFINITY);

    ps.add(updateScheduledBlockLocationProbability(blockInstance, lastRecord,
        lastLocation));

    if (Descriptive.mean(ps) < minProbabilityForConsideration)
      return;

    /**
     * If the vehicle is traveling backwards in time, we kill the prediction
     */
    int maxTravelBackwardsTime = computeMaxTravelBackwardsTime(lastRecord.getTimestamp()
        - firstRecord.getTimestamp());

    if (lastLocation.getScheduledTime() < firstLocation.getScheduledTime()
        - maxTravelBackwardsTime)
      return;

    double minDistanceAlongBlock = Math.min(
        firstLocation.getDistanceAlongBlock(),
        lastLocation.getDistanceAlongBlock()) - 500;
    double maxDistanceAlongBlock = Math.max(
        firstLocation.getDistanceAlongBlock(),
        lastLocation.getDistanceAlongBlock()) + 500;

    for (int i = 1; i < records.size() - 1; i++) {

      Record record = records.get(i);
      ScheduledBlockLocation location = _blockGeospatialService.getBestScheduledBlockLocationForLocation(
          blockInstance, record.getLocation(), record.getTimestamp(),
          minDistanceAlongBlock, maxDistanceAlongBlock);
      blockLocations.add(location);

      ps.add(updateScheduledBlockLocationProbability(blockInstance, record,
          location));

      if (Descriptive.mean(ps) < minProbabilityForConsideration)
        return;
    }
View Full Code Here

    ScheduleDeviationHistory resampledHistory = resampleHistory(history,
        scheduledBlockLocation.getScheduledTime(),
        record.getScheduleDeviation());

    DoubleArrayList scheduleTimes = new DoubleArrayList();
    DoubleArrayList mus = new DoubleArrayList();
    DoubleArrayList sigmas = new DoubleArrayList();

    for (int t = 0; t <= _predictionLookahead; t += 5 * 60) {

      int scheduleTime = scheduledBlockLocation.getScheduledTime() + t;
      double[] deviations = getScheduleDeviationsForScheduleTime(
          resampledHistory, scheduleTime);

      deviations = noNans(deviations);
      DoubleArrayList values = new DoubleArrayList(deviations);

      double mu = Descriptive.mean(values);
      double var = Descriptive.sampleVariance(values, mu);
      double sigma = Descriptive.sampleStandardDeviation(values.size(), var);

      scheduleTimes.add(scheduleTime);
      mus.add(mu);
      sigmas.add(sigma);
    }
View Full Code Here

      v[i] = values[i][index];
    return v;
  }

  private double[] noNans(double[] values) {
    DoubleArrayList vs = new DoubleArrayList();
    for (double v : values) {
      if (!Double.isNaN(v))
        vs.add(v);
    }
    vs.trimToSize();
    return vs.elements();
  }
View Full Code Here

      return direction;

    Collection<PointAndOrientation> orientations = getAllOrientationsForStop(
        provider, stopEntry);

    DoubleArrayList ys = new DoubleArrayList();
    DoubleArrayList xs = new DoubleArrayList();

    for (PointAndOrientation po : orientations) {
      double orientation = Math.toRadians(po.getOrientation());
      double x = Math.cos(orientation);
      double y = Math.sin(orientation);
      xs.add(x);
      ys.add(y);
    }

    if (ys.isEmpty())
      return null;

    if (ys.size() == 1) {
      double theta = Math.atan2(ys.get(0), xs.get(0));
      return getAngleAsDirection(theta);
    }

    double yMu = Descriptive.mean(ys);
    double xMu = Descriptive.mean(xs);

    /**
     * Check for undefined case where angles are directly opposite
     */
    if (yMu == 0.0 && xMu == 0.0)
      return null;

    double thetaMu = Math.atan2(yMu, xMu);

    double yVariance = Descriptive.sampleVariance(ys, yMu);
    double xVariance = Descriptive.sampleVariance(xs, xMu);

    double yStdDev = Descriptive.sampleStandardDeviation(ys.size(), yVariance);
    double xStdDev = Descriptive.sampleStandardDeviation(xs.size(), xVariance);

    if (yStdDev > _stopDirectionStandardDeviationThreshold
        || xStdDev > _stopDirectionStandardDeviationThreshold) {
      return null;
    }

    DoubleArrayList normalizedThetas = new DoubleArrayList();

    for (PointAndOrientation po : orientations) {
      double orientation = Math.toRadians(po.getOrientation());
      double delta = orientation - thetaMu;
      delta = normalizeDelta(delta);
      orientation = thetaMu + delta;
      normalizedThetas.add(orientation);
    }

    normalizedThetas.sort();
    double thetaMedian = Descriptive.median(normalizedThetas);

    return getAngleAsDirection(thetaMedian);
  }
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.