/** * Returns an estimate of the <code>p</code>th percentile of the values * in the <code>values</code> array. * <p> * <ul> * <li>Returns <code>Double.NaN</code> if <code>values</code> has length * <code>0</code></li></p> * <li>Returns (for any value of <code>p</code>) <code>values[0]</code> * if <code>values</code> has length <code>1</code></li> * <li>Throws <code>IllegalArgumentException</code> if <code>values</code> * is null or p is not a valid quantile value (p must be greater than 0 * and less than or equal to 100)</li> * </ul></p> * <p> * See {@link org.apache.commons.math3.stat.descriptive.rank.Percentile} for * a description of the percentile estimation algorithm used.</p> * * @param values input array of values * @param p the percentile value to compute * @return the percentile value or Double.NaN if the array is empty * @throws MathIllegalArgumentException if <code>values</code> is null * or p is invalid */ public static double percentile(final double[] values, final double p) throws MathIllegalArgumentException { return PERCENTILE.evaluate(values,p); }
/** * Returns an estimate of the <code>quantile</code>th percentile of the * designated values in the <code>values</code> array. The quantile * estimated is determined by the <code>quantile</code> property. * <p> * <ul> * <li>Returns <code>Double.NaN</code> if <code>length = 0</code></li> * <li>Returns (for any value of <code>quantile</code>) * <code>values[begin]</code> if <code>length = 1 </code></li> * <li>Throws <code>MathIllegalArgumentException</code> if <code>values</code> * is null, or <code>start</code> or <code>length</code> is invalid</li> * </ul></p> * <p> * See {@link Percentile} for a description of the percentile estimation * algorithm used.</p> * * @param values the input array * @param start index of the first array element to include * @param length the number of elements to include * @return the percentile value * @throws MathIllegalArgumentException if the parameters are not valid * */ @Override public double evaluate(final double[] values, final int start, final int length) throws MathIllegalArgumentException { return evaluate(values, start, length, quantile); }
return PERCENTILE.evaluate(values, begin, length, p);
/** * Returns the result of evaluating the statistic over the stored data. * <p> * The stored array is the one which was set by previous calls to * {@link #setData(double[])} * </p> * @param p the percentile value to compute * @return the value of the statistic applied to the stored data * @throws MathIllegalArgumentException if p is not a valid quantile value * (p must be greater than 0 and less than or equal to 100) */ public double evaluate(final double p) throws MathIllegalArgumentException { return evaluate(getDataRef(), p); }
throws MathIllegalArgumentException { test(values, 0, 0); return evaluate(values, 0, values.length, p);
double upperPercentileMetricValue = _percentile.evaluate(_anomalyUpperPercentile); if (upperPercentileMetricValue <= SIGNIFICANT_METRIC_VALUE_THRESHOLD) { return null; double lowerThreshold = _percentile.evaluate(_anomalyLowerPercentile) * _anomalyLowerMargin; double currentMetricValue = current.metricValues().valuesFor(metricId).latest();
public double[] value(double[] x){ double[] value = new double[size]; for(int i=0;i<size;i++){ value[i] = q[i].evaluate(x, prob[i]); } return value; }
public double[] value(double[] x){ double[] value = new double[size]; for(int i=0;i<size;i++){ value[i] = q[i].evaluate(x, prob[i]); } return value; }
public double value(){ StandardDeviation sd = new StandardDeviation(); double q3 = pcntl.evaluate(x, 75.0); double q1 = pcntl.evaluate(x, 25.0); double IQR = (q3-q1)/1.34; double s = sd.evaluate(x); double N = (double)x.length; double m = Math.min(s, IQR); return 1.06*m*Math.pow(N, -1.0/5.0)*adjustmentFactor; }
/** * Returns the result of evaluating the statistic over the stored data. * <p> * The stored array is the one which was set by previous calls to * {@link #setData(double[])} * </p> * @param p the percentile value to compute * @return the value of the statistic applied to the stored data * @throws MathIllegalArgumentException if p is not a valid quantile value * (p must be greater than 0 and less than or equal to 100) */ public double evaluate(final double p) throws MathIllegalArgumentException { return evaluate(getDataRef(), p); }
/** * Returns the result of evaluating the statistic over the stored data. * <p> * The stored array is the one which was set by previous calls to * {@link #setData(double[])} * </p> * @param p the percentile value to compute * @return the value of the statistic applied to the stored data * @throws MathIllegalArgumentException if p is not a valid quantile value * (p must be greater than 0 and less than or equal to 100) */ public double evaluate(final double p) throws MathIllegalArgumentException { return evaluate(getDataRef(), p); }
private Double findPivot(Map<Long, Double> datapoints, Double limit) { double[] doubleValues = new double[datapoints.size()]; int k = 0; for (Map.Entry<Long, Double> entry : datapoints.entrySet()) { doubleValues[k] = entry.getValue(); k++; } Arrays.sort(doubleValues); double pivotValue = Double.MAX_VALUE; try { pivotValue = new Percentile().evaluate(doubleValues, (double) limit); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Please provide a valid percentile number!"); } return pivotValue; }
private Double findPivot(Map<Long, Double> datapoints, Double limit) { double[] doubleValues = new double[datapoints.size()]; int k = 0; for (Map.Entry<Long, Double> entry : datapoints.entrySet()) { doubleValues[k] = entry.getValue(); k++; } Arrays.sort(doubleValues); double pivotValue = Double.MAX_VALUE; try { pivotValue = new Percentile().evaluate(doubleValues, (double) limit); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Please provide a valid percentile number!"); } return pivotValue; }
@Override public double doublePercentile(int percentile){ if(this.size == 0){ throw new IllegalStateException(); } double[] data = new double[this.size]; System.arraycopy(this.values, 0, data, 0, data.length); Arrays.sort(data); Percentile statistic = new Percentile(); statistic.setData(data); return statistic.evaluate(percentile); } }
private Double _calculateNthPercentile(Collection<Double> values, Double percentileValue) { return new Percentile().evaluate(Doubles.toArray(values), percentileValue); }
private Double _calculateNthPercentile(Collection<Double> values, Double percentileValue) { return new Percentile().evaluate(Doubles.toArray(values), percentileValue); }
private double _calculateValue(double sum, List<Double> numberArr, int count, InternalReducerType type) { if (InternalReducerType.MEDIAN.equals(type)) { double[] numbers = ArrayUtils.toPrimitive(numberArr.toArray(new Double[numberArr.size()])); return new Percentile().evaluate(numbers, 50.0); } if(InternalReducerType.AVG.equals(type)) { return (sum / count); } return sum; }
private double _calculateValue(double sum, List<Double> numberArr, int count, InternalReducerType type) { if (InternalReducerType.MEDIAN.equals(type)) { double[] numbers = ArrayUtils.toPrimitive(numberArr.toArray(new Double[numberArr.size()])); return new Percentile().evaluate(numbers, 50.0); } if(InternalReducerType.AVG.equals(type)) { return (sum / count); } return sum; }
@Override public double getValue() { return new org.apache.commons.math3.stat.descriptive.rank.Percentile(nth * 100) .withEstimationType(org.apache.commons.math3.stat.descriptive.rank.Percentile.EstimationType.R_7) .withNaNStrategy(NaNStrategy.FIXED) .evaluate(values, 0, n); }