@Override public int size() { return list.size(); }
private void sortMetrics(TObjectDoubleMap<String> metrics, final List<String> activities, final TDoubleList values) { metrics.forEachEntry((s, v) -> { boolean inserted = false; for (int i = 0; i < values.size() && i < limit; i++) { if (v > values.get(i)) { values.insert(i, v); activities.add(i, s); inserted = true; break; } } if (!inserted && values.size() < limit) { activities.add(s); values.add(v); } return true; }); } }
private int getNumOfColors() { return weights.size(); }
@Override public int size() { return list.size(); }
@Override public int size() { return list.size(); }
@Override public int size() { return list.size(); }
@Override public int size() { return list.size(); }
public int getCount() { return values.size(); }
@Override public String dump() { init(); StringBuffer buff = new StringBuffer("loess normalizer"); if (logTransform) buff.append(" (log'ed)"); DecimalFormat df = new DecimalFormat("#.##"); for (int i = 0; i <= 20; i++) { int j = Math.min(X.size() - 1, i * X.size() / 20); double x = X.get(j); buff.append(" <" + df.format(x) + "," + df.format(normalize(x)) + ">"); } return buff.toString(); }
/** * Constructs a new {@code MovingAverage} * * @param historicalValues list of entry values * @param windowSize length over which to take the average */ public MovingAverage(TDoubleList historicalValues, double total, int windowSize) { if(windowSize <= 0) { throw new IllegalArgumentException("Window size must be > 0"); } this.windowSize = windowSize; calc = new Calculation(); calc.historicalValues = historicalValues == null || historicalValues.size() < 1 ? new TDoubleArrayList(windowSize) : historicalValues; calc.total = total != -1 ? total : calc.historicalValues.sum(); }
/** * Replaces the current buffer data with the list of bytes in the give {@link gnu.trove.list.TDoubleList} This method arbitrarily creates data for the ByteBuffer regardless of the data type of the * vertex attribute. * * @param list to set */ public void setData(TDoubleList list) { this.buffer = CausticUtil.createByteBuffer(list.size() * DataType.DOUBLE.getByteSize()); final TDoubleIterator iterator = list.iterator(); while (iterator.hasNext()) { buffer.putDouble(iterator.next()); } }
public double getPearsonsCorrelation() { TDoubleList actual = new TDoubleArrayList(); TDoubleList expected = new TDoubleArrayList(); for (MostSimilarGuess msg : guesses) { for (MostSimilarGuess.Observation o : msg.getObservations()) { if (!Double.isInfinite(o.estimate) && !Double.isNaN(o.estimate)) { actual.add(o.actual); expected.add(o.estimate); } } } if (actual.size() < 2) { return Double.NaN; } else { return new PearsonsCorrelation().correlation(actual.toArray(), expected.toArray()); } }
/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( other == this ) { return true; } if ( !( other instanceof TDoubleList ) ) return false; if ( other instanceof TDoubleArrayList ) { TDoubleArrayList that = ( TDoubleArrayList )other; if ( that.size() != this.size() ) return false; for ( int i = _pos; i-- > 0; ) { if ( this._data[ i ] != that._data[ i ] ) { return false; } } return true; } else { TDoubleList that = ( TDoubleList )other; if ( that.size() != this.size() ) return false; for( int i = 0; i < _pos; i++ ) { if ( this._data[ i ] != that.get( i ) ) { return false; } } return true; } }
public double getSpearmansCorrelation() { TDoubleList actual = new TDoubleArrayList(); TDoubleList expected = new TDoubleArrayList(); for (MostSimilarGuess msg : guesses) { for (MostSimilarGuess.Observation o : msg.getObservations()) { if (!Double.isInfinite(o.estimate) && !Double.isNaN(o.estimate)) { actual.add(o.actual); expected.add(o.estimate); } } } if (actual.size() < 2) { return Double.NaN; } else { return new SpearmansCorrelation().correlation(actual.toArray(), expected.toArray()); } }
/** * Get average speed for set of trips that begin within the time window in meters per second. * @param trips * @param from * @param to * @return avg. speed (meters per second) */ public double getAverageSpeedForTrips (Collection<Trip> trips, LocalTime from, LocalTime to) { TDoubleList speeds = new TDoubleArrayList(); for (Trip trip : trips) { StopTime firstStopTime = feed.stop_times.ceilingEntry(Fun.t2(trip.trip_id, null)).getValue(); LocalTime tripBeginTime = LocalTime.ofSecondOfDay(firstStopTime.departure_time % 86399); // convert 24hr+ seconds to 0 - 86399 // skip trip if begin time is before or after specified time period if (tripBeginTime.isAfter(to) || tripBeginTime.isBefore(from)) { continue; } // TODO: swap straight lines for actual geometry? double speed = feed.getTripSpeed(trip.trip_id, true); if (!Double.isNaN(speed)) { speeds.add(speed); } } if (speeds.isEmpty()) return -1; return speeds.sum() / speeds.size(); }
public void draw() { if (checkDirty()) { updateCache(); } Timer timer = ClientUtil.getTimer(); float c = 1; float a = 0.2f; if (timer != null) { c = Math.round(( ((float) Math.sin((Minecraft.getMinecraft().world.getTotalWorldTime() + timer.renderPartialTicks) / 5)) / 2) + 0.5f); a = Math.abs(2 * (float) Math.sin(((Minecraft.getMinecraft().world.getTotalWorldTime() + timer.renderPartialTicks) / 5))) * 0.1f; } GlStateManager.pushMatrix(); BufferBuilder buf = Tessellator.getInstance().getBuffer(); buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); for (int i = 0; i < geometryCache.size(); i += 3) { buf.pos(geometryCache.get(i), geometryCache.get(i + 1), geometryCache.get(i + 2)).color(c, c, c, a).endVertex(); } Tessellator.getInstance().draw(); GlStateManager.popMatrix(); }