当前位置: 首页>>代码示例>>Java>>正文


Java DoubleMath.mean方法代码示例

本文整理汇总了Java中com.google.common.math.DoubleMath.mean方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMath.mean方法的具体用法?Java DoubleMath.mean怎么用?Java DoubleMath.mean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.math.DoubleMath的用法示例。


在下文中一共展示了DoubleMath.mean方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: finish

import com.google.common.math.DoubleMath; //导入方法依赖的package包/类
@Override
public void finish() throws IOException {
  final ImmutableMap<Symbol, Double> scores = this.scores.build();
  final ImmutableMap<Symbol, Integer> falsePositives = this.falsePositives.build();
  final ImmutableMap<Symbol, Integer> truePositives = this.truePositives.build();
  final ImmutableMap<Symbol, Integer> falseNegatives = this.falseNegatives.build();

  // see guidelines section 7.3.1.1.3 for aggregating rules:
  outputDir.mkdirs();
  final double meanScore = scores.isEmpty()?Double.NaN:DoubleMath.mean(scores.values());
  Files.asCharSink(new File(outputDir, "linearScore.txt"), Charsets.UTF_8)
      .write(Double.toString(meanScore));

  for (final Symbol queryId : scores.keySet()) {
    final File queryDir = new File(outputDir, queryId.asString());
    queryDir.mkdirs();
    final File queryScoreFile = new File(queryDir, "score.txt");
    // avoid dividing by zero
    final double normalizer = Math.max(truePositives.get(queryId) + falseNegatives.get(queryId), 1);
    // see guidelines referenced above
    // pretends that the corpus is a single document
    Files.asCharSink(queryScoreFile, Charsets.UTF_8).write(String
        .format(SCORE_PATTERN, truePositives.get(queryId), falsePositives.get(queryId),
            falseNegatives.get(queryId), 100 * scores.get(queryId) / normalizer));
  }
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:27,代码来源:CorpusScorer.java

示例2: assertDistributionStatsMatchCalcFromSample

import com.google.common.math.DoubleMath; //导入方法依赖的package包/类
private static void assertDistributionStatsMatchCalcFromSample(Distribution distribution,
    double[] samples) {
  double wantedMean = DoubleMath.mean(samples);
  double wantedSumSquareDeviations = 0.0;
  for (int i = 0; i < samples.length; i++) {
    wantedSumSquareDeviations += Math.pow((wantedMean - samples[i]), 2);
  }
  assertEquals(wantedSumSquareDeviations, distribution.getSumOfSquaredDeviation(), TOLERANCE);
  assertEquals(samples.length, distribution.getCount());
  assertEquals(wantedMean, distribution.getMean(), 1e-5);
  assertEquals(Ordering.<Double>natural().max(Doubles.asList(samples)).doubleValue(),
      distribution.getMaximum(), TOLERANCE);
  assertEquals(Ordering.<Double>natural().min(Doubles.asList(samples)).doubleValue(),
      distribution.getMinimum(), TOLERANCE);
}
 
开发者ID:cloudendpoints,项目名称:endpoints-management-java,代码行数:16,代码来源:DistributionsTest.java

示例3: getR2

import com.google.common.math.DoubleMath; //导入方法依赖的package包/类
public static Double getR2(double sse, List<Double> targetValues) {
	if (targetValues.size() < 2) {
		return null;
	}

	double targetMean = DoubleMath.mean(targetValues);
	double targetTotalSumOfSquares = targetValues.stream().mapToDouble(v -> Math.pow(v - targetMean, 2.0)).sum();
	double rSquared = 1 - sse / targetTotalSumOfSquares;

	return Math.max(rSquared, 0.0);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:12,代码来源:MathUtils.java

示例4: evaluateAccuracy

import com.google.common.math.DoubleMath; //导入方法依赖的package包/类
public static String evaluateAccuracy(long period) {

        // CACHE??

        final List<BloodTest> bloodTests = latestForGraph(1000, JoH.tsl() - period, JoH.tsl() - AddCalibration.estimatedInterstitialLagSeconds);
        final List<Double> difference = new ArrayList<>();
        final List<Double> plugin_difference = new ArrayList<>();
        if ((bloodTests == null) || (bloodTests.size() == 0)) return null;

        final boolean show_plugin = true;
        final CalibrationAbstract plugin = (show_plugin) ? PluggableCalibration.getCalibrationPluginFromPreferences() : null;


        for (BloodTest bt : bloodTests) {
            final BgReading bgReading = BgReading.getForPreciseTimestamp(bt.timestamp + (AddCalibration.estimatedInterstitialLagSeconds * 1000), BgGraphBuilder.DEXCOM_PERIOD);

            if (bgReading != null) {
                final Calibration calibration = bgReading.calibration;
                if (calibration == null) {
                    Log.d(TAG,"Calibration for bgReading is null! @ "+JoH.dateTimeText(bgReading.timestamp));
                    continue;
                }
                final double diff = Math.abs(bgReading.calculated_value - bt.mgdl);
                difference.add(diff);
                if (d) {
                    Log.d(TAG, "Evaluate Accuracy: difference: " + JoH.qs(diff));
                }
                final CalibrationAbstract.CalibrationData cd = (plugin != null) ? plugin.getCalibrationData(bgReading.timestamp) : null;
                if ((plugin != null) && (cd != null)) {
                    final double plugin_diff = Math.abs(bt.mgdl - plugin.getGlucoseFromBgReading(bgReading, cd));
                    plugin_difference.add(plugin_diff);
                    if (d)
                        Log.d(TAG, "Evaluate Plugin Accuracy: " + BgGraphBuilder.unitized_string_with_units_static(bt.mgdl) + " @ " + JoH.dateTimeText(bt.timestamp) + "  difference: " + JoH.qs(plugin_diff) + "/" + JoH.qs(plugin_diff * Constants.MGDL_TO_MMOLL, 2) + " calibration: " + JoH.qs(cd.slope, 2) + " " + JoH.qs(cd.intercept, 2));
                }
            }
        }

        if (difference.size() == 0) return null;
        double avg = DoubleMath.mean(difference);
        Log.d(TAG, "Average accuracy: " + accuracyAsString(avg) + "  (" + JoH.qs(avg, 5) + ")");

        if (plugin_difference.size() > 0) {
            double plugin_avg = DoubleMath.mean(plugin_difference);
            Log.d(TAG, "Plugin Average accuracy: " + accuracyAsString(plugin_avg) + "  (" + JoH.qs(plugin_avg, 5) + ")");
            return accuracyAsString(plugin_avg) + " / " + accuracyAsString(avg);
        }
        return accuracyAsString(avg);
    }
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:49,代码来源:BloodTest.java

示例5: average_from_list_of_numbers_with_google_guava

import com.google.common.math.DoubleMath; //导入方法依赖的package包/类
@Test
public void average_from_list_of_numbers_with_google_guava () {

	double average = DoubleMath.mean(NUMBERS_FOR_AVERAGE);
	assertEquals(10, average, 0);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:7,代码来源:AverageFromList.java

示例6: calculate_average_of_array_guava

import com.google.common.math.DoubleMath; //导入方法依赖的package包/类
@Test
public void calculate_average_of_array_guava () {
	
	double average = DoubleMath.mean(NUMBERS);
	
	assertEquals(35.36363636363637, average, 0);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:8,代码来源:AverageFromArray.java

示例7: getConcentration

import com.google.common.math.DoubleMath; //导入方法依赖的package包/类
/**
 * Returns the concentration level based on the internal values
 * @return
 */
public synchronized float getConcentration(){
    return (float) DoubleMath.mean(this.mConcentrationBuffer);
}
 
开发者ID:neuralcubes,项目名称:musephero,代码行数:8,代码来源:ConcetrationManager.java

示例8: getTestScoreAverages

import com.google.common.math.DoubleMath; //导入方法依赖的package包/类
/**
 * Method should calculate the average scores 
 * 
 * @param grades
 * @return
 */
static double getTestScoreAverages (List<? extends Number> grades) {
	return DoubleMath.mean(grades);
}
 
开发者ID:leveluplunch,项目名称:levelup-java-exercises,代码行数:10,代码来源:GradePapers.java


注:本文中的com.google.common.math.DoubleMath.mean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。