/** Returns an immutable snapshot of the current statistics. */ public Stats snapshot() { return new Stats(count, mean, sumOfSquaresOfDeltas, min, max); }
/** Returns an immutable snapshot of the current statistics. */ public Stats snapshot() { return new Stats(count, mean, sumOfSquaresOfDeltas, min, max); }
/** Returns an immutable snapshot of the current statistics. */ public Stats snapshot() { return new Stats(count, mean, sumOfSquaresOfDeltas, min, max); }
/** * Creates a Stats instance from the byte representation read from the given {@link ByteBuffer}. * * <p><b>Note:</b> No guarantees are made regarding stability of the representation between * versions. * * @param buffer A {@link ByteBuffer} with at least BYTES {@link ByteBuffer#remaining}, ordered as * {@link ByteOrder#LITTLE_ENDIAN}, from which a BYTES-long byte representation of this * instance is read. In the process increases the position of {@link ByteBuffer} by BYTES. */ static Stats readFrom(ByteBuffer buffer) { checkNotNull(buffer); checkArgument( buffer.remaining() >= BYTES, "Expected at least Stats.BYTES = %s remaining , got %s", BYTES, buffer.remaining()); return new Stats( buffer.getLong(), buffer.getDouble(), buffer.getDouble(), buffer.getDouble(), buffer.getDouble()); }
/** * Creates a Stats instance from the byte representation read from the given {@link ByteBuffer}. * * <p><b>Note:</b> No guarantees are made regarding stability of the representation between * versions. * * @param buffer A {@link ByteBuffer} with at least BYTES {@link ByteBuffer#remaining}, ordered as * {@link ByteOrder#LITTLE_ENDIAN}, from which a BYTES-long byte representation of this * instance is read. In the process increases the position of {@link ByteBuffer} by BYTES. */ static Stats readFrom(ByteBuffer buffer) { checkNotNull(buffer); checkArgument( buffer.remaining() >= BYTES, "Expected at least Stats.BYTES = %s remaining , got %s", BYTES, buffer.remaining()); return new Stats( buffer.getLong(), buffer.getDouble(), buffer.getDouble(), buffer.getDouble(), buffer.getDouble()); }
/** * Creates a Stats instance from the byte representation read from the given {@link ByteBuffer}. * * <p><b>Note:</b> No guarantees are made regarding stability of the representation between * versions. * * @param buffer A {@link ByteBuffer} with at least BYTES {@link ByteBuffer#remaining}, ordered as * {@link ByteOrder#LITTLE_ENDIAN}, from which a BYTES-long byte representation of this * instance is read. In the process increases the position of {@link ByteBuffer} by BYTES. */ static Stats readFrom(ByteBuffer buffer) { checkNotNull(buffer); checkArgument( buffer.remaining() >= BYTES, "Expected at least Stats.BYTES = %s remaining , got %s", BYTES, buffer.remaining()); return new Stats( buffer.getLong(), buffer.getDouble(), buffer.getDouble(), buffer.getDouble(), buffer.getDouble()); }
public void testEqualsAndHashCode() { new EqualsTester() .addEqualityGroup( Stats.of(1.0, 1.0, 5.0, 5.0), Stats.of(1.0, 1.0, 5.0, 5.0), Stats.of(ImmutableList.of(1.0, 1.0, 5.0, 5.0)), Stats.of(ImmutableList.of(1.0, 1.0, 5.0, 5.0).iterator()), SerializableTester.reserialize(Stats.of(1.0, 1.0, 5.0, 5.0))) .addEqualityGroup(Stats.of(1.0, 5.0)) .addEqualityGroup(Stats.of(1.0, 5.0, 1.0, 6.0)) .addEqualityGroup(Stats.of(2.0, 6.0, 2.0, 6.0)) .addEqualityGroup( new Stats(5, -5.5, 55.5, -5.55, 5.55), new Stats(5, -5.5, 55.5, -5.55, 5.55)) .addEqualityGroup(new Stats(6, -5.5, 55.5, -5.55, 5.55)) .addEqualityGroup(new Stats(5, -5.6, 55.5, -5.55, 5.55)) .addEqualityGroup(new Stats(5, -5.5, 55.6, -5.55, 5.55)) .addEqualityGroup(new Stats(5, -5.5, 55.5, -5.56, 5.55)) .addEqualityGroup(new Stats(5, -5.5, 55.5, -5.55, 5.56)) .testEquals(); }
for (Car car : cars { Stats s = stats.get(car.maker); if (s == null) { s = new Stats(); stats.put(car.maker, s); } stats.count++; stats.totalWeight+=car.weight; } for (Car car in importantCars) { stats.get(car.maker); }
function Stats() { this.total = (function(args){ var total = 0; for(var i = 0; i < args.length; i++) { total += args[i]; } return total; })(arguments); } var output = new Stats(10, 10, 5, 10, 10, 10,100,24,1000); console.log(output.total);
function Person(){ this.age = 30; } function Stats(){ this.age = 20 } Stats.prototype = new Person(); // Note that this is not your code example var fred = new Stats(); console.log(fred.age) console.log(Object.getPrototypeOf(fred).age);
/** Returns an immutable snapshot of the current statistics. */ public Stats snapshot() { return new Stats(count, mean, sumOfSquaresOfDeltas, min, max); }
function Game() { this.id; this.stats = new Stats(this); } function Stats(game) { this.property; this.method = method; function method() { this.property; game.id; } } var game = new Game; game.stats.method();
/** Returns an immutable snapshot of the current statistics. */ public Stats snapshot() { return new Stats(count, mean, sumOfSquaresOfDeltas, min, max); }
function Stats() { var _arguments = arguments; this.sum = function() { var i = _arguments.length; var result = 0; while (i--) { result += _arguments[i]; } return result; }; } var output = new Stats(10, 25, 5, 84, 8, 44); console.log(output.sum());
class Character { private Stats stats = new Stats(); }
static Stats getStatsFromVals(List<Double> vals) { double min = Double.POSITIVE_INFINITY; double max = Double.NEGATIVE_INFINITY; double avg = 0.0; for(double val : vals) { avg += val; if(val < min) min = val; if(val > max) max = val; } avg /= vals.size(); return new Stats(min, max, avg); }
Map<String, Stats> map = lines.map(s -> s.split(",")).collect( Collectors.groupingBy(a -> a[0], Collectors.mapping(a -> new Stats(Integer.parseInt(a[1]), Integer.parseInt(a[2])), Collectors.reducing(new Stats(), Stats::merge)))); System.out.println(map);
Stats stats = new Stats(); documentRelivency.forEach(relevant -> { stats.add(relevant); System.out.format("%9.2f\t%.2f\t%.2f\t\n", stats.getPrecision(), stats.getRecall(), stats.getFMeasure()); });
Stats s = new Stats (); ... some loop ... s.count (); s.end (); s.print ();