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

x33g5p2x  于2022-01-26 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(147)

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

Percentile.setData介绍

暂无

代码示例

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

/**
 * Copy constructor, creates a new {@code Percentile} identical
 * to the {@code original}
 *
 * @param original the {@code Percentile} instance to copy
 * @throws NullArgumentException if original is null
 */
public Percentile(final Percentile original) throws NullArgumentException {
  MathUtils.checkNotNull(original);
  estimationType   = original.getEstimationType();
  nanStrategy      = original.getNaNStrategy();
  kthSelector      = original.getKthSelector();
  setData(original.getDataRef());
  if (original.cachedPivots != null) {
    System.arraycopy(original.cachedPivots, 0, cachedPivots, 0, original.cachedPivots.length);
  }
  setQuantile(original.quantile);
}

代码示例来源:origin: linkedin/cruise-control

_percentile.setData(historyMetricValues.doubleArray());

代码示例来源:origin: jpmml/jpmml-evaluator

@Override
  public double doublePercentile(int percentile){

    if(this.size == 0){
      throw new IllegalStateException();
    }

    double[] data = new double[this.size];

    System.arraycopy(this.values, 0, data, 0, data.length);

    Arrays.sort(data);

    Percentile statistic = new Percentile();
    statistic.setData(data);

    return statistic.evaluate(percentile);
  }
}

代码示例来源:origin: stanford-futuredata/macrobase

curDimensionValues[i] = metrics.get(i)[j];
p.setData(curDimensionValues);
bounds[j][0] = p.evaluate(trimPct);
bounds[j][1] = p.evaluate(100 - trimPct);

代码示例来源:origin: org.apache.solr/solr-solrj

@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",toExpression(constructingFactory), first.getClass().getSimpleName()));
 }
 if((second instanceof Number)) {
  Percentile percentile = new Percentile();
  percentile.setData(((List<?>) first).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray());
  return percentile.evaluate(((Number) second).doubleValue());
 } else if(second instanceof List){
  Percentile percentile = new Percentile();
  percentile.setData(((List<?>) first).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray());
  List<Number> values = (List<Number>) second;
  List<Number> percentiles = new ArrayList();
  for(Number value : values) {
   percentiles.add(percentile.evaluate(value.doubleValue()));
  }
  return percentiles;
 } else {
  throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the second value, expecting a number or a numeric array",toExpression(constructingFactory), first.getClass().getSimpleName()));
 }
}

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

/**
 * @return an array of values to split the numeric feature's values on when
 *  building candidate splits. When input size is <= MAX_NUMERIC_SPLITS + 1, it will
 *  return the averages between success values as split points. When larger, it will
 *  return MAX_NUMERIC_SPLITS approximate percentiles through the data.
 */
private static double[] chooseNumericSplitPoints(double[] values) {
 if (values.length <= 1) {
  return values;
 }
 if (values.length <= MAX_NUMERIC_SPLITS + 1) {
  double[] splitPoints = new double[values.length - 1];
  for (int i = 1; i < values.length; i++) {
   splitPoints[i-1] = (values[i] + values[i-1]) / 2.0;
  }
  return splitPoints;
 }
 Percentile distribution = new Percentile();
 distribution.setData(values);
 double[] percentiles = new double[MAX_NUMERIC_SPLITS];
 for (int i = 0 ; i < percentiles.length; i++) {
  double p = 100.0 * ((i + 1.0) / (MAX_NUMERIC_SPLITS + 1.0));
  percentiles[i] = distribution.evaluate(p);
 }
 return percentiles;
}

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

/**
 * @return an array of values to split the numeric feature's values on when
 *  building candidate splits. When input size is <= MAX_NUMERIC_SPLITS + 1, it will
 *  return the averages between success values as split points. When larger, it will
 *  return MAX_NUMERIC_SPLITS approximate percentiles through the data.
 */
private static double[] chooseNumericSplitPoints(double[] values) {
 if (values.length <= 1) {
  return values;
 }
 if (values.length <= MAX_NUMERIC_SPLITS + 1) {
  double[] splitPoints = new double[values.length - 1];
  for (int i = 1; i < values.length; i++) {
   splitPoints[i-1] = (values[i] + values[i-1]) / 2.0;
  }
  return splitPoints;
 }
 Percentile distribution = new Percentile();
 distribution.setData(values);
 double[] percentiles = new double[MAX_NUMERIC_SPLITS];
 for (int i = 0 ; i < percentiles.length; i++) {
  double p = 100.0 * ((i + 1.0) / (MAX_NUMERIC_SPLITS + 1.0));
  percentiles[i] = distribution.evaluate(p);
 }
 return percentiles;
}

代码示例来源:origin: stanford-futuredata/macrobase

