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


Java DescriptiveStatistics类代码示例

本文整理汇总了Java中org.apache.commons.math3.stat.descriptive.DescriptiveStatistics的典型用法代码示例。如果您正苦于以下问题:Java DescriptiveStatistics类的具体用法?Java DescriptiveStatistics怎么用?Java DescriptiveStatistics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DescriptiveStatistics类属于org.apache.commons.math3.stat.descriptive包,在下文中一共展示了DescriptiveStatistics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testStatisticalTests

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/**
 *Generates random double array, applies t-test to it
 * @throws Exception
 */
@Test
public void testStatisticalTests() throws Exception {
    double[] x = new double[1000];
    for (int i = 0; i < x.length; i++) {
        x[i] = Math.random()*100+1;
    }
    System.out.println("Testing array: " + Arrays.toString(x));
    //One-sample t-test
    double mu = new DescriptiveStatistics(x).getMean();
    System.out.println("Mean: " + mu);
    System.out.println("t-statistic for true mean (50): " + TestUtils.t(50, x));
    System.out.println("p-value for true mean (50): " + TestUtils.tTest(50,x));
    System.out.println("t-statistic for false mean (75): " + TestUtils.t(75,x));
    System.out.println("p-value for false mean (75): " + TestUtils.tTest(75,x));


}
 
开发者ID:jmueller95,项目名称:CORNETTO,代码行数:22,代码来源:ApacheMathTest.java

示例2: phi

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/**
 * Compute phi for the specified node id.
 * @param nodeId node id
 * @return phi value
 */
