當前位置: 首頁>>代碼示例>>Java>>正文


Java DescriptiveStatistics.getPercentile方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getPercentile方法的典型用法代碼示例。如果您正苦於以下問題:Java DescriptiveStatistics.getPercentile方法的具體用法?Java DescriptiveStatistics.getPercentile怎麽用?Java DescriptiveStatistics.getPercentile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.stat.descriptive.DescriptiveStatistics的用法示例。


在下文中一共展示了DescriptiveStatistics.getPercentile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: testQuantiles

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
@Test
public void testQuantiles() {
    Random r = new Random(0);
    List<DataPoint> points = new ArrayList<>();
    DescriptiveStatistics stats = new DescriptiveStatistics();
    Distribution distribution = null;
    for(int i = 0; i < 100;++i) {
        double val = r.nextDouble()*1000;
        DataPoint dp = (new DataPoint(i, val, null, "foo"));
        points.add(dp);
        stats.addValue(val);
        if(distribution == null) {
            distribution = new Distribution(dp, ScalingFunctions.NONE, new GlobalStatistics());
        }
        else {
            distribution.addDataPoint(dp, ScalingFunctions.NONE);
        }
    }
    double realMedian = stats.getPercentile(50);
    double approxMedian = distribution.getMedian();
    System.out.println("mean and std dev: " + stats.getMean() + ", " + Math.sqrt(stats.getVariance()));
    System.out.println("Real : " + realMedian + ", approx: " + approxMedian);
    Assert.assertTrue(Math.abs(realMedian - approxMedian) < 5);
}
 
開發者ID:cestella,項目名稱:streaming_outliers,代碼行數:25,代碼來源:DistributionTest.java

示例3: getDescStats

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
public void getDescStats(double[] values){
	DescriptiveStatistics stats = new DescriptiveStatistics();
	for( int i = 0; i < values.length; i++) {
	        stats.addValue(values[i]);
	}
	double mean = stats.getMean();
	double std = stats.getStandardDeviation();
	double median = stats.getPercentile(50);
	System.out.println(mean + "\t" + std + "\t" + median);
}
 
開發者ID:PacktPublishing,項目名稱:Java-Data-Science-Cookbook,代碼行數:11,代碼來源:DescriptiveStats.java

示例4: medianMisMatch

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
private static int medianMisMatch (String matchLine) {
	DescriptiveStatistics stats = new DescriptiveStatistics();
	for (int i=0; i<matchLine.length(); i++) {
		if  (matchLine.substring(i, i+1).equals(" ")) {
			stats.addValue(i+1);
		}
	}
	double median = 100 * (double) stats.getPercentile(50) / (double) matchLine.length();
	return (int) median;
}
 
開發者ID:hivdb,項目名稱:sierra,代碼行數:11,代碼來源:BlastXmlOutputParser.java

示例5: isOutlierByModifiedZScore

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
private boolean isOutlierByModifiedZScore(DescriptiveStatistics stats, double value)
{
    double median = stats.getPercentile(50);
    double medianAbsoluteDeviation = new DescriptiveStatistics(
        Arrays.stream(stats.getValues()).map(v -> Math.abs(v - median)).toArray()).getPercentile(50);
    double modifiedZScore = 0.6745 * (value - median) / medianAbsoluteDeviation;

    return Math.abs(modifiedZScore) > 3.5;
}
 
開發者ID:marcelovca90,項目名稱:anti-spam-weka-gui,代碼行數:10,代碼來源:ExperimentHelper.java

示例6: isOutlierByInterquartileRange

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
private boolean isOutlierByInterquartileRange(DescriptiveStatistics stats, double value)
{
    double quartile1 = stats.getPercentile(25);
    double quartile3 = stats.getPercentile(75);
    double iqr = quartile3 - quartile1;
    double lowerBound = quartile1 - (iqr * 1.5);
    double upperBound = quartile3 + (iqr * 1.5);

    return (value < lowerBound || value > upperBound);
}
 
開發者ID:marcelovca90,項目名稱:anti-spam-weka-gui,代碼行數:11,代碼來源:ExperimentHelper.java

示例7: 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) {
	final DescriptiveStatistics stats = new DescriptiveStatistics();
	for (int i = 0; i < preds.length; ++i) {
		final double[] predAndAct = toDouble(preds[i], expected[i]);
		stats.addValue(Math.abs(predAndAct[0] - predAndAct[1]));
	}
	return new DescriptiveStatistics(new double[] { stats.getPercentile(50) });
}
 
開發者ID:ProfilingIO,項目名稱:insight-ml,代碼行數:11,代碼來源:MedianError.java

示例8: prediction

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
private double prediction(final DescriptiveStatistics stats) {
	switch (nodePrediction) {
	case "mean":
		return stats.getMean();
	case "median":
		return stats.getPercentile(50);
	case "meandian":
		return (stats.getMean() + stats.getPercentile(50)) / 2;
	default:
		throw new IllegalArgumentException(nodePrediction);
	}
}
 
開發者ID:ProfilingIO,項目名稱:insight-ml,代碼行數:13,代碼來源:GrowJob.java

