當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。