/** * {@inheritDoc}This method in particular for R_2 averages the * values at ceil(p+0.5) and floor(p-0.5). */ @Override protected double estimate(final double[] values, final int[] pivotsHeap, final double pos, final int length, final KthSelector selector) { final double low = super.estimate(values, pivotsHeap, Math.ceil(pos - 0.5), length, selector); final double high = super.estimate(values, pivotsHeap,Math.floor(pos + 0.5), length, selector); return (low + high) / 2; }
final int[] pivotsHeap = getPivots(values); return work.length == 0 ? Double.NaN : estimationType.evaluate(work, pivotsHeap, p, kthSelector);
final int[] pivotsHeap = getPivots(values); return work.length == 0 ? Double.NaN : estimationType.evaluate(work, pivotsHeap, p, kthSelector);
/** * Evaluate method to compute the percentile for a given bounded array * using earlier computed pivots heap.<br> * This basically calls the {@link #index(double, int) index} and then * {@link #estimate(double[], int[], double, int, KthSelector) estimate} * functions to return the estimated percentile value. * * @param work array of numbers to be used for finding the percentile * @param pivotsHeap a prior cached heap which can speed up estimation * @param p the p<sup>th</sup> quantile to be computed * @param selector a {@link KthSelector} used for pivoting during search * @return estimated percentile * @throws OutOfRangeException if p is out of range * @throws NullArgumentException if work array is null */ protected double evaluate(final double[] work, final int[] pivotsHeap, final double p, final KthSelector selector) { MathUtils.checkNotNull(work); if (p > 100 || p <= 0) { throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100); } return estimate(work, pivotsHeap, index(p/100d, work.length), work.length, selector); }
/** * Evaluate method to compute the percentile for a given bounded array * using earlier computed pivots heap.<br> * This basically calls the {@link #index(double, int) index} and then * {@link #estimate(double[], int[], double, int, KthSelector) estimate} * functions to return the estimated percentile value. * * @param work array of numbers to be used for finding the percentile * @param pivotsHeap a prior cached heap which can speed up estimation * @param p the p<sup>th</sup> quantile to be computed * @param selector a {@link KthSelector} used for pivoting during search * @return estimated percentile * @throws OutOfRangeException if p is out of range * @throws NullArgumentException if work array is null */ protected double evaluate(final double[] work, final int[] pivotsHeap, final double p, final KthSelector selector) { MathUtils.checkNotNull(work); if (p > 100 || p <= 0) { throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100); } return estimate(work, pivotsHeap, index(p/100d, work.length), work.length, selector); }
/** * Evaluate method to compute the percentile for a given bounded array. * This basically calls the {@link #index(double, int) index} and then * {@link #estimate(double[], int[], double, int, KthSelector) estimate} * functions to return the estimated percentile value. Please * note that this method does not make use of cached pivots. * * @param work array of numbers to be used for finding the percentile * @param p the p<sup>th</sup> quantile to be computed * @return estimated percentile * @param selector a {@link KthSelector} used for pivoting during search * @throws OutOfRangeException if length or p is out of range * @throws NullArgumentException if work array is null */ public double evaluate(final double[] work, final double p, final KthSelector selector) { return this.evaluate(work, null, p, selector); }
/** * Evaluate method to compute the percentile for a given bounded array. * This basically calls the {@link #index(double, int) index} and then * {@link #estimate(double[], int[], double, int, KthSelector) estimate} * functions to return the estimated percentile value. Please * note that this method does not make use of cached pivots. * * @param work array of numbers to be used for finding the percentile * @param p the p<sup>th</sup> quantile to be computed * @return estimated percentile * @param selector a {@link KthSelector} used for pivoting during search * @throws OutOfRangeException if length or p is out of range * @throws NullArgumentException if work array is null */ public double evaluate(final double[] work, final double p, final KthSelector selector) { return this.evaluate(work, null, p, selector); }
/** * {@inheritDoc}This method in particular for R_2 averages the * values at ceil(p+0.5) and floor(p-0.5). */ @Override protected double estimate(final double[] values, final int[] pivotsHeap, final double pos, final int length, final KthSelector selector) { final double low = super.estimate(values, pivotsHeap, FastMath.ceil(pos - 0.5), length, selector); final double high = super.estimate(values, pivotsHeap,FastMath.floor(pos + 0.5), length, selector); return (low + high) / 2; }
/** * {@inheritDoc}This method in particular for R_1 uses ceil(pos-0.5) */ @Override protected double estimate(final double[] values, final int[] pivotsHeap, final double pos, final int length, final KthSelector selector) { return super.estimate(values, pivotsHeap, FastMath.ceil(pos - 0.5), length, selector); }
/** * {@inheritDoc}This method in particular for R_1 uses ceil(pos-0.5) */ @Override protected double estimate(final double[] values, final int[] pivotsHeap, final double pos, final int length, final KthSelector selector) { return super.estimate(values, pivotsHeap, Math.ceil(pos - 0.5), length, selector); }
final int[] pivotsHeap = getPivots(values); return work.length == 0 ? Double.NaN : estimationType.evaluate(work, pivotsHeap, p, kthSelector);
/** * Evaluate method to compute the percentile for a given bounded array * using earlier computed pivots heap.<br> * This basically calls the {@link #index(double, int) index} and then * {@link #estimate(double[], int[], double, int, KthSelector) estimate} * functions to return the estimated percentile value. * * @param work array of numbers to be used for finding the percentile * @param pivotsHeap a prior cached heap which can speed up estimation * @param p the p<sup>th</sup> quantile to be computed * @param selector a {@link KthSelector} used for pivoting during search * @return estimated percentile * @throws OutOfRangeException if p is out of range * @throws NullArgumentException if work array is null */ protected double evaluate(final double[] work, final int[] pivotsHeap, final double p, final KthSelector selector) { MathUtils.checkNotNull(work); if (p > 100 || p <= 0) { throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100); } return estimate(work, pivotsHeap, index(p/100d, work.length), work.length, selector); }
/** * Evaluate method to compute the percentile for a given bounded array. * This basically calls the {@link #index(double, int) index} and then * {@link #estimate(double[], int[], double, int, KthSelector) estimate} * functions to return the estimated percentile value. Please * note that this method does not make use of cached pivots. * * @param work array of numbers to be used for finding the percentile * @param p the p<sup>th</sup> quantile to be computed * @return estimated percentile * @param selector a {@link KthSelector} used for pivoting during search * @throws OutOfRangeException if length or p is out of range * @throws NullArgumentException if work array is null */ public double evaluate(final double[] work, final double p, final KthSelector selector) { return this.evaluate(work, null, p, selector); }
/** * {@inheritDoc}This method in particular for R_2 averages the * values at ceil(p+0.5) and floor(p-0.5). */ @Override protected double estimate(final double[] values, final int[] pivotsHeap, final double pos, final int length, final KthSelector selector) { final double low = super.estimate(values, pivotsHeap, FastMath.ceil(pos - 0.5), length, selector); final double high = super.estimate(values, pivotsHeap,FastMath.floor(pos + 0.5), length, selector); return (low + high) / 2; }
/** * {@inheritDoc}This method in particular for R_1 uses ceil(pos-0.5) */ @Override protected double estimate(final double[] values, final int[] pivotsHeap, final double pos, final int length, final KthSelector selector) { return super.estimate(values, pivotsHeap, FastMath.ceil(pos - 0.5), length, selector); }