示例9: getResult

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
@Override
public float getResult() {
    if (count == 0)
        return Float.NaN;
    
    double[] primitiveValues = new double[floatValues.size()];
    for (int i = 0; i < floatValues.size(); i++)
        primitiveValues[i] = floatValues.get(i);
    DescriptiveStatistics stats = new DescriptiveStatistics(primitiveValues);
    
    return (float) stats.getPercentile(50);
}
 
開發者ID:ViDA-NYU,項目名稱:data-polygamy,代碼行數:13,代碼來源:Median.java

示例10: getIQR

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
public double getIQR(ArrayList<Float> arrayList) {
    double[] vals = new double[arrayList.size()];
    for (int i = 0; i < arrayList.size(); i++) {
        vals[i] = (double)arrayList.get(i);
    }
    DescriptiveStatistics ds = new DescriptiveStatistics(vals);
    double fq = ds.getPercentile(25);
    double tq = ds.getPercentile(75);
    return (tq - fq);
}
 
開發者ID:ViDA-NYU,項目名稱:data-polygamy,代碼行數:11,代碼來源:NoiseExp.java

示例11: apply

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
private Double apply(ITimeSeriesUnivariate t) {
	List<Double> vals = t.getValues();
	double[] da = new double[vals.size()];
	for (int i = 0; i < vals.size(); i++) {
		da[i] = vals.get(i);
	}
	DescriptiveStatistics ds = new DescriptiveStatistics(da);
	return ds.getPercentile(50);
}
 
開發者ID:TKnudsen,項目名稱:timeSeries,代碼行數:10,代碼來源:Value2ndQuartileFeatureExtractor.java

示例12: apply

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
private Double apply(ITimeSeriesUnivariate t) {
	List<Double> vals = t.getValues();
	double[] da = new double[vals.size()];
	for (int i = 0; i < vals.size(); i++) {
		da[i] = vals.get(i);
	}
	DescriptiveStatistics ds = new DescriptiveStatistics(da);
	return ds.getPercentile(75);
}
 
開發者ID:TKnudsen,項目名稱:timeSeries,代碼行數:10,代碼來源:Value3rdQuartileFeatureExtractor.java

示例13: apply

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
private Double apply(ITimeSeriesUnivariate t) {
	List<Double> vals = t.getValues();
	double[] da = new double[vals.size()];
	for (int i = 0; i < vals.size(); i++) {
		da[i] = vals.get(i);
	}
	DescriptiveStatistics ds = new DescriptiveStatistics(da);
	return ds.getPercentile(25);
}
 
開發者ID:TKnudsen,項目名稱:timeSeries,代碼行數:10,代碼來源:Value1stQuartileFeatureExtractor.java

示例14: getMedian

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
private Double getMedian(final String feature) {
	final DescriptiveStatistics stat = stats.get(feature);
	return stat == null ? null : stat.getPercentile(50);
}
 
開發者ID:ProfilingIO,項目名稱:insight-ml,代碼行數:5,代碼來源:FeatureStatistics.java

示例15: process

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //導入方法依賴的package包/類
@Override
public Data process(Data item) {
    Utils.isKeyValid(item, "NPIX", Integer.class);
    npix = (Integer) item.get("NPIX");

    Utils.mapContainsKeys(item, dataKey);

    int[][] data = (int[][]) item.get(dataKey);

    double[] mean = new double[npix];
    double[] median = new double[npix];
    double[] mode = new double[npix];
    double[] std = new double[npix];
    double[] kurtosis = new double[npix];
    double[] skewness = new double[npix];
    double[] min = new double[npix];
    double[] max = new double[npix];
    double[] quantil25 = new double[npix];
    double[] quantil75 = new double[npix];

    for (int pix = 0; pix < npix; pix++) {
        double[] values = Utils.toDoubleArray(data[pix]);


        ///FIXME: fill nans instead of continue
        if (values.length == 0) {
            continue;
        }

        DescriptiveStatistics stats = new DescriptiveStatistics(values);
        mean[pix] = stats.getMean();
        min[pix] = stats.getMin();
        max[pix] = stats.getMax();
        std[pix] = stats.getStandardDeviation();
        skewness[pix] = stats.getSkewness();
        kurtosis[pix] = stats.getKurtosis();
        quantil25[pix] = stats.getPercentile(0.25);
        quantil75[pix] = stats.getPercentile(0.75);
        median[pix] = stats.getPercentile(0.5);

        double[] modeArray = StatUtils.mode(values);
        mode[pix] = modeArray[0];
    }

    item.put(outputKey + "_mean", mean);
    item.put(outputKey + "_median", median);
    item.put(outputKey + "_mode", mode);
    item.put(outputKey + "_std", std);
    item.put(outputKey + "_kurtosis", kurtosis);
    item.put(outputKey + "_skewness", skewness);
    item.put(outputKey + "_min", min);
    item.put(outputKey + "_max", max);
    item.put(outputKey + "_quantil25", quantil25);
    item.put(outputKey + "_quantil75", quantil75);


    return item;
}
 
開發者ID:fact-project,項目名稱:fact-tools,代碼行數:59,代碼來源:SinglePeStatisticsPixel.java


注:本文中的org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getPercentile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。