double[] curBoundaries = new double[k];
Percentile pCalc = new Percentile();
pCalc.setData(colValues);
for (int i = 0; i < k; i++) {
  curBoundaries[i] = pCalc.evaluate(boundaryPercentiles[i]);

代码示例来源:origin: stanford-futuredata/macrobase

@Override
public void consume(List<Datum> records) {
  List<DatumWithNorm> toClassify = new ArrayList<>();
  double[] scores = new double[records.size()];
  for(int i = 0; i < records.size(); i++) {
    Datum d = records.get(i);
    DatumWithNorm dwn = new DatumWithNorm(d);
    toClassify.add(dwn);
    scores[i] = dwn.getNorm();
  }
  Percentile pCalc = new Percentile().withNaNStrategy(NaNStrategy.MAXIMAL);
  pCalc.setData(scores);
  double cutoff = pCalc.evaluate(scores, targetPercentile * 100);
  log.debug("{} Percentile Cutoff: {}", targetPercentile, cutoff);
  log.debug("Median: {}", pCalc.evaluate(50));
  log.debug("Max: {}", pCalc.evaluate(100));
  for(DatumWithNorm dwn : toClassify) {
    results.add(new OutlierClassificationResult(dwn.getDatum(),
                          dwn.getNorm() >= cutoff || dwn.getNorm().isInfinite()));
  }
}

代码示例来源:origin: FutureCitiesCatapult/TomboloDigitalConnector

percentile.setData(values);
log.info("Normalising percentiles of {} over {} subjects", singleValueField.getLabel(), percentileSubjects.size());
log.info("Min value: {}", StatUtils.min(values));

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

/**
 * Copy constructor, creates a new {@code Percentile} identical
 * to the {@code original}
 *
 * @param original the {@code Percentile} instance to copy
 * @throws NullArgumentException if original is null
 */
public Percentile(final Percentile original) throws NullArgumentException {
  MathUtils.checkNotNull(original);
  estimationType   = original.getEstimationType();
  nanStrategy      = original.getNaNStrategy();
  kthSelector      = original.getKthSelector();
  setData(original.getDataRef());
  if (original.cachedPivots != null) {
    System.arraycopy(original.cachedPivots, 0, cachedPivots, 0, original.cachedPivots.length);
  }
  setQuantile(original.quantile);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Copy constructor, creates a new {@code Percentile} identical
 * to the {@code original}
 *
 * @param original the {@code Percentile} instance to copy
 * @throws NullArgumentException if original is null
 */
public Percentile(final Percentile original) throws NullArgumentException {
  MathUtils.checkNotNull(original);
  estimationType   = original.getEstimationType();
  nanStrategy      = original.getNaNStrategy();
  kthSelector      = original.getKthSelector();
  setData(original.getDataRef());
  if (original.cachedPivots != null) {
    System.arraycopy(original.cachedPivots, 0, cachedPivots, 0, original.cachedPivots.length);
  }
  setQuantile(original.quantile);
}

代码示例来源:origin: kiegroup/droolsjbpm-integration

@Test
  public void testRandomGenerator() {
    
    Percentile p = new Percentile(35);
    p.setData(new double[]{35});
    System.out.println(p.evaluate(5));
    
    Map<String, Object> data = new HashMap<String, Object>();
    data.put(SimulationConstants.DISTRIBUTION_TYPE, "random");
    data.put(SimulationConstants.MIN, 500L);
    data.put(SimulationConstants.MAX, 40000L);
    
    TimeGenerator generator = TimeGeneratorFactory.newTimeGenerator(data);
    assertNotNull(generator);
    assertTrue(generator instanceof RandomTimeGenerator);
    
    System.out.println(generator.generateTime());
    System.out.println(generator.generateTime());
    System.out.println(generator.generateTime());
    System.out.println(generator.generateTime());
  }
}

代码示例来源:origin: org.drools/jbpm-simulation

@Test
  public void testRandomGenerator() {
    
    Percentile p = new Percentile(35);
    p.setData(new double[]{35});
    System.out.println(p.evaluate(5));
    
    Map<String, Object> data = new HashMap<String, Object>();
    data.put(SimulationConstants.DISTRIBUTION_TYPE, "random");
    data.put(SimulationConstants.MIN, 500L);
    data.put(SimulationConstants.MAX, 40000L);
    
    TimeGenerator generator = TimeGeneratorFactory.newTimeGenerator(data);
    assertNotNull(generator);
    assertTrue(generator instanceof RandomTimeGenerator);
    
    System.out.println(generator.generateTime());
    System.out.println(generator.generateTime());
    System.out.println(generator.generateTime());
    System.out.println(generator.generateTime());
  }
}

代码示例来源:origin: FoundationDB/fdb-record-layer

final double max = dtimes[dtimes.length - 1];
final Percentile percentile = new Percentile();
percentile.setData(dtimes);
final double p50 = percentile.evaluate(50);
final double p90 = percentile.evaluate(90);

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

percentile.setData(inputArray);
result.setValue(percentile.evaluate(val));

代码示例来源:origin: com.linkedin.cruisecontrol/cruise-control-core

_percentile.setData(historyMetricValues.doubleArray());

相关文章