当前位置: 首页>>代码示例>>Java>>正文


Java LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD属性代码示例

本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD属性的具体用法?Java LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD怎么用?Java LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.math3.exception.util.LocalizedFormats的用法示例。


在下文中一共展示了LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPercentile

/**
 * Returns an estimate for the pth percentile of the stored values.
 * <p>
 * The implementation provided here follows the first estimation procedure presented
 * <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm">here.</a>
 * </p><p>
 * <strong>Preconditions</strong>:<ul>
 * <li><code>0 &lt; p &le; 100</code> (otherwise an
 * <code>MathIllegalArgumentException</code> is thrown)</li>
 * <li>at least one value must be stored (returns <code>Double.NaN
 *     </code> otherwise)</li>
 * </ul></p>
 *
 * @param p the requested percentile (scaled from 0 - 100)
 * @return An estimate for the pth percentile of the stored data
 * @throws MathIllegalStateException if percentile implementation has been
 *  overridden and the supplied implementation does not support setQuantile
 * @throws MathIllegalArgumentException if p is not a valid quantile
 */
public double getPercentile(double p) throws MathIllegalStateException, MathIllegalArgumentException {
    if (percentileImpl instanceof Percentile) {
        ((Percentile) percentileImpl).setQuantile(p);
    } else {
        try {
            percentileImpl.getClass().getMethod(SET_QUANTILE_METHOD_NAME,
                    new Class[] {Double.TYPE}).invoke(percentileImpl,
                            new Object[] {Double.valueOf(p)});
        } catch (NoSuchMethodException e1) { // Setter guard should prevent
            throw new MathIllegalStateException(
                  LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD,
                  percentileImpl.getClass().getName(), SET_QUANTILE_METHOD_NAME);
        } catch (IllegalAccessException e2) {
            throw new MathIllegalStateException(
                  LocalizedFormats.PERCENTILE_IMPLEMENTATION_CANNOT_ACCESS_METHOD,
                  SET_QUANTILE_METHOD_NAME, percentileImpl.getClass().getName());
        } catch (InvocationTargetException e3) {
            throw new IllegalStateException(e3.getCause());
        }
    }
    return apply(percentileImpl);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:41,代码来源:DescriptiveStatistics.java

示例2: setPercentileImpl

/**
 * Sets the implementation to be used by {@link #getPercentile(double)}.
 * The supplied <code>UnivariateStatistic</code> must provide a
 * <code>setQuantile(double)</code> method; otherwise
 * <code>IllegalArgumentException</code> is thrown.
 *
 * @param percentileImpl the percentileImpl to set
 * @throws MathIllegalArgumentException if the supplied implementation does not
 *  provide a <code>setQuantile</code> method
 * @since 1.2
 */
public synchronized void setPercentileImpl(UnivariateStatistic percentileImpl)
throws MathIllegalArgumentException {
    try {
        percentileImpl.getClass().getMethod(SET_QUANTILE_METHOD_NAME,
                new Class[] {Double.TYPE}).invoke(percentileImpl,
                        new Object[] {Double.valueOf(50.0d)});
    } catch (NoSuchMethodException e1) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD,
              percentileImpl.getClass().getName(), SET_QUANTILE_METHOD_NAME);
    } catch (IllegalAccessException e2) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.PERCENTILE_IMPLEMENTATION_CANNOT_ACCESS_METHOD,
              SET_QUANTILE_METHOD_NAME, percentileImpl.getClass().getName());
    } catch (InvocationTargetException e3) {
        throw new IllegalArgumentException(e3.getCause());
    }
    this.percentileImpl = percentileImpl;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:30,代码来源:DescriptiveStatistics.java


注:本文中的org.apache.commons.math3.exception.util.LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。