org.apache.commons.math3.stat.descriptive.moment.Mean.evaluate()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(222)

本文整理了Java中org.apache.commons.math3.stat.descriptive.moment.Mean.evaluate()方法的一些代码示例,展示了Mean.evaluate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mean.evaluate()方法的具体详情如下:
包路径:org.apache.commons.math3.stat.descriptive.moment.Mean
类名称:Mean
方法名:evaluate

Mean.evaluate介绍

[英]Returns the arithmetic mean of the entries in the specified portion of the input array, or Double.NaN if the designated subarray is empty.

Throws IllegalArgumentException if the array is null.

See Mean for details on the computing algorithm.
[中]返回输入数组中指定部分的项的算术平均值,如果指定的子数组为空,则返回Double.NaN
如果数组为空,则抛出IllegalArgumentException
有关计算算法的详细信息,请参见Mean。

代码示例

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * 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);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * 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);
}

代码示例来源:origin: org.apache.commons/commons-math3

LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, length, 2);
} else {
  double xMean = mean.evaluate(xArray);
  double yMean = mean.evaluate(yArray);
  for (int i = 0; i < length; i++) {
    double xDev = xArray[i] - xMean;

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * <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);
 }

代码示例来源:origin: prestodb/presto

public Stat(double[] values)
{
  mean = new Mean().evaluate(values);
  standardDeviation = new StandardDeviation().evaluate(values);
  median = new Median().evaluate(values);
}

代码示例来源:origin: org.apache.commons/commons-math3

Mean mean = new Mean();
double m = mean.evaluate(values, begin, length);

代码示例来源:origin: org.apache.commons/commons-math3

} else if (length > 1) {
  Mean mean = new Mean();
  double m = mean.evaluate(values, begin, length);
  var = evaluate(values, m, begin, length);

代码示例来源:origin: org.apache.commons/commons-math3

} else if (length > 1) {
  Mean mean = new Mean();
  double m = mean.evaluate(values, weights, begin, length);
  var = evaluate(values, weights, m, begin, length);

代码示例来源:origin: ICOnator/ICOnator-backend

public double getMean() {
  Mean mean = new Mean();
  return mean.evaluate(this.data, 0, this.data.length);
}

代码示例来源:origin: geogebra/geogebra

/**
 * 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);
}

代码示例来源:origin: dremio/dremio-oss

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);
}

代码示例来源:origin: sweble/sweble-wikitext

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)));
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

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);
}

代码示例来源:origin: org.apache.mahout/mahout-mr

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);
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

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);
}

代码示例来源:origin: org.apache.mahout/mahout-mr

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);
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

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);
}

代码示例来源:origin: org.apache.mahout/mahout-mr

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);
}

代码示例来源:origin: ICOnator/ICOnator-backend

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));
  }
}

代码示例来源:origin: prestosql/presto

public Stat(double[] values)
{
  mean = new Mean().evaluate(values);
  standardDeviation = new StandardDeviation().evaluate(values);
  median = new Median().evaluate(values);
}

相关文章