/** * Returns the mean of the (signed) differences between corresponding elements of the * input arrays -- i.e., sum(sample1[i] - sample2[i]) / sample1.length. * * @param sample1 the first array * @param sample2 the second array * @return mean of paired differences * @throws DimensionMismatchException if the arrays do not have the same * (positive) length. * @throws NoDataException if the sample arrays are empty. */ public static double meanDifference(final double[] sample1, final double[] sample2) throws DimensionMismatchException, NoDataException{ return sumDifference(sample1, sample2) / sample1.length; }
public static Double sumDifference(NumericColumn<?> column1, NumericColumn<?> column2) { return StatUtils.sumDifference(column1.asDoubleArray(), column2.asDoubleArray()); } }
/** * Returns the mean of the (signed) differences between corresponding elements of the * input arrays -- i.e., sum(sample1[i] - sample2[i]) / sample1.length. * * @param sample1 the first array * @param sample2 the second array * @return mean of paired differences * @throws DimensionMismatchException if the arrays do not have the same * (positive) length. * @throws NoDataException if the sample arrays are empty. */ public static double meanDifference(final double[] sample1, final double[] sample2) throws DimensionMismatchException, NoDataException{ return sumDifference(sample1, sample2) / sample1.length; }
/** * Returns the mean of the (signed) differences between corresponding elements of the * input arrays -- i.e., sum(sample1[i] - sample2[i]) / sample1.length. * * @param sample1 the first array * @param sample2 the second array * @return mean of paired differences * @throws DimensionMismatchException if the arrays do not have the same * (positive) length. * @throws NoDataException if the sample arrays are empty. */ public static double meanDifference(final double[] sample1, final double[] sample2) throws DimensionMismatchException, NoDataException{ return sumDifference(sample1, sample2) / sample1.length; }
@Override public Object doWork(Object first, Object second) throws IOException{ if(null == first){ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory))); } if(null == second){ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the second value",toExpression(constructingFactory))); } if(!(first instanceof List<?>)){ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the first value, expecting a list of numbers",toExpression(constructingFactory), first.getClass().getSimpleName())); } if(!(second instanceof List<?>)){ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the second value, expecting a list of numbers",toExpression(constructingFactory), first.getClass().getSimpleName())); } return StatUtils.sumDifference( ((List) first).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray(), ((List) second).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray() ); } }
public static Double sumDifference(NumericColumn<?> column1, NumericColumn<?> column2) { return StatUtils.sumDifference(column1.asDoubleArray(), column2.asDoubleArray()); } }
public static double sumDifference(FloatColumn column1, FloatColumn column2) { return StatUtils.sumDifference(column1.toDoubleArray(), column2.toDoubleArray()); } }