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

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

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

Median.evaluate介绍

暂无

代码示例

代码示例来源:origin: apache/hive

/**
 * Get median value for given statistics.
 * @param data collected datapoints.
 * @return median value.
 */
private static double median(@NotNull DescriptiveStatistics data) {
 return new Median().evaluate(data.getValues());
}

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

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

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * Calculates Transit center from median of coordinates of all transitStops if graph
 * has transit. If it doesn't it isn't calculated. (mean walue of min, max latitude and longitudes are used)
 *
 * Transit center is saved in center variable
 *
 * This speeds up calculation, but problem is that median needs to have all of latitudes/longitudes
 * in memory, this can become problematic in large installations. It works without a problem on New York State.
 */
public void calculateTransitCenter() {
  if (hasTransit) {
    TDoubleList latitudes = new TDoubleLinkedList();
    TDoubleList longitudes = new TDoubleLinkedList();
    Median median = new Median();
    getVertices().stream()
      .filter(v -> v instanceof TransitStop)
      .forEach(v -> {
        latitudes.add(v.getLat());
        longitudes.add(v.getLon());
      });
    median.setData(latitudes.toArray());
    double medianLatitude = median.evaluate();
    median = new Median();
    median.setData(longitudes.toArray());
    double medianLongitude = median.evaluate();
    this.center = new Coordinate(medianLongitude, medianLatitude);
  }
}

代码示例来源:origin: apache/metron

public MetaScores(List<Double> scores) {
 // A meta alert could be entirely alerts with no values.
 DoubleSummaryStatistics stats = scores
   .stream()
   .mapToDouble(a -> a)
   .summaryStatistics();
 metaScores.put("max", stats.getMax());
 metaScores.put("min", stats.getMin());
 metaScores.put("average", stats.getAverage());
 metaScores.put("count", stats.getCount());
 metaScores.put("sum", stats.getSum());
 // median isn't in the stats summary
 double[] arr = scores
   .stream()
   .mapToDouble(d -> d)
   .toArray();
 metaScores.put("median", new Median().evaluate(arr));
}

代码示例来源:origin: NemProject/nem.core

/**
 * Gets the median value of all elements in this vector.
 *
 * @return The median value of all elements in this vector.
 */
public double median() {
  final Median median = new Median();
  return median.evaluate(this.vector);
}

代码示例来源:origin: stackoverflow.com

import org.apache.commons.math3.*;
.....
......
........
//calculate median
public double getMedian(double[] values){
 Median median = new Median();
 double medianValue = median.evaluate(values);
 return medianValue;
}
.......

代码示例来源:origin: stackoverflow.com

import org.apache.commons.math3.*;
.....
......
........
//calculate median
public double getMedian(double[] values){
 Median median = new Median();
 double medianValue = median.evaluate(values);
 return medianValue;
}
.......

代码示例来源:origin: nemtech/nem2-sdk-java

/**
 * Gets the median value of all elements in this vector.
 *
 * @return The median value of all elements in this vector.
 */
public double median() {
  final Median median = new Median();
  return median.evaluate(this.vector);
}

代码示例来源:origin: stackoverflow.com

Median median = new Median();
median.evaluate(values);

代码示例来源:origin: broadgsa/gatk-protected

/**
   *
   * @param offsets a list of integers
   * @param median median of the list offsets.
   * @return median absolute deviation (median of the list of deviations from the median)
   */
  private double calculateMAD(final List<Integer> offsets, final double median) {
    // This code is concise but somehow leads to ClusteredReadPosition class being removed from ClassMap.
    // mapToDouble() seems to be the trigger
    // return new Median().evaluate(offsets.stream().mapToDouble(x -> Math.abs(x - median)).toArray());

    double[] medianAbsoluteDeviations = new double[offsets.size()];
    for (int i = 0; i < offsets.size(); i++){
      medianAbsoluteDeviations[i] = Math.abs(offsets.get(i) - median);
    }

    return new Median().evaluate(medianAbsoluteDeviations);
  }
}

代码示例来源:origin: io.github.msdk/msdk-featuredetection-chromatogrambuilder

@Nonnull
Double calculateMz() {
 if (mzValues.isEmpty())
  throw new MSDKRuntimeException("Cannot calculate the m/z value of an empty chromatogram");
 // Convert the m/z values to an array
 double mzDoubleValues[] = Doubles.toArray(mzValues);
 // Calculate the final m/z value as a median of all m/z values
 Median median = new Median();
 double medianValue = median.evaluate(mzDoubleValues);
 return medianValue;
}

代码示例来源:origin: io.github.msdk/msdk-featdet-chromatogrambuilder

@Nonnull
Double calculateMz() {
 if (mzValues.isEmpty())
  throw new MSDKRuntimeException("Cannot calculate the m/z value of an empty chromatogram");
 // Convert the m/z values to an array
 double mzDoubleValues[] = Doubles.toArray(mzValues);
 // Calculate the final m/z value as a median of all m/z values
 Median median = new Median();
 double medianValue = median.evaluate(mzDoubleValues);
 return medianValue;
}

代码示例来源:origin: io.github.msdk/msdk-chromatogrambuilder

@Nonnull
Double calculateMz() {
  if (mzValues.isEmpty())
    throw new MSDKRuntimeException(
        "Cannot calculate the m/z value of an empty chromatogram");
  // Convert the m/z values to an array
  double mzDoubleValues[] = Doubles.toArray(mzValues);
  // Calculate the final m/z value as a median of all m/z values
  Median median = new Median();
  double medianValue = median.evaluate(mzDoubleValues);
  return medianValue;
}

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

@Nonnull
Double calculateMz() {
 if (mzValues.isEmpty())
  throw new MSDKRuntimeException("Cannot calculate the m/z value of an empty chromatogram");
 // Convert the m/z values to an array
 double mzDoubleValues[] = Doubles.toArray(mzValues);
 // Calculate the final m/z value as a median of all m/z values
 Median median = new Median();
 double medianValue = median.evaluate(mzDoubleValues);
 return medianValue;
}

代码示例来源: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: zavtech/morpheus-core

public static void main(String[] args) {
  final double[] values = new java.util.Random().doubles(5000).toArray();
  final Percentile stat1 = new Percentile(0.5);
  final Median stat2 = new Median();
  for (double value : values) stat1.add(value);
  final double result1 = stat1.getValue();
  final double result2 = stat2.evaluate(values);
  if (result1 != result2) {
    throw new RuntimeException("Error: " + result1 + " != " + result2);
  }
}

代码示例来源:origin: broadgsa/gatk-protected

double leftMedian = median.evaluate(tumorLeftOffsetsDouble);
double rightMedian = median.evaluate(tumorRightOffsetsDouble);
double leftMAD = calculateMAD(tumorLeftOffsets, leftMedian);
double rightMAD = calculateMAD(tumorRightOffsets, rightMedian);

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

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

代码示例来源:origin: broadgsa/gatk

final double nonRefLikelihood = medianCalculator.evaluate(qualifiedAlleleLikelihoods, 0, numberOfQualifiedAlleleLikelihoods);

代码示例来源:origin: broadgsa/gatk-protected

qualifylingLikelihoods.add(originalLikelihoods[s][a][r]);
final double medianLikelihood = median.evaluate(qualifylingLikelihoods.stream().mapToDouble(d -> d).toArray());

相关文章