public double phi(NodeId nodeId) {
    checkNotNull(nodeId, "NodeId must not be null");
    if (!states.containsKey(nodeId)) {
        return bootstrapPhiValue;
    }
    History nodeState = states.get(nodeId);
    synchronized (nodeState) {
        long latestHeartbeat = nodeState.latestHeartbeatTime();
        DescriptiveStatistics samples = nodeState.samples();
        if (latestHeartbeat == -1 || samples.getN() < minSamples) {
            return 0.0;
        }
        return computePhi(samples, latestHeartbeat, System.currentTimeMillis());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:PhiAccrualFailureDetector.java

示例3: convertDescriptiveStatisticsMap

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
public static Map<String, List<DescriptiveStatistics>> convertDescriptiveStatisticsMap(
    Map<TopicPartition, DescriptiveStatistics> tpsMap) {
  Map<String, List<DescriptiveStatistics>> result = new TreeMap<>();
  for (Map.Entry<TopicPartition, DescriptiveStatistics> entry : tpsMap.entrySet()) {
    String topicName = entry.getKey().topic();
    int partitionId = entry.getKey().partition();
    if (!result.containsKey(topicName)) {
      result.put(topicName, new ArrayList<>());
    }
    List<DescriptiveStatistics> partitionArray = result.get(topicName);
    while (partitionArray.size() < partitionId + 1) {
      partitionArray.add(null);
    }
    partitionArray.set(partitionId, entry.getValue());
  }
  return result;
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:18,代码来源:DoctorKafkaServletUtil.java

示例4: getValue

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Override
public Map<String, HashMap<String, Double>> getValue() {
	while (true) {
		try {
			Map<String, HashMap<String, Double>> ret = new HashMap<>();
			for (Map.Entry<LatencySourceDescriptor, DescriptiveStatistics> source : latencyStats.entrySet()) {
				HashMap<String, Double> sourceStatistics = new HashMap<>(6);
				sourceStatistics.put("max", source.getValue().getMax());
				sourceStatistics.put("mean", source.getValue().getMean());
				sourceStatistics.put("min", source.getValue().getMin());
				sourceStatistics.put("p50", source.getValue().getPercentile(50));
				sourceStatistics.put("p95", source.getValue().getPercentile(95));
				sourceStatistics.put("p99", source.getValue().getPercentile(99));
				ret.put(source.getKey().toString(), sourceStatistics);
			}
			return ret;
			// Concurrent access onto the "latencyStats" map could cause
			// ConcurrentModificationExceptions. To avoid unnecessary blocking
			// of the reportLatency() method, we retry this operation until
			// it succeeds.
		} catch (ConcurrentModificationException ignore) {
			LOG.debug("Unable to report latency statistics", ignore);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:AbstractStreamOperator.java

示例5: setUp

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Before
public void setUp()
{
    results.clear();

    Arrays.stream(Metric.values()).forEach(m -> results.put(m, new DescriptiveStatistics(new Random().doubles(10, 0, 100).toArray())));

    Random random = new Random();

    when(evaluationMock.precision(anyInt())).thenReturn(random.nextDouble());
    when(evaluationMock.recall(anyInt())).thenReturn(random.nextDouble());
    when(evaluationMock.areaUnderPRC(anyInt())).thenReturn(random.nextDouble());
    when(evaluationMock.areaUnderROC(anyInt())).thenReturn(random.nextDouble());

    when(methodEvaluationMock.getEvaluation()).thenReturn(evaluationMock);
    when(methodEvaluationMock.getTrainStart()).thenReturn(System.currentTimeMillis() - 1000);
    when(methodEvaluationMock.getTrainEnd()).thenReturn(System.currentTimeMillis() - 750);
    when(methodEvaluationMock.getTestStart()).thenReturn(System.currentTimeMillis() - 500);
    when(methodEvaluationMock.getTestEnd()).thenReturn(System.currentTimeMillis() - 250);
}
 
开发者ID:marcelovca90,项目名称:anti-spam-weka-gui,代码行数:21,代码来源:ExperimentHelperTest.java

示例6: getChart

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
public final PairList<String, Map<Number, Number>> getChart(final CharSequence label) {
	final Map<Number, DescriptiveStatistics> points = new HashMap<>();
	for (int i = 0; i < arrays[0].length; ++i) {
		final double key = arrays[1][i];
		if (!points.containsKey(key)) {
			points.put(key, new DescriptiveStatistics());
		}
		points.get(key).addValue(arrays[0][i]);
	}
	final Map<Number, Number> average = new HashMap<>();
	final Map<Number, Number> median = new HashMap<>();
	for (final Entry<Number, DescriptiveStatistics> entry : points.entrySet()) {
		average.put(entry.getKey(), entry.getValue().getMean());
		median.put(entry.getKey(), entry.getValue().getPercentile(50));
	}
	final PairList<String, Map<Number, Number>> list = new PairList<>();
	list.add("Average " + label, average);
	list.add("Median " + label, median);
	return list;
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:21,代码来源:Correlation.java

示例7: acrossLabels

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Override
public final DescriptiveStatistics acrossLabels(
		final List<? extends Predictions<? extends E[], ? extends Collection<? extends P>>>[] predictions) {
	final DescriptiveStatistics stats = new DescriptiveStatistics();
	for (final List<? extends Predictions<? extends E[], ? extends Collection<? extends P>>> predz : Check
			.size(predictions, 1, 9999999)) {
		for (final Predictions<? extends E[], ? extends Collection<? extends P>> preds : predz) {
			for (final double val : label(preds.getPredictions(),
					(E[][]) preds.getExpected(),
					preds.getWeights(),
					preds.getSamples(),
					preds.getLabelIndex()).getValues()) {
				stats.addValue(val);
			}
		}
	}
	Check.num(stats.getN(), 1, 999999999);
	return stats;
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:20,代码来源:AbstractIRFunction.java

示例8: label

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Override
public DescriptiveStatistics label(final Serializable[] preds, final Object[] expected, final double[] weights,
		final ISamples<?, ?> samples, final int labelIndex) {
	int count = 0;
	int correct = 0;
	for (int i = 0; i < preds.length; ++i) {
		final double[] predAndAct = toDouble(preds[i], expected[i]);
		if (predAndAct[0] >= thresholdTrue) {
			++count;
			if (predAndAct[1] >= thresholdTrue) {
				++correct;
			}
		}
	}
	return new DescriptiveStatistics(new double[] { correct == 0 ? 0 : correct * 1.0 / count });
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:17,代码来源:Accuracy.java

示例9: acrossLabels

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Override
public DescriptiveStatistics acrossLabels(
		final List<? extends Predictions<? extends Number, ? extends Number>>[] predictions) {
	final DescriptiveStatistics stats = new DescriptiveStatistics();
	for (final List<? extends Predictions<? extends Number, ? extends Number>> predz : predictions) {
		for (final Predictions<? extends Number, ? extends Number> preds : predz) {
			final Number[] pred = preds.getPredictions();
			final Number[] exp = preds.getExpected();
			final int labelIndex = preds.getLabelIndex();
			for (int i = 0; i < pred.length; ++i) {
				if (exp[i] != null) {
					stats.addValue(instance(pred[i], exp[i], preds.getSample(i), labelIndex));
				}
			}
		}
	}
	return stats;
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:19,代码来源:MeanAbsoluteError.java

示例10: acrossLabels

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Override
public final DescriptiveStatistics acrossLabels(
		final List<? extends Predictions<? extends E, ? extends T>>[] predictions) {
	final DescriptiveStatistics stats = new DescriptiveStatistics();
	for (final List<? extends Predictions<? extends E, ? extends T>> predz : predictions) {
		for (final Predictions<? extends E, ? extends T> preds : predz) {
			for (final double val : label(preds.getPredictions(),
					preds.getExpected(),
					preds.getWeights(),
					preds.getSamples(),
					preds.getLabelIndex()).getValues()) {
				stats.addValue(val);
			}
		}
	}
	return stats;
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:18,代码来源:AbstractIndependentLabelsObjectiveFunction.java

示例11: compute

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Override
protected void compute() {
	final Split best = findBestSplit();
	// TODO: Do crossval here to reject split, if necessary
	if (best == null || best.getImprovement() < 0.00000000001) {
		return;
	}
	final DescriptiveStatistics[] nodeStats = nodeStats(best);
	final IStats statsNaN = best.getStatsNaN();
	final TreeNode[] children = new TreeNode[statsNaN.getN() >= context.minObs ? 3 : 2];
	children[0] = new TreeNode(prediction(nodeStats[0]), best.getStatsL());
	children[1] = new TreeNode(prediction(nodeStats[1]), best.getStatsR());
	if (children.length == 3) {
		children[2] = new TreeNode(prediction(nodeStats[2]), statsNaN);
	}
	final boolean[][] split = parent.split(best, children, context.orderedInstances, subset);
	if (depth < context.maxDepth) {
		for (int i = 0; i < children.length; ++i) {
			if (split[i].length >= context.minObs * 2) {
				new GrowJob(children[i], context, split[i], depth + 1, nodePrediction, splitCriterionFactory,
						statisticsFactory, parallelize).compute();
			}
		}
	}
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:26,代码来源:GrowJob.java

示例12: isSignificant

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
public boolean isSignificant(double singletonKL[],double p){
	DescriptiveStatistics ds=new DescriptiveStatistics((double[])singletonKL);
	double mean=ds.getMean();
	double std=ds.getStandardDeviation();
	double z=(Math.log(contextShiftingScore)-mean)/std;
	//double pValue1;
	
	// Compute z value of the scores based on the null distribution of scores of kmers computed from aptamers with small counts
	if (z>0.0)
		pvalue = computePValue(z);
	else 
		pvalue=1.0;

	if (pvalue<=p)
		return true;
	else
		return false;
}
 
开发者ID:drivenbyentropy,项目名称:aptasuite,代码行数:19,代码来源:KContextTrace.java

示例13: statistics

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
public ReflexValue statistics(List<ReflexValue> params) {
    if (params.size() != 1) {
        throw new ReflexException(-1, "statistics needs one list parameter");
    }
    if (!params.get(0).isList()) {
        throw new ReflexException(-1, "statistics needs one list parameter");
    }
    DescriptiveStatistics stats = new DescriptiveStatistics();
    List<ReflexValue> values = params.get(0).asList();
    for (ReflexValue v : values) {
        stats.addValue(v.asDouble());
    }
    Map<String, ReflexValue> ret = new HashMap<String, ReflexValue>();
    ret.put("mean", new ReflexValue(stats.getMean()));
    ret.put("std", new ReflexValue(stats.getStandardDeviation()));
    ret.put("median", new ReflexValue(stats.getPercentile(50)));
    return new ReflexValue(ret);
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:19,代码来源:ReflexStatistics.java

示例14: statBasedSelectMetricHistory

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/**
 * filter snapshots using statistically significant points only
 * @param selectedLists list of snapshots
 */
private void statBasedSelectMetricHistory(final LinkedList<InMemoryHistoryNode> selectedLists)
    throws ClassCastException {
  logger.debug("selecting snapshots which are far away from mean value");
  DescriptiveStatistics descStats = getDescriptiveStatistics(selectedLists);
  Double mean = descStats.getMean();
  Double std = descStats.getStandardDeviation();

  Iterator<InMemoryHistoryNode> ite = selectedLists.iterator();
  while (ite.hasNext()) {
    InMemoryHistoryNode currentNode = ite.next();
    double value = ((Number) currentNode.getValue()).doubleValue();
    // remove all elements which lies in 95% value band
    if (value < mean + standardDeviationFactor * std && value > mean - standardDeviationFactor * std) {
      ite.remove();
    }
  }
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:22,代码来源:InMemoryMetricEmitter.java

示例15: process

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Override
public Data process(Data item) {
    int[][] singlePulses = (int[][]) item.get(singlePulsesKey);
    double[] arrivalTimes = new double[singlePulses.length];

    for (int pix = 0; pix < singlePulses.length; pix++) {
        if (singlePulses[pix].length == 0) {
            arrivalTimes[pix] = 0.; // use zero instead of NaN - plotter likes no NaN
        } else {
            DescriptiveStatistics stat = new DescriptiveStatistics();
            for (int slice : singlePulses[pix]) {
                stat.addValue((double) slice);
            }
            arrivalTimes[pix] = stat.getPercentile(50);
        }
    }
    item.put(arrivalTimeKey, arrivalTimes);
    return item;
}
 
开发者ID:fact-project,项目名称:fact-tools,代码行数:20,代码来源:PhotonStream2ArrivalTime.java


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