本文整理汇总了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;
}