本文整理汇总了Java中org.apache.commons.math.stat.descriptive.DescriptiveStatistics.addValue方法的典型用法代码示例。如果您正苦于以下问题:Java DescriptiveStatistics.addValue方法的具体用法?Java DescriptiveStatistics.addValue怎么用?Java DescriptiveStatistics.addValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.stat.descriptive.DescriptiveStatistics
的用法示例。
在下文中一共展示了DescriptiveStatistics.addValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: frequencyToStatistics
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public static DescriptiveStatistics frequencyToStatistics(Frequency frequency)
{
Iterator<Comparable<?>> comparableIterator = frequency.valuesIterator();
DescriptiveStatistics result = new DescriptiveStatistics();
while (comparableIterator.hasNext()) {
Comparable<?> next = comparableIterator.next();
long count = frequency.getCount(next);
for (int i = 0; i < count; i++) {
if (next instanceof Number) {
result.addValue(((Number) next).doubleValue());
}
}
}
return result;
}
示例2: getClusteringInfo
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public String getClusteringInfo() {
StringBuffer sb = new StringBuffer();
sb.append("concept clustering:\n");
sb.append("mentions:\t");
if (this.groupedConcepts != null) {
int mentions = this.groupedConcepts.stream().mapToInt(x -> x.size()).sum();
sb.append(mentions);
} else {
sb.append("none");
}
sb.append("\n");
sb.append("concepts:\t");
sb.append(this.concepts.size());
sb.append("\n");
DescriptiveStatistics lengthStat = new DescriptiveStatistics();
for (List<Concept> cluster : this.groupedConcepts)
lengthStat.addValue(cluster.size());
sb.append("cluster size:\n");
sb.append(lengthStat);
return sb.toString();
}
示例3: scale
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
private void scale(double[][] peakList) {
DescriptiveStatistics stdDevStats = new DescriptiveStatistics();
for (int columns = 0; columns < peakList.length; columns++) {
stdDevStats.clear();
for (int row = 0; row < peakList[columns].length; row++) {
if (!Double.isInfinite(peakList[columns][row])
&& !Double.isNaN(peakList[columns][row])) {
stdDevStats.addValue(peakList[columns][row]);
}
}
double stdDev = stdDevStats.getStandardDeviation();
for (int row = 0; row < peakList[columns].length; row++) {
if (stdDev != 0) {
peakList[columns][row] = peakList[columns][row] / stdDev;
}
}
}
}
示例4: getCoprocessorExecutionStatistics
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
Map<String, DescriptiveStatistics> results = new HashMap<String, DescriptiveStatistics>();
for (RegionEnvironment env : coprocessors) {
DescriptiveStatistics ds = new DescriptiveStatistics();
if (env.getInstance() instanceof RegionObserver) {
for (Long time : env.getExecutionLatenciesNanos()) {
ds.addValue(time);
}
// Ensures that web ui circumvents the display of NaN values when there are zero samples.
if (ds.getN() == 0) {
ds.addValue(0);
}
results.put(env.getInstance().getClass().getSimpleName(), ds);
}
}
return results;
}
示例5: testTakedown
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
@Override
protected void testTakedown() throws IOException {
if (this.gets != null && this.gets.size() > 0) {
this.table.get(gets);
this.gets.clear();
}
super.testTakedown();
if (opts.reportLatency) {
Arrays.sort(times);
DescriptiveStatistics ds = new DescriptiveStatistics();
for (double t : times) {
ds.addValue(t);
}
LOG.info("randomRead latency log (ms), on " + times.length + " measures");
LOG.info("99.9999% = " + ds.getPercentile(99.9999d));
LOG.info(" 99.999% = " + ds.getPercentile(99.999d));
LOG.info(" 99.99% = " + ds.getPercentile(99.99d));
LOG.info(" 99.9% = " + ds.getPercentile(99.9d));
LOG.info(" 99% = " + ds.getPercentile(99d));
LOG.info(" 95% = " + ds.getPercentile(95d));
LOG.info(" 90% = " + ds.getPercentile(90d));
LOG.info(" 80% = " + ds.getPercentile(80d));
LOG.info("Standard Deviation = " + ds.getStandardDeviation());
LOG.info("Mean = " + ds.getMean());
}
}
示例6: computeStatistics
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
* Compute the current aggregate statistics of the
* accumulated results.
*
* @return the current aggregate statistics
*/
public AggregateStatistics computeStatistics() {
DescriptiveStatistics accuracy = new DescriptiveStatistics();
DescriptiveStatistics errorRate = new DescriptiveStatistics();
for (CMResult<CLASS> result : matrices) {
ConfusionMatrix<CLASS> m = result.getMatrix();
accuracy.addValue(m.getAccuracy());
errorRate.addValue(m.getErrorRate());
}
AggregateStatistics s = new AggregateStatistics();
s.meanAccuracy = accuracy.getMean();
s.stddevAccuracy = accuracy.getStandardDeviation();
s.meanErrorRate = errorRate.getMean();
s.stddevErrorRate = errorRate.getStandardDeviation();
return s;
}
示例7: normalize
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
* Normalize (standardize) the series, so in the end it is having a mean of 0 and a standard deviation of 1.
*
* @param sample Sample to normalize.
* @return normalized (standardized) sample.
* @since 2.2
*/
public static double[] normalize(final double[] sample) {
DescriptiveStatistics stats = new DescriptiveStatistics();
// Add the data from the series to stats
for (int i = 0; i < sample.length; i++) {
stats.addValue(sample[i]);
}
// Compute mean and standard deviation
double mean = stats.getMean();
double standardDeviation = stats.getStandardDeviation();
// initialize the standardizedSample, which has the same length as the sample
double[] standardizedSample = new double[sample.length];
for (int i = 0; i < sample.length; i++) {
// z = (x- mean)/standardDeviation
standardizedSample[i] = (sample[i] - mean) / standardDeviation;
}
return standardizedSample;
}
示例8: testNormalize2
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
* Run with 77 random values, assuming that the outcome has a mean of 0 and a standard deviation of 1 with a
* precision of 1E-10.
*/
public void testNormalize2() {
// create an sample with 77 values
int length = 77;
double sample[] = new double[length];
for (int i = 0; i < length; i++) {
sample[i] = Math.random();
}
// normalize this sample
double standardizedSample[] = StatUtils.normalize(sample);
DescriptiveStatistics stats = new DescriptiveStatistics();
// Add the data from the array
for (int i = 0; i < length; i++) {
stats.addValue(standardizedSample[i]);
}
// the calculations do have a limited precision
double distance = 1E-10;
// check the mean an standard deviation
assertEquals(0.0, stats.getMean(), distance);
assertEquals(1.0, stats.getStandardDeviation(), distance);
}
示例9: testNormalize2
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
* Run with 77 random values, assuming that the outcome has a mean of 0 and a standard deviation of 1 with a
* precision of 1E-10.
*/
@Test
public void testNormalize2() {
// create an sample with 77 values
int length = 77;
double sample[] = new double[length];
for (int i = 0; i < length; i++) {
sample[i] = Math.random();
}
// normalize this sample
double standardizedSample[] = StatUtils.normalize(sample);
DescriptiveStatistics stats = new DescriptiveStatistics();
// Add the data from the array
for (int i = 0; i < length; i++) {
stats.addValue(standardizedSample[i]);
}
// the calculations do have a limited precision
double distance = 1E-10;
// check the mean an standard deviation
Assert.assertEquals(0.0, stats.getMean(), distance);
Assert.assertEquals(1.0, stats.getStandardDeviation(), distance);
}
示例10: testCostFromStats
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
@Test
public void testCostFromStats() {
DescriptiveStatistics statOne = new DescriptiveStatistics();
for (int i =0; i < 100; i++) {
statOne.addValue(10);
}
assertEquals(0, loadBalancer.costFromStats(statOne), 0.01);
DescriptiveStatistics statTwo = new DescriptiveStatistics();
for (int i =0; i < 100; i++) {
statTwo.addValue(0);
}
statTwo.addValue(100);
assertEquals(1, loadBalancer.costFromStats(statTwo), 0.01);
DescriptiveStatistics statThree = new DescriptiveStatistics();
for (int i =0; i < 100; i++) {
statThree.addValue(0);
statThree.addValue(100);
}
assertEquals(0.5, loadBalancer.costFromStats(statThree), 0.01);
}
示例11: drawNormalDistributionChart
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public void drawNormalDistributionChart(double[] values) {
DescriptiveStatistics stats = new DescriptiveStatistics();
// Add the data from the array
for (int i = 0; i < values.length; i++) {
stats.addValue(values[i]);
}
// Compute some statistics
double mean = stats.getMean();
double std = stats.getStandardDeviation();
double skewness = stats.getSkewness();
double variance = stats.getVariance();
double kurtosis = stats.getKurtosis();
System.out.println(mean + "\t" + std + "\t" + skewness + "\t" + variance + "\t" + kurtosis);
stats.clear();
}
示例12: export
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
private static void export(File argumentsWithReasonsFile, File argumentsWithGistFile,
File outputDir)
throws Exception
{
List<StandaloneArgument> arguments = ExportHelper.copyReasonAnnotationsWithGistOnly(
argumentsWithReasonsFile, argumentsWithGistFile);
String metaDataCSV = ExportHelper.exportMetaDataToCSV(arguments);
FileUtils.write(new File(outputDir, "metadata.csv"), metaDataCSV, "utf-8");
Frequency premisesFrequency = new Frequency();
DescriptiveStatistics premisesStatistics = new DescriptiveStatistics();
// and export them all as XMI files using standard DKPro pipeline
for (StandaloneArgument argument : arguments) {
JCas jCas = argument.getJCas();
SimplePipeline.runPipeline(jCas, AnalysisEngineFactory.createEngineDescription(
XmiWriter.class,
XmiWriter.PARAM_TARGET_LOCATION, outputDir,
XmiWriter.PARAM_USE_DOCUMENT_ID, true,
XmiWriter.PARAM_OVERWRITE, true
));
// count all premises
int count = JCasUtil.select(jCas, Premise.class).size();
premisesStatistics.addValue(count);
premisesFrequency.addValue(count);
}
System.out.println("Premises total: " + premisesStatistics.getSum());
System.out.println("Argument: " + arguments.size());
System.out.println(premisesFrequency);
}
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:34,代码来源:Step3dExportGistToXMIFiles.java
示例13: main
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public static void main(String[] args)
throws IOException
{
File inputFile = new File(
"mturk/annotation-task/data/32-reasons-batch-0001-5000-2026args-gold.xml.gz");
// read all arguments from the original corpus
List<StandaloneArgument> arguments = XStreamSerializer
.deserializeArgumentListFromXML(inputFile);
System.out.println("Arguments: " + arguments.size());
Frequency frequency = new Frequency();
DescriptiveStatistics statistics = new DescriptiveStatistics();
for (StandaloneArgument argument : arguments) {
JCas jCas = argument.getJCas();
Collection<Premise> premises = JCasUtil.select(jCas, Premise.class);
frequency.addValue(premises.size());
statistics.addValue(premises.size());
}
System.out.println(frequency);
System.out.println(statistics.getSum());
System.out.println(statistics.getMean());
System.out.println(statistics.getStandardDeviation());
}
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:28,代码来源:Step2dGoldReasonStatistics.java
示例14: statistics3
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public static void statistics3(File inputDir, File outputDir)
throws IOException
{
PrintWriter pw = new PrintWriter(new FileWriter(new File(outputDir, "stats3.csv")));
pw.println(
"qID\tagreementMean\tagreementStdDev\tqueryText");
// iterate over query containers
for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) {
QueryResultContainer queryResultContainer = QueryResultContainer
.fromXML(FileUtils.readFileToString(f, "utf-8"));
DescriptiveStatistics statistics = new DescriptiveStatistics();
for (QueryResultContainer.SingleRankedResult rankedResult : queryResultContainer.rankedResults) {
Double observedAgreement = rankedResult.observedAgreement;
if (observedAgreement != null) {
statistics.addValue(observedAgreement);
}
}
pw.printf(Locale.ENGLISH, "%s\t%.3f\t%.3f\t%s%n",
queryResultContainer.qID, statistics.getMean(),
statistics.getStandardDeviation(),
queryResultContainer.query
);
}
pw.close();
}
开发者ID:UKPLab,项目名称:sigir2016-collection-for-focused-retrieval,代码行数:32,代码来源:Step11GoldDataStatistics.java
示例15: winsor2
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**Winsorise vector x. Adapted from https://www.r-bloggers.com/winsorization/.
* */
public static List<Float> winsor2(List<Float> x, double multiple) {
/*
winsor2<- function (x, multiple=3)
{
med <- median(x)
y <- x - med
sc <- mad(y, center=0) * multiple
y[ y > sc ] <- sc
y[ y < -sc ] <- -sc
y + med
}
*/
if(multiple <= 0){
throw new ArithmeticException();
}
DescriptiveStatistics stats = new DescriptiveStatistics();
for(float z : x){
stats.addValue(z);
}
float median = (float)stats.getPercentile(50);
List<Float> y= new ArrayList<Float>(x);
for(int i= 0; i < x.size(); i++){
y.set(i, x.get(i) - median);
}
float sc= (float) (Utils.medianAbsoluteDeviation(y, 0) * multiple);
for(int i= 0; i < y.size(); i++){
if(y.get(i) > sc){
y.set(i, sc);
}
else if(y.get(i) < -sc){
y.set(i, -sc);
}
y.set(i, y.get(i) + median);
}
return y;
}