public void testMax_noArgs() { try { Doubles.max(); fail(); } catch (IllegalArgumentException expected) { } }
public void testMax() { assertEquals(LEAST, Doubles.max(LEAST)); assertEquals(GREATEST, Doubles.max(GREATEST)); assertEquals( (double) 9, Doubles.max( (double) 8, (double) 6, (double) 7, (double) 5, (double) 3, (double) 0, (double) 9)); assertEquals(0.0, Doubles.max(-0.0, 0.0)); assertEquals(0.0, Doubles.max(0.0, -0.0)); assertEquals(GREATEST, Doubles.max(NUMBERS)); assertTrue(Double.isNaN(Doubles.max(VALUES))); }
/** * Compares the absolute values of 4 signed doubles and returns the unsigned * magnitude of the number with the greatest absolute value. */ public static double maxNum(double a, double b, double c, double d) { // take the absolute values of the given numbers a = Math.abs(a); b = Math.abs(b); c = Math.abs(c); d = Math.abs(d); // compare the numbers and return the unsigned value of the one with the greatest magnitude return Doubles.max(a, b, c, d); }
/** * Compares the absolute values of 4 signed doubles and returns the unsigned * magnitude of the number with the greatest absolute value. */ public static double maxNum(double a, double b, double c, double d) { // take the absolute values of the given numbers a = Math.abs(a); b = Math.abs(b); c = Math.abs(c); d = Math.abs(d); // compare the numbers and return the unsigned value of the one with the greatest magnitude return Doubles.max(a, b, c, d); }
/** * Compares the absolute values of 4 signed doubles and returns the unsigned * magnitude of the number with the greatest absolute value. */ public static double maxNum(double a, double b, double c, double d) { // take the absolute values of the given numbers a = Math.abs(a); b = Math.abs(b); c = Math.abs(c); d = Math.abs(d); // compare the numbers and return the unsigned value of the one with the greatest magnitude return Doubles.max(a, b, c, d); }
public void testMax() { assertEquals(LEAST, Doubles.max(LEAST)); assertEquals(GREATEST, Doubles.max(GREATEST)); assertEquals((double) 9, Doubles.max( (double) 8, (double) 6, (double) 7, (double) 5, (double) 3, (double) 0, (double) 9)); assertEquals(0.0, Doubles.max(-0.0, 0.0)); assertEquals(0.0, Doubles.max(0.0, -0.0)); assertEquals(GREATEST, Doubles.max(NUMBERS)); assertTrue(Double.isNaN(Doubles.max(VALUES))); }
public void testMax_noArgs() { try { Doubles.max(); fail(); } catch (IllegalArgumentException expected) { } }
@Override public boolean apply(@Nullable Scenario scenario) { final List<Double> loads = newArrayList(relative ? Metrics .measureRelativeLoad(scenario) : Metrics.measureLoad(scenario)); final int toAdd = desiredLoadList.size() - loads.size(); for (int j = 0; j < toAdd; j++) { loads.add(0d); } final double[] deviations = abs(subtract( Doubles.toArray(desiredLoadList), Doubles.toArray(loads))); final double mean = StatUtils.mean(deviations); final double max = Doubles.max(deviations); return max <= maxMax && mean <= maxMean; }
@Override public boolean apply(@Nullable Scenario scenario) { assert scenario != null; final List<Double> loads = newArrayList(relative ? Metrics .measureRelativeLoad(scenario) : Metrics.measureLoad(scenario)); final int toAdd = desiredLoadList.size() - loads.size(); for (int j = 0; j < toAdd; j++) { loads.add(0d); } final double[] deviations = abs(subtract( Doubles.toArray(desiredLoadList), Doubles.toArray(loads))); final double mean = StatUtils.mean(deviations); final double max = Doubles.max(deviations); return max <= maxMax && mean <= maxMean; }
public void setBounds( LatLonGeo center, DoubleUnaryOperator unitsToSu, double ewExtent_UNITS, double nsExtent_UNITS ) { double ewExtent_SU = unitsToSu.applyAsDouble( ewExtent_UNITS ); double nsExtent_SU = unitsToSu.applyAsDouble( nsExtent_UNITS ); LatLonGeo[] latlons = { center.displacedBy( 0.5*ewExtent_SU, Azimuth.fromNavDeg( -90 ) ), center.displacedBy( 0.5*ewExtent_SU, Azimuth.fromNavDeg( +90 ) ), center.displacedBy( 0.5*nsExtent_SU, Azimuth.fromNavDeg( 0 ) ), center.displacedBy( 0.5*nsExtent_SU, Azimuth.fromNavDeg( 180 ) ) }; double[] xs_SU = new double[ latlons.length ]; double[] ys_SU = new double[ latlons.length ]; for ( int i = 0; i < latlons.length; i++ ) { Vector2d xy_SU = proj.project( latlons[ i ] ); xs_SU[ i ] = xy_SU.getX( ); ys_SU[ i ] = xy_SU.getY( ); } this.axis.set( min( xs_SU ), max( xs_SU ), min( ys_SU ), max( ys_SU ) ); }
@Override public void operate( FlowProcess flowProcess, FunctionCall<Context<BaseRegressionFunction.ExpressionContext>> functionCall ) { TupleEntry arguments = functionCall.getArguments(); ExpressionEvaluator[] expressions = functionCall.getContext().payload.expressions; double[] results = functionCall.getContext().payload.results; for( int i = 0; i < expressions.length; i++ ) results[ i ] = expressions[ i ].calculate( arguments ); LOG.debug( "raw regression: {}", results ); for( int i = 0; i < expressions.length; i++ ) results[ i ] = getSpec().getLinkFunction().calculate( results[ i ] ); LOG.debug( "link regression: {}", results ); results = getSpec().getNormalization().normalize( results ); LOG.debug( "probabilities: {}", results ); double max = Doubles.max( results ); int index = Doubles.indexOf( results, max ); String category = expressions[ index ].getTargetCategory(); LOG.debug( "category: {}", category ); if( !getSpec().getModelSchema().isIncludePredictedCategories() ) { functionCall.getOutputCollector().add( functionCall.getContext().result( category ) ); return; } Tuple result = functionCall.getContext().tuple; result.set( 0, category ); for( int i = 0; i < results.length; i++ ) result.set( i + 1, results[ i ] ); functionCall.getOutputCollector().add( result ); } }