/** * Returns the weighted arithmetic mean of the entries in the input array. * <p> * Throws <code>MathIllegalArgumentException</code> if either array is null.</p> * <p> * See {@link Mean} for details on the computing algorithm. The two-pass algorithm * described above is used here, with weights applied in computing both the original * estimate and the correction factor.</p> * <p> * Throws <code>MathIllegalArgumentException</code> if any of the following are true: * <ul><li>the values array is null</li> * <li>the weights array is null</li> * <li>the weights array does not have the same length as the values array</li> * <li>the weights array contains one or more infinite values</li> * <li>the weights array contains one or more NaN values</li> * <li>the weights array contains negative values</li> * </ul></p> * * @param values the input array * @param weights the weights array * @return the mean of the values or Double.NaN if length = 0 * @throws MathIllegalArgumentException if the parameters are not valid * @since 2.1 */ public double evaluate(final double[] values, final double[] weights) throws MathIllegalArgumentException { return evaluate(values, weights, 0, values.length); }
/** * This method calculates {@link SemiVariance} for the entire array against the mean, using * the current value of the biasCorrection instance property. * * @param values the input array * @param direction the {@link Direction} of the semivariance * @return the SemiVariance * @throws MathIllegalArgumentException if values is null * */ public double evaluate(final double[] values, Direction direction) throws MathIllegalArgumentException { double m = (new Mean()).evaluate(values); return evaluate (values, m, direction, biasCorrected, 0, values.length); }
/** * <p>Returns the {@link SemiVariance} of the designated values against the mean, using * instance properties varianceDirection and biasCorrection.</p> * * <p>Returns <code>NaN</code> if the array is empty and throws * <code>IllegalArgumentException</code> if the array is null.</p> * * @param values the input array * @param start index of the first array element to include * @param length the number of elements to include * @return the SemiVariance * @throws MathIllegalArgumentException if the parameters are not valid * */ @Override public double evaluate(final double[] values, final int start, final int length) throws MathIllegalArgumentException { double m = (new Mean()).evaluate(values, start, length); return evaluate(values, m, varianceDirection, biasCorrected, 0, values.length); }
public Stat(double[] values) { mean = new Mean().evaluate(values); standardDeviation = new StandardDeviation().evaluate(values); median = new Median().evaluate(values); }
Mean mean = new Mean(); double m = mean.evaluate(values, begin, length);
} else if (length > 1) { Mean mean = new Mean(); double m = mean.evaluate(values, begin, length); var = evaluate(values, m, begin, length);
} else if (length > 1) { Mean mean = new Mean(); double m = mean.evaluate(values, weights, begin, length); var = evaluate(values, weights, m, begin, length);
public double getMean() { Mean mean = new Mean(); return mean.evaluate(this.data, 0, this.data.length); }
/** * This method calculates {@link SemiVariance} for the entire array against the mean, using * the current value of the biasCorrection instance property. * * @param values the input array * @param direction the {@link Direction} of the semivariance * @return the SemiVariance * @throws MathIllegalArgumentException if values is null * */ public double evaluate(final double[] values, Direction direction) throws MathIllegalArgumentException { double m = (new Mean()).evaluate(values); return evaluate (values, m, direction, biasCorrected, 0, values.length); }
private static double mean(List<Long> data) { double[] asDouble = new double[data.size()]; int i = 0; for (Long l : data) { asDouble[i++] = (double) l; } return new Mean().evaluate(asDouble); }
private void print(int indent, String header, TimingResults timings) { String msg = String.format("" + "Mean: % 7.2f ms\n" + "Median: % 7.2f ms\n" + "StdDev: % 7.2f ms", timings.mean.evaluate() * 1000.0, timings.median.evaluate() * 1000.0, timings.stddev.evaluate() * 1000.0); System.out.println(StringTools.indent(header + ":", StringTools.strrep(' ', indent))); System.out.println(StringTools.indent(msg, StringTools.strrep(' ', indent + 2))); }
public double getWeightedF1score() { double[] f1Scores = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { f1Scores[index] = getF1score(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(f1Scores, weights); }
public double getWeightedF1score() { double[] f1Scores = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { f1Scores[index] = getF1score(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(f1Scores, weights); }
public double getWeightedPrecision() { double[] precisions = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { precisions[index] = getPrecision(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(precisions, weights); }
public double getWeightedPrecision() { double[] precisions = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { precisions[index] = getPrecision(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(precisions, weights); }
public double getWeightedRecall() { double[] recalls = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { recalls[index] = getRecall(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(recalls, weights); }
public double getWeightedRecall() { double[] recalls = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { recalls[index] = getRecall(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(recalls, weights); }
private ExchangeAggregateCurrencyRate createExchangeAggregateCurrencyRate(CurrencyType currencyType, List<ExchangeCurrencyRate> currencyRates) { Mean mean = new Mean(); double[] rateDoubles = currencyRates.stream().mapToDouble((value) -> value.getExchangeRate().doubleValue()).toArray(); double meanValue = mean.evaluate(rateDoubles, 0, rateDoubles.length); return new ExchangeAggregateCurrencyRate(currencyType, new BigDecimal(meanValue)); } }
public Stat(double[] values) { mean = new Mean().evaluate(values); standardDeviation = new StandardDeviation().evaluate(values); median = new Median().evaluate(values); }