本文整理匯總了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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) });